Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an API to set descriptor set and binding of default uniform block #1437

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libshaderc/include/shaderc/shaderc.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ SHADERC_EXPORT void shaderc_compile_options_set_invert_y(
SHADERC_EXPORT void shaderc_compile_options_set_nan_clamp(
shaderc_compile_options_t options, bool enable);

// Sets the descriptor set and binding for the default uniform block in the
// relaxed Vulkan rules mode.
SHADERC_EXPORT void shaderc_compile_options_set_default_uniform_block_set_and_binding(
shaderc_compile_options_t options, uint32_t set, uint32_t binding);

// An opaque handle to the results of a call to any shaderc_compile_into_*()
// function.
typedef struct shaderc_compilation_result* shaderc_compilation_result_t;
Expand Down
5 changes: 5 additions & 0 deletions libshaderc/src/shaderc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ void shaderc_compile_options_set_nan_clamp(shaderc_compile_options_t options,
options->compiler.SetNanClamp(enable);
}

void shaderc_compile_options_set_default_uniform_block_set_and_binding(
shaderc_compile_options_t options, uint32_t set, uint32_t binding) {
options->compiler.SetDefaultUniformBlockSetAndBinding(set, binding);
}

shaderc_compiler_t shaderc_compiler_initialize() {
shaderc_compiler_t compiler = new (std::nothrow) shaderc_compiler;
if (compiler) {
Expand Down
15 changes: 15 additions & 0 deletions libshaderc_util/include/libshaderc_util/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ class Compiler {
hlsl_16bit_types_enabled_(false),
invert_y_enabled_(false),
nan_clamp_(false),
default_uniform_block_set_(0),
default_uniform_block_binding_(0),
hlsl_explicit_bindings_() {}

// Requests that the compiler place debug information into the object code,
Expand Down Expand Up @@ -339,6 +341,13 @@ class Compiler {
}
}

// Sets the descriptor set and binding for the default uniform block in
// the relaxed Vulkan rules mode.
void SetDefaultUniformBlockSetAndBinding(uint32_t set, uint32_t binding) {
default_uniform_block_set_ = set;
default_uniform_block_binding_ = binding;
}

// Sets an explicit set and binding for the given HLSL register in the given
// shader stage. For example,
// SetHlslRegisterSetAndBinding(Stage::Fragment, "t1", "4", "5")
Expand Down Expand Up @@ -563,6 +572,12 @@ class Compiler {
// as a composition of max and min.
bool nan_clamp_;

// Descriptor set for the default uniform block in relaxed Vulkan rules mode.
uint32_t default_uniform_block_set_;

// Binding for the default uniform block in relaxed Vulkan rules mode.
uint32_t default_uniform_block_binding_;

// A sequence of triples, each triple representing a specific HLSL register
// name, and the set and binding numbers it should be mapped to, but in
// the form of strings. This is how Glslang wants to consume the data.
Expand Down
2 changes: 2 additions & 0 deletions libshaderc_util/src/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ std::tuple<bool, std::vector<uint32_t>, size_t> Compiler::Compile(
}
shader.setInvertY(invert_y_enabled_);
shader.setNanMinMaxClamp(nan_clamp_);
shader.setGlobalUniformSet(default_uniform_block_set_);
shader.setGlobalUniformBinding(default_uniform_block_binding_);

const EShMessages rules =
GetMessageRules(target_env_, source_language_, hlsl_offsets_,
Expand Down