summaryrefslogtreecommitdiff
path: root/src/video_core/shader
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-02-22 03:30:12 -0300
committerGravatar ReinUsesLisp2019-02-26 00:11:30 -0300
commit5ca63d06757a92fdbd7d75d81f0c9ff1d7ab4e62 (patch)
treef8b542a250f4ed649fa6e27ee5fa8d8dbef2c2d1 /src/video_core/shader
parentshader/decode: Split memory and texture instructions decoding (diff)
downloadyuzu-5ca63d06757a92fdbd7d75d81f0c9ff1d7ab4e62.tar.gz
yuzu-5ca63d06757a92fdbd7d75d81f0c9ff1d7ab4e62.tar.xz
yuzu-5ca63d06757a92fdbd7d75d81f0c9ff1d7ab4e62.zip
shader/decode: Remove extras from MetaTexture
Diffstat (limited to 'src/video_core/shader')
-rw-r--r--src/video_core/shader/decode/texture.cpp37
-rw-r--r--src/video_core/shader/shader_ir.h4
2 files changed, 26 insertions, 15 deletions
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp
index 50e2d0584..a99ae19bf 100644
--- a/src/video_core/shader/decode/texture.cpp
+++ b/src/video_core/shader/decode/texture.cpp
@@ -119,8 +119,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
119 coords.push_back(op_a); 119 coords.push_back(op_a);
120 coords.push_back(op_b); 120 coords.push_back(op_b);
121 } 121 }
122 std::vector<Node> extras; 122 const Node component = Immediate(static_cast<u32>(instr.tld4s.component));
123 extras.push_back(Immediate(static_cast<u32>(instr.tld4s.component)));
124 123
125 const auto& sampler = 124 const auto& sampler =
126 GetSampler(instr.sampler, TextureType::Texture2D, false, depth_compare); 125 GetSampler(instr.sampler, TextureType::Texture2D, false, depth_compare);
@@ -128,7 +127,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
128 Node4 values; 127 Node4 values;
129 for (u32 element = 0; element < values.size(); ++element) { 128 for (u32 element = 0; element < values.size(); ++element) {
130 auto coords_copy = coords; 129 auto coords_copy = coords;
131 MetaTexture meta{sampler, {}, {}, extras, element}; 130 MetaTexture meta{sampler, {}, {}, {}, {}, component, element};
132 values[element] = Operation(OperationCode::TextureGather, meta, std::move(coords_copy)); 131 values[element] = Operation(OperationCode::TextureGather, meta, std::move(coords_copy));
133 } 132 }
134 133
@@ -153,7 +152,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
153 if (!instr.txq.IsComponentEnabled(element)) { 152 if (!instr.txq.IsComponentEnabled(element)) {
154 continue; 153 continue;
155 } 154 }
156 MetaTexture meta{sampler, {}, {}, {}, element}; 155 MetaTexture meta{sampler, {}, {}, {}, {}, {}, element};
157 const Node value = 156 const Node value =
158 Operation(OperationCode::TextureQueryDimensions, meta, GetRegister(instr.gpr8)); 157 Operation(OperationCode::TextureQueryDimensions, meta, GetRegister(instr.gpr8));
159 SetTemporal(bb, indexer++, value); 158 SetTemporal(bb, indexer++, value);
@@ -203,7 +202,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
203 202
204 for (u32 element = 0; element < 2; ++element) { 203 for (u32 element = 0; element < 2; ++element) {
205 auto params = coords; 204 auto params = coords;
206 MetaTexture meta{sampler, {}, {}, {}, element}; 205 MetaTexture meta{sampler, {}, {}, {}, {}, {}, element};
207 const Node value = Operation(OperationCode::TextureQueryLod, meta, std::move(params)); 206 const Node value = Operation(OperationCode::TextureQueryLod, meta, std::move(params));
208 SetTemporal(bb, element, value); 207 SetTemporal(bb, element, value);
209 } 208 }
@@ -347,25 +346,35 @@ Node4 ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type,
347 (texture_type == Tegra::Shader::TextureType::TextureCube && is_array && is_shadow)); 346 (texture_type == Tegra::Shader::TextureType::TextureCube && is_array && is_shadow));
348 347
349 const OperationCode read_method = 348 const OperationCode read_method =
350 lod_needed && gl_lod_supported ? OperationCode::TextureLod : OperationCode::Texture; 349 (lod_needed && gl_lod_supported) ? OperationCode::TextureLod : OperationCode::Texture;
351 350
352 UNIMPLEMENTED_IF(process_mode != TextureProcessMode::None && !gl_lod_supported); 351 UNIMPLEMENTED_IF(process_mode != TextureProcessMode::None && !gl_lod_supported);
353 352
354 std::vector<Node> extras; 353 Node bias = {};
354 Node lod = {};
355 if (process_mode != TextureProcessMode::None && gl_lod_supported) { 355 if (process_mode != TextureProcessMode::None && gl_lod_supported) {
356 if (process_mode == TextureProcessMode::LZ) { 356 switch (process_mode) {
357 extras.push_back(Immediate(0.0f)); 357 case TextureProcessMode::LZ:
358 } else { 358 lod = Immediate(0.0f);
359 break;
360 case TextureProcessMode::LB:
359 // If present, lod or bias are always stored in the register indexed by the gpr20 361 // If present, lod or bias are always stored in the register indexed by the gpr20
360 // field with an offset depending on the usage of the other registers 362 // field with an offset depending on the usage of the other registers
361 extras.push_back(GetRegister(instr.gpr20.Value() + bias_offset)); 363 bias = GetRegister(instr.gpr20.Value() + bias_offset);
364 break;
365 case TextureProcessMode::LL:
366 lod = GetRegister(instr.gpr20.Value() + bias_offset);
367 break;
368 default:
369 UNIMPLEMENTED_MSG("Unimplemented process mode={}", static_cast<u32>(process_mode));
370 break;
362 } 371 }
363 } 372 }
364 373
365 Node4 values; 374 Node4 values;
366 for (u32 element = 0; element < values.size(); ++element) { 375 for (u32 element = 0; element < values.size(); ++element) {
367 auto copy_coords = coords; 376 auto copy_coords = coords;
368 MetaTexture meta{sampler, array, depth_compare, extras, element}; 377 MetaTexture meta{sampler, array, depth_compare, bias, lod, {}, element};
369 values[element] = Operation(read_method, meta, std::move(copy_coords)); 378 values[element] = Operation(read_method, meta, std::move(copy_coords));
370 } 379 }
371 380
@@ -462,7 +471,7 @@ Node4 ShaderIR::GetTld4Code(Instruction instr, TextureType texture_type, bool de
462 Node4 values; 471 Node4 values;
463 for (u32 element = 0; element < values.size(); ++element) { 472 for (u32 element = 0; element < values.size(); ++element) {
464 auto coords_copy = coords; 473 auto coords_copy = coords;
465 MetaTexture meta{sampler, GetRegister(array_register), {}, {}, element}; 474 MetaTexture meta{sampler, GetRegister(array_register), {}, {}, {}, {}, element};
466 values[element] = Operation(OperationCode::TextureGather, meta, std::move(coords_copy)); 475 values[element] = Operation(OperationCode::TextureGather, meta, std::move(coords_copy));
467 } 476 }
468 477
@@ -498,7 +507,7 @@ Node4 ShaderIR::GetTldsCode(Instruction instr, TextureType texture_type, bool is
498 Node4 values; 507 Node4 values;
499 for (u32 element = 0; element < values.size(); ++element) { 508 for (u32 element = 0; element < values.size(); ++element) {
500 auto coords_copy = coords; 509 auto coords_copy = coords;
501 MetaTexture meta{sampler, array, {}, {lod}, element}; 510 MetaTexture meta{sampler, array, {}, {}, lod, {}, element};
502 values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy)); 511 values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy));
503 } 512 }
504 return values; 513 return values;
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h
index 0548c46f0..5bc3a3900 100644
--- a/src/video_core/shader/shader_ir.h
+++ b/src/video_core/shader/shader_ir.h
@@ -290,7 +290,9 @@ struct MetaTexture {
290 const Sampler& sampler; 290 const Sampler& sampler;
291 Node array{}; 291 Node array{};
292 Node depth_compare{}; 292 Node depth_compare{};
293 std::vector<Node> extras; 293 Node bias{};
294 Node lod{};
295 Node component{};
294 u32 element{}; 296 u32 element{};
295}; 297};
296 298