diff options
| author | DrChat <arkolbed@gmail.com> | 2017-10-01 18:59:54 -0500 |
|---|---|---|
| committer | DrChat <arkolbed@gmail.com> | 2017-10-01 18:59:54 -0500 |
| commit | a7b6d91a2b2286e70592d6bcae9950dc65379070 (patch) | |
| tree | 7f087925a4d7c9bf00050dfc373e14dd420ce76d | |
| parent | 2a3c66484e818364e321bab4f3bf00e5851c6f19 (diff) | |
[SPIR-V] (untested) Implementation of getGradients
| -rw-r--r-- | src/xenia/gpu/spirv_shader_translator.cc | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/xenia/gpu/spirv_shader_translator.cc b/src/xenia/gpu/spirv_shader_translator.cc index 789f622c3..bfccc052c 100644 --- a/src/xenia/gpu/spirv_shader_translator.cc +++ b/src/xenia/gpu/spirv_shader_translator.cc @@ -996,7 +996,7 @@ void SpirvShaderTranslator::ProcessAllocInstruction( // Already included, nothing to do here. } break; case AllocType::kMemory: { - assert_always(); + // Nothing to do for this. } break; default: break; @@ -1357,6 +1357,25 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction( dest = b.createTextureCall(spv::NoPrecision, vec4_float_type_, false, false, false, false, false, params); } break; + case FetchOpcode::kGetTextureGradients: { + auto texture_index = b.makeUintConstant(instr.operands[2].storage_index); + auto texture_ptr = + b.createAccessChain(spv::StorageClass::StorageClassUniformConstant, + tex_[dim_idx], std::vector<Id>({texture_index})); + auto texture = b.createLoad(texture_ptr); + + Id grad = LoadFromOperand(instr.operands[1]); + Id gradX = b.createCompositeExtract(grad, float_type_, 0); + Id gradY = b.createCompositeExtract(grad, float_type_, 1); + + spv::Builder::TextureParameters params = {0}; + params.coords = src; + params.sampler = texture; + params.gradX = gradX; + params.gradY = gradY; + dest = b.createTextureCall(spv::NoPrecision, vec4_float_type_, false, + false, false, false, false, params); + } break; case FetchOpcode::kGetTextureWeights: { // fract(src0 * textureSize); auto texture_index = b.makeUintConstant(instr.operands[1].storage_index); @@ -1397,7 +1416,7 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction( } break; case FetchOpcode::kSetTextureLod: { - // <lod register> = src1.x + // <lod register> = src1.x (MIP level) // ... immediately after // tfetch UseRegisterLOD=true } break; |
