Support setting target environment version, e.g. Vulkan 1.1#445
Support setting target environment version, e.g. Vulkan 1.1#445antiagainst merged 2 commits intogoogle:masterfrom
Conversation
NOTE: We no longer can compile OpenGL compatibility profile shaders to SPIR-V. These will error out. C and C++ API: Set nontrivial target environment version Glslc --target-env accepts optional version suffix, e.g. vulkan1.1
|
FYI: CI-ubuntu-clang-debug failure is a config failure: " clang is not a full path and was not found in the PATH." |
|
PTAL @antiagainst . @dgkoch has asked for this to land sooner rather than later. |
antiagainst
left a comment
There was a problem hiding this comment.
Sorry for the late review! Overall LGTM! Just a few nits.
|
|
||
|
|
||
| @inside_glslc_testsuite('OptionTargetEnv') | ||
| class TestTargetEnvEqVulkan1_0WithVulkan1_1ShaderFails(expect.ErrorMessageSubstr): |
There was a problem hiding this comment.
This is a duplicate test with the one at Line 98?
There was a problem hiding this comment.
Yes! Deleting the one at line 98.
glslc/test/option_target_env.py
Outdated
| @inside_glslc_testsuite('OptionTargetEnv') | ||
| class TestTargetEnvEqVulkan1_1WithVulkan1_0ShaderSucceeds(expect.ValidObjectFile): | ||
| shader = FileShader(vulkan_vertex_shader(), '.vert') | ||
| glslc_args = ['--target-env=vulkan1.0', '-c', shader] |
There was a problem hiding this comment.
Should be --target-env=vulkan1.1?
libshaderc/include/shaderc/shaderc.h
Outdated
| shaderc_target_env_opengl, // create SPIR-V under OpenGL semantics | ||
| shaderc_target_env_vulkan, // create SPIR-V under Vulkan semantics | ||
| shaderc_target_env_opengl, // create SPIR-V under OpenGL semantics | ||
| // NOTE: SPIR-V coide generation is not supported for shaders under OpenGL |
libshaderc/include/shaderc/shaderc.h
Outdated
| shaderc_env_version_vulkan_1_0 = (((uint32_t)1 << 22)), | ||
| shaderc_env_version_vulkan_1_1 = (((uint32_t)1 << 22) | (1 << 12)), | ||
| // For OpenGL, use the number from #version in shaders. | ||
| // TODO(dneto): Currently no difference between OpenGL 4.5 andf 4.6. |
| OpenGLCompat, | ||
| }; | ||
|
|
||
| // Target environment versions. These bnumbgers match those used by Glslang. |
| // Sets the target environment. | ||
| void SetTargetEnv(TargetEnv env); | ||
| // Sets the target environment, including version. | ||
| // 0 means the default version for the |
There was a problem hiding this comment.
for the target environment?
libshaderc_util/src/compiler.cc
Outdated
| std::vector<uint32_t>& compilation_output_data = std::get<1>(result_tuple); | ||
| size_t& compilation_output_data_size_in_bytes = std::get<2>(result_tuple); | ||
|
|
||
| // Check target envirohnment. |
There was a problem hiding this comment.
s/envirohnment/environment/
| OpenGLCompat, | ||
| }; | ||
|
|
||
| // Target environment versions. These bnumbgers match those used by Glslang. |
|
|
||
| // Target environment versions. These bnumbgers match those used by Glslang. | ||
| enum class TargetEnvVersion : uint32_t { | ||
| // For Vulkan, use numbering schmee from vulkan.h |
| enum class TargetEnvVersion : uint32_t { | ||
| // For Vulkan, use numbering schmee from vulkan.h | ||
| Vulkan_1_0 = ((1 << 22)), // Default to Vuilkan 1.0 | ||
| Vulkan_1_1 = ((1 << 22) | (1 << 12)), // Default to Vuilkan 1.0 |
| // For Vulkan, use numbering schmee from vulkan.h | ||
| Vulkan_1_0 = ((1 << 22)), // Default to Vuilkan 1.0 | ||
| Vulkan_1_1 = ((1 << 22) | (1 << 12)), // Default to Vuilkan 1.0 | ||
| // For Op[enGL, use the numbering from #version in shaders. |
| enum class TargetEnv { | ||
| Vulkan, | ||
| OpenGL, | ||
| Vulkan, // Default to Vuilkan 1.0 |
There was a problem hiding this comment.
oh my. I must have been tired. Actually I was on a plane and comments were dark blue on black... :-(
|
Also, we should probably update the glslc manual about the changes. |
| the client version. Values are: | ||
| vulkan1.0 # The default | ||
| vulkan1.1 | ||
| vulkan # Same as vulkan1.0 |
There was a problem hiding this comment.
A question about the vulkan parameter suddenly comes to me.
What's our guarantee of this parameter? Are we gonna change what it aliases to when, say, Vulkan 1.2 or 1.N releases?
If not, that effectively makes it just a way of saying vulkan1.0, which would be handy for now but in the future developers will mostly want vulkan 1.N. So it will likely be less useful.
If we would like to change it when newer version of Vulkan come out, then how we decide which version to alias to since we are not alias to the newest version here?
Also note that when we have a python or other binary or library without version number in the system, they alias to the newest ones. If you want to the older ones, you need to specify python2.6 or something. I'm not sure whether that's particularly related here, but seems it's a convention?
There was a problem hiding this comment.
Okay, I think maybe make vulkan alias to the previous major release is a good balance between new functionality and driver stability?
There was a problem hiding this comment.
JohnK and I independently came to the same conclusion that at least for now defaulting to Vulkan 1.0 is a sane default. It also happens to retain backward compatibility.
It is a judgement call though.
- Update glslc manual - Update comments at the shaderc_compile_options_set_target_env entry point and its moral equivalents - Fix typos in comments - Remove duplicate test - Fix 'vulkan1.1' option in test
|
Thanks for the reviews. I've addressed all feedback, and also updated the comments at shaderc_compile_set_target_env and its friends. @antiagainst PTAL |
|
Appveyor & Travis is fine. I'll ignore Google bots for now. |
|
The Google bot failures are new and unrelated to this CL. I will work on fixing them. |
…951c 2a9b6f951c Add Capability and Execution mode SPV_KHR_compute_shader_derivatives (google#446) efb6b4099d add support for SPV_INTEL_subgroup_buffer_prefetch (google#442) 744753a21d Update spirv generator info (google#445) 69ab0f32dc Add UnormInt2_101010EXT ImageChannelDataType (google#444) 1b75a4ae0b Request a vendor id for Kongruent (google#443) git-subtree-dir: third_party/spirv-headers git-subtree-split: 2a9b6f951c7d6b04b6c21fe1bf3f475b68b84801
NOTE: We no longer can compile OpenGL compatibility profile shaders to SPIR-V.
These will error out.
C and C++ API: Set nontrivial target environment version
Glslc --target-env accepts optional version suffix, e.g. vulkan1.1