mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
[SPIR-V] Proper implementation of getGradients
This commit is contained in:
parent
5a4dcd7043
commit
24baf58ae3
|
|
@ -1846,26 +1846,21 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
||||||
dest = b.createTextureCall(spv::NoPrecision, vec4_float_type_, false,
|
dest = b.createTextureCall(spv::NoPrecision, vec4_float_type_, false,
|
||||||
false, false, false, false, params);
|
false, false, false, false, params);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FetchOpcode::kGetTextureGradients: {
|
case FetchOpcode::kGetTextureGradients: {
|
||||||
auto texture_index =
|
Id src_x = b.createCompositeExtract(src, float_type_, 0);
|
||||||
b.makeUintConstant(tex_binding_map_[instr.operands[2].storage_index]);
|
Id src_y = b.createCompositeExtract(src, float_type_, 1);
|
||||||
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]);
|
dest = b.createCompositeConstruct(
|
||||||
Id gradX = b.createCompositeExtract(grad, float_type_, 0);
|
vec4_float_type_,
|
||||||
Id gradY = b.createCompositeExtract(grad, float_type_, 1);
|
{
|
||||||
|
b.createUnaryOp(spv::OpDPdx, float_type_, src_x),
|
||||||
spv::Builder::TextureParameters params = {0};
|
b.createUnaryOp(spv::OpDPdy, float_type_, src_x),
|
||||||
params.coords = src;
|
b.createUnaryOp(spv::OpDPdx, float_type_, src_y),
|
||||||
params.sampler = texture;
|
b.createUnaryOp(spv::OpDPdy, float_type_, src_y),
|
||||||
params.gradX = gradX;
|
});
|
||||||
params.gradY = gradY;
|
|
||||||
dest = b.createTextureCall(spv::NoPrecision, vec4_float_type_, false,
|
|
||||||
false, false, false, false, params);
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FetchOpcode::kGetTextureWeights: {
|
case FetchOpcode::kGetTextureWeights: {
|
||||||
// fract(src0 * textureSize);
|
// fract(src0 * textureSize);
|
||||||
auto texture_index =
|
auto texture_index =
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue