-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Begin to refactor test_LoadImage to use SharedShaders #9092
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,9 +158,19 @@ layout(binding = 0, set = 0) uniform Params { | |
| } params; | ||
| )"; | ||
| } | ||
| case ShaderUniformType::Sampler: { | ||
| case ShaderUniformType::Sampler2D: { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that WebGPU/WGSL does not support combined image samplers. We need to define and bind both the texture and the sampler for it and use both in the call to sample the color from the texture. In pure WGSL it is:
We deal with this in our shader generation code using a SPIRV-OPT pass that splits combined image samplers (see (libs/filamat/src/GLSLPostProcessor.cpp ~line 574)[https://github.com/google/filament/blob/5daa0cfe4b9d74a489117d8df393d01540af1a0a/libs/filamat/src/GLSLPostProcessor.cpp#L574]: // In WebGPU, textures and samplers are separate bindings.
/ We map the Filament binding index to two WebGPU binding indices:
// - texture: binding * 2
// - sampler: binding * 2 + 1
wEntry.binding = fEntry.binding * 2;
entryInfo.binding = wEntry.binding;I could be wrong, as I am not familiar with this side of the code, but I don't see where this is accounted for in the test shader generation. I think we need to modify the shader GLSL for the WebGPU case to handle this. |
||
| return R"( | ||
| layout(location = 0, set = 0) uniform sampler2D test_tex; | ||
| )"; | ||
| } | ||
| case ShaderUniformType::ISampler2D: { | ||
| return R"( | ||
| layout(location = 0, set = 0) uniform isampler2D test_tex; | ||
| )"; | ||
| } | ||
| case ShaderUniformType::USampler2D: { | ||
| return R"( | ||
| layout(location = 0, set = 0) uniform usampler2D test_tex; | ||
| )"; | ||
| } | ||
| default: | ||
|
|
@@ -179,14 +189,30 @@ std::vector<UniformConfig> GetUniformConfig(ShaderUniformType type) { | |
| case ShaderUniformType::SimpleWithPadding: { | ||
| return {{ "Params" }}; | ||
| } | ||
| case ShaderUniformType::Sampler: { | ||
| case ShaderUniformType::Sampler2D: { | ||
| filament::SamplerInterfaceBlock::SamplerInfo samplerInfo{ | ||
| "backend_test", "test_tex", 0, | ||
| SamplerType::SAMPLER_2D, SamplerFormat::FLOAT, Precision::HIGH, false }; | ||
| return {{ | ||
| "test_tex", DescriptorType::SAMPLER_2D_FLOAT, samplerInfo | ||
| }}; | ||
| } | ||
| case ShaderUniformType::ISampler2D: { | ||
| filament::SamplerInterfaceBlock::SamplerInfo samplerInfo{ | ||
| "backend_test", "test_tex", 0, | ||
| SamplerType::SAMPLER_2D, SamplerFormat::INT, Precision::HIGH, false }; | ||
| return {{ | ||
| "test_tex", DescriptorType::SAMPLER_2D_INT, samplerInfo | ||
| }}; | ||
| } | ||
| case ShaderUniformType::USampler2D: { | ||
| filament::SamplerInterfaceBlock::SamplerInfo samplerInfo{ | ||
| "backend_test", "test_tex", 0, | ||
| SamplerType::SAMPLER_2D, SamplerFormat::UINT, Precision::HIGH, false }; | ||
| return {{ | ||
| "test_tex", DescriptorType::SAMPLER_2D_INT, samplerInfo | ||
| }}; | ||
| } | ||
| default: | ||
| abort(); | ||
| } | ||
|
|
@@ -252,4 +278,4 @@ std::string SharedShaders::getFragmentShaderText(FragmentShaderType fragment, | |
| return fragmentText->withUniform(*uniformText); | ||
| } | ||
|
|
||
| } // namespace test | ||
| } // namespace test | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is forcing an alpha value necessary?