Skip to content

Support setting target environment version, e.g. Vulkan 1.1#445

Merged
antiagainst merged 2 commits intogoogle:masterfrom
dneto0:vulkan-1.1
Mar 22, 2018
Merged

Support setting target environment version, e.g. Vulkan 1.1#445
antiagainst merged 2 commits intogoogle:masterfrom
dneto0:vulkan-1.1

Conversation

@dneto0
Copy link
Copy Markdown
Collaborator

@dneto0 dneto0 commented Mar 18, 2018

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

@dneto0 dneto0 requested a review from antiagainst March 18, 2018 06:34
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
@dneto0
Copy link
Copy Markdown
Collaborator Author

dneto0 commented Mar 21, 2018

FYI: CI-ubuntu-clang-debug failure is a config failure: " clang is not a full path and was not found in the PATH."

@dneto0
Copy link
Copy Markdown
Collaborator Author

dneto0 commented Mar 21, 2018

PTAL @antiagainst .

@dgkoch has asked for this to land sooner rather than later.

Copy link
Copy Markdown
Contributor

@antiagainst antiagainst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review! Overall LGTM! Just a few nits.



@inside_glslc_testsuite('OptionTargetEnv')
class TestTargetEnvEqVulkan1_0WithVulkan1_1ShaderFails(expect.ErrorMessageSubstr):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a duplicate test with the one at Line 98?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Deleting the one at line 98.

@inside_glslc_testsuite('OptionTargetEnv')
class TestTargetEnvEqVulkan1_1WithVulkan1_0ShaderSucceeds(expect.ValidObjectFile):
shader = FileShader(vulkan_vertex_shader(), '.vert')
glslc_args = ['--target-env=vulkan1.0', '-c', shader]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be --target-env=vulkan1.1?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/coide/code/

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/andf/and/

OpenGLCompat,
};

// Target environment versions. These bnumbgers match those used by Glslang.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/bnumbgers/numbers/

// Sets the target environment.
void SetTargetEnv(TargetEnv env);
// Sets the target environment, including version.
// 0 means the default version for the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the target environment?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. whoops.

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/envirohnment/environment/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

OpenGLCompat,
};

// Target environment versions. These bnumbgers match those used by Glslang.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"bnumbgers" typo?


// Target environment versions. These bnumbgers match those used by Glslang.
enum class TargetEnvVersion : uint32_t {
// For Vulkan, use numbering schmee from vulkan.h
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"schmee"?

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vuilkan

// 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Op[enGL

enum class TargetEnv {
Vulkan,
OpenGL,
Vulkan, // Default to Vuilkan 1.0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vuilkan

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my. I must have been tired. Actually I was on a plane and comments were dark blue on black... :-(

@antiagainst
Copy link
Copy Markdown
Contributor

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think maybe make vulkan alias to the previous major release is a good balance between new functionality and driver stability?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair.

- 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
@dneto0
Copy link
Copy Markdown
Collaborator Author

dneto0 commented Mar 22, 2018

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

@antiagainst
Copy link
Copy Markdown
Contributor

Appveyor & Travis is fine. I'll ignore Google bots for now.

@ehsannas
Copy link
Copy Markdown
Contributor

The Google bot failures are new and unrelated to this CL. I will work on fixing them.

@antiagainst antiagainst merged commit c993158 into google:master Mar 22, 2018
stenzek added a commit to stenzek/shaderc that referenced this pull request Sep 27, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants