KhronosGroup / KhronosGroup/Vulkan-Tutorial

Lesson 9, I like to whine

Abierto
#112 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C++
Estrellas
418
Forks
126
Merge medio
11 d 6 h
PR fusionados (30 d)
31

Descripción

This bit of text is odd:

> The built-in annotation SV_Position functions as the output. Within the VertexOutput struct. Something worth mentioning if you’re familiar with other shading languages like GLSL or HLSL, there are no instructions for bindings.

Is this three sentences or two?

Not an error but a suggestion: stick with Slang throughout as far as compilation goes (you can keep the GLSL files as examples). Trying to reverse-engineer the existing CMakeLists.txt in the `attachments` directory for one's own code is complicated by trying to account for both.

Text says `SV_TARGET`, code says `SV_Target`.

There's a mention of `location` directives, which seems to be a remnant of the original vulkan-tutorial.com version of this lesson that used GLSL fragment shaders.

Also not an error, but there is a paragraph starting with "At the time of writing..." justifying the use of SPIR-V 1.4, which wikipedia says was released 5 years ago.

In this code block:

```
add_slang_shader_target( foo SOURCES ${SHADER_SLANG_SOURCES})
target_add_dependencies(bar PUBLIC foo)
```

It's not clear to me what the second line means. And should it be `target_add_dependencies` or `add_dependencies` which is closer to what's in the sample code's CMakeLists.txt?

Anyway, I had trouble getting the code to compile using the `add_slang_shader_target` function in the tutorial until I added a dummy variable and passed a dummy string to it, because cmake was complaining that I'd defined the keyword "SOURCE" more than once. Apparently `cmake_parse_arguments` needs at least four arguments and I think if you pass it fewer then it just doubles one of the parameters? The Cmake documentation says up front that the implementation of `cmake_parse_arguments` is "naive". Anyway, I had to do this:

```
function(add_slang_shader_target TARGET)
cmake_parse_arguments("SHADER" "" "SOURCES" "POINTLESS" ${ARGN})
set(SHADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/shader)
set(ENTRY_POINTS -entry vertMain -entry fragMain)
add_custom_command(
OUTPUT ${SHADERS_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${SHADERS_DIR}
)
add_custom_command(
OUTPUT ${SHADERS_DIR}/slang.spv
COMMAND ${SLANGC_EXECUTABLE} ${SHADER_SOURCES} -target spirv -profile spirv_1_4 -emit-spirv-directly -fvk-use-entrypoint-name ${ENTRY_POINTS} -o slang.spv
WORKING_DIRECTORY ${SHADERS_DIR}
DEPENDS ${SHADERS_DIR} ${SHADER_SOURCES}
COMMENT "Compiling Slang Shaders"
VERBATIM
)
add_custom_target(${TARGET} DEPENDS ${SHADERS_DIR}/slang.spv)
endfunction()
```

And then this:

```
add_slang_shader_target(${SLANG_SHADER_TARGET} SOURCES ${SHADER_SOURCE_FILES} POINTLESS "FOO")
add_dependencies(${PROJECT_NAME} ${SLANG_SHADER_TARGET})
```

And that worked.

In the function `readFile` if you're trying to keep the C++20 thing going then you might switch from raw string paths to std::filesystem

More C API references in multiple places (e.g. `VkFoo` instead of `vk::foo`).

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start with Lesson 9 and the CMakeLists.txt in the attachments directory, then compare the prose, code blocks, and shader examples for the reported terminology and CMake inconsistencies. Try the documented add_slang_shader_target example and review the readFile and C API references mentioned in the issue. Done means the lesson text and examples are internally consistent and the documented compilation path works.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
cmake, cpp
Área
build-system, documentation
Tipo de issue
Documentación
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.