diff --git a/src/xenia/gpu/spirv_shader_translator.cc b/src/xenia/gpu/spirv_shader_translator.cc index fda637ee3..376d04f17 100644 --- a/src/xenia/gpu/spirv_shader_translator.cc +++ b/src/xenia/gpu/spirv_shader_translator.cc @@ -111,6 +111,8 @@ void SpirvShaderTranslator::StartTranslation() { "pc"); a0_ = b.createVariable(spv::StorageClass::StorageClassFunction, int_type_, "a0"); + lod_ = b.createVariable(spv::StorageClass::StorageClassFunction, float_type_, + "lod"); // Uniform constants. Id float_consts_type = @@ -1843,6 +1845,10 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction( spv::Builder::TextureParameters params = {0}; params.coords = src; params.sampler = texture; + if (instr.attributes.use_register_lod) { + params.lod = b.createLoad(lod_); + } + dest = b.createTextureCall(spv::NoPrecision, vec4_float_type_, false, false, false, false, is_vertex_shader(), params); @@ -1906,6 +1912,7 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction( // = src1.x (MIP level) // ... immediately after // tfetch UseRegisterLOD=true + b.createStore(b.createCompositeExtract(src, float_type_, 0), lod_); } break; default: diff --git a/src/xenia/gpu/spirv_shader_translator.h b/src/xenia/gpu/spirv_shader_translator.h index c1e97d127..ec822e8e2 100644 --- a/src/xenia/gpu/spirv_shader_translator.h +++ b/src/xenia/gpu/spirv_shader_translator.h @@ -149,6 +149,7 @@ class SpirvShaderTranslator : public ShaderTranslator { spv::Id loop_count_ = 0; // Loop counter stack spv::Id ps_ = 0, pv_ = 0; // IDs of previous results spv::Id pc_ = 0; // Program counter + spv::Id lod_ = 0; // LOD register spv::Id pos_ = 0; spv::Id push_consts_ = 0; spv::Id interpolators_ = 0;