[SPIR-V] tfetch UseRegisterLOD support

This commit is contained in:
DrChat 2018-03-01 13:46:44 -06:00
parent ea3ee2db2b
commit d31db60a75
2 changed files with 8 additions and 0 deletions

View File

@ -111,6 +111,8 @@ void SpirvShaderTranslator::StartTranslation() {
"pc"); "pc");
a0_ = b.createVariable(spv::StorageClass::StorageClassFunction, int_type_, a0_ = b.createVariable(spv::StorageClass::StorageClassFunction, int_type_,
"a0"); "a0");
lod_ = b.createVariable(spv::StorageClass::StorageClassFunction, float_type_,
"lod");
// Uniform constants. // Uniform constants.
Id float_consts_type = Id float_consts_type =
@ -1843,6 +1845,10 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
spv::Builder::TextureParameters params = {0}; spv::Builder::TextureParameters params = {0};
params.coords = src; params.coords = src;
params.sampler = texture; params.sampler = texture;
if (instr.attributes.use_register_lod) {
params.lod = b.createLoad(lod_);
}
dest = dest =
b.createTextureCall(spv::NoPrecision, vec4_float_type_, false, false, b.createTextureCall(spv::NoPrecision, vec4_float_type_, false, false,
false, false, is_vertex_shader(), params); false, false, is_vertex_shader(), params);
@ -1906,6 +1912,7 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
// <lod register> = src1.x (MIP level) // <lod register> = src1.x (MIP level)
// ... immediately after // ... immediately after
// tfetch UseRegisterLOD=true // tfetch UseRegisterLOD=true
b.createStore(b.createCompositeExtract(src, float_type_, 0), lod_);
} break; } break;
default: default:

View File

@ -149,6 +149,7 @@ class SpirvShaderTranslator : public ShaderTranslator {
spv::Id loop_count_ = 0; // Loop counter stack spv::Id loop_count_ = 0; // Loop counter stack
spv::Id ps_ = 0, pv_ = 0; // IDs of previous results spv::Id ps_ = 0, pv_ = 0; // IDs of previous results
spv::Id pc_ = 0; // Program counter spv::Id pc_ = 0; // Program counter
spv::Id lod_ = 0; // LOD register
spv::Id pos_ = 0; spv::Id pos_ = 0;
spv::Id push_consts_ = 0; spv::Id push_consts_ = 0;
spv::Id interpolators_ = 0; spv::Id interpolators_ = 0;