summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_context.cpp
diff options
context:
space:
mode:
authorGravatar ameerj2021-05-29 01:53:32 -0400
committerGravatar ameerj2021-07-22 21:51:36 -0400
commit7619b7d427437cb58df0f9fc57a7d6b3f5c45f9c (patch)
treecaf39be4349d41c6992691d2d4660501827ed6b0 /src/shader_recompiler/backend/glsl/emit_context.cpp
parentglsl: Implement TEX ImageSample functions (diff)
downloadyuzu-7619b7d427437cb58df0f9fc57a7d6b3f5c45f9c.tar.gz
yuzu-7619b7d427437cb58df0f9fc57a7d6b3f5c45f9c.tar.xz
yuzu-7619b7d427437cb58df0f9fc57a7d6b3f5c45f9c.zip
glsl: Implement TEX depth functions
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_context.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp
index eb1d8266f..94ba9af7c 100644
--- a/src/shader_recompiler/backend/glsl/emit_context.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_context.cpp
@@ -21,7 +21,26 @@ std::string_view InterpDecorator(Interpolation interp) {
21 throw InvalidArgument("Invalid interpolation {}", interp); 21 throw InvalidArgument("Invalid interpolation {}", interp);
22} 22}
23 23
24std::string_view SamplerType(TextureType type) { 24std::string_view SamplerType(TextureType type, bool is_depth) {
25 if (is_depth) {
26 switch (type) {
27 case TextureType::Color1D:
28 return "sampler1DShadow";
29 case TextureType::ColorArray1D:
30 return "sampler1DArrayShadow";
31 case TextureType::Color2D:
32 return "sampler2DShadow";
33 case TextureType::ColorArray2D:
34 return "sampler2DArrayShadow";
35 case TextureType::ColorCube:
36 return "samplerCubeShadow";
37 case TextureType::ColorArrayCube:
38 return "samplerCubeArrayShadow";
39 default:
40 fmt::print("Texture type: {}", type);
41 throw NotImplementedException("Texture type: {}", type);
42 }
43 }
25 switch (type) { 44 switch (type) {
26 case TextureType::Color1D: 45 case TextureType::Color1D:
27 return "sampler1D"; 46 return "sampler1D";
@@ -110,6 +129,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
110void EmitContext::SetupExtensions(std::string&) { 129void EmitContext::SetupExtensions(std::string&) {
111 header += "#extension GL_ARB_separate_shader_objects : enable\n"; 130 header += "#extension GL_ARB_separate_shader_objects : enable\n";
112 header += "#extension GL_ARB_sparse_texture2 : enable\n"; 131 header += "#extension GL_ARB_sparse_texture2 : enable\n";
132 header += "#extension GL_EXT_texture_shadow_lod : enable\n";
113 // header += "#extension GL_ARB_texture_cube_map_array : enable\n"; 133 // header += "#extension GL_ARB_texture_cube_map_array : enable\n";
114 if (info.uses_int64) { 134 if (info.uses_int64) {
115 header += "#extension GL_ARB_gpu_shader_int64 : enable\n"; 135 header += "#extension GL_ARB_gpu_shader_int64 : enable\n";
@@ -227,7 +247,7 @@ void EmitContext::SetupImages(Bindings& bindings) {
227 } 247 }
228 texture_bindings.reserve(info.texture_descriptors.size()); 248 texture_bindings.reserve(info.texture_descriptors.size());
229 for (const auto& desc : info.texture_descriptors) { 249 for (const auto& desc : info.texture_descriptors) {
230 const auto sampler_type{SamplerType(desc.type)}; 250 const auto sampler_type{SamplerType(desc.type, desc.is_depth)};
231 texture_bindings.push_back(bindings.texture); 251 texture_bindings.push_back(bindings.texture);
232 const auto indices{bindings.texture + desc.count}; 252 const auto indices{bindings.texture + desc.count};
233 for (u32 index = bindings.texture; index < indices; ++index) { 253 for (u32 index = bindings.texture; index < indices; ++index) {