KhronosGroup / KhronosGroup/Vulkan-Tutorial

Lesson 9, I like to whine

未关闭
#112 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
418
派生
126
平均合并
11 天 6 小时
30 天内合并 PR
31

描述

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`).

贡献指南

打开贡献指南

调研方向

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.

由索引模型根据 Issue 内容生成。

评估

技术栈
cmake, cpp
领域
build-system, documentation
Issue 类型
文档
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。