diff --git a/src/xenia/gpu/spirv_shader_translator_fetch.cc b/src/xenia/gpu/spirv_shader_translator_fetch.cc index 4d83b022a..764bde94d 100644 --- a/src/xenia/gpu/spirv_shader_translator_fetch.cc +++ b/src/xenia/gpu/spirv_shader_translator_fetch.cc @@ -1477,9 +1477,23 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction( spv::Id is_any_unsigned = builder_->createUnaryOp( spv::OpLogicalNot, type_bool_, is_all_signed); + // Load the fetch constant word 3, needed for result exponent biasing. + // exp_adjust is in word 3, bits 13:18 (6-bit signed). + id_vector_temp_.clear(); + id_vector_temp_.push_back(const_int_0_); + id_vector_temp_.push_back(builder_->makeIntConstant( + int((fetch_constant_word_0_index + 3) >> 2))); + id_vector_temp_.push_back(builder_->makeIntConstant( + int((fetch_constant_word_0_index + 3) & 3))); + spv::Id fetch_constant_word_3_signed = builder_->createUnaryOp( + spv::OpBitcast, type_int_, + builder_->createLoad(builder_->createAccessChain( + spv::StorageClassUniform, + uniform_fetch_constants_, id_vector_temp_), + spv::NoPrecision)); + // Load the fetch constant word 4, needed unconditionally for LOD - // biasing, for result exponent biasing, and conditionally for stacked - // texture filtering. + // biasing, and conditionally for stacked texture filtering. id_vector_temp_.clear(); id_vector_temp_.push_back(const_int_0_); id_vector_temp_.push_back(builder_->makeIntConstant( @@ -2198,12 +2212,12 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction( } // Apply the exponent bias from the bits 13:18 of the fetch constant - // word 4. + // word 3. spv::Id result_exponent_bias = builder_->createBinBuiltinCall( type_float_, ext_inst_glsl_std_450_, GLSLstd450Ldexp, const_float_1_, builder_->createTriOp(spv::OpBitFieldSExtract, type_int_, - fetch_constant_word_4_signed, + fetch_constant_word_3_signed, builder_->makeUintConstant(13), builder_->makeUintConstant(6))); {