mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
SPIR-V: Rudimentary support of tfetch offsets, fix scalar operand loads
This commit is contained in:
parent
99d2b2fb55
commit
9e646085f0
|
|
@ -840,6 +840,10 @@ void SpirvShaderTranslator::ProcessAllocInstruction(
|
||||||
} break;
|
} break;
|
||||||
// Also PS Colors
|
// Also PS Colors
|
||||||
case AllocType::kVsInterpolators: {
|
case AllocType::kVsInterpolators: {
|
||||||
|
// Already included, nothing to do here.
|
||||||
|
} break;
|
||||||
|
case AllocType::kMemory: {
|
||||||
|
assert_always();
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -1026,6 +1030,20 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
||||||
tex_[dim_idx], std::vector<Id>({texture_index}));
|
tex_[dim_idx], std::vector<Id>({texture_index}));
|
||||||
auto texture = b.createLoad(texture_ptr);
|
auto texture = b.createLoad(texture_ptr);
|
||||||
|
|
||||||
|
if (instr.dimension == TextureDimension::k1D &&
|
||||||
|
(instr.attributes.offset_x)) {
|
||||||
|
auto offset = b.makeFloatConstant(instr.attributes.offset_x + 0.5f);
|
||||||
|
src = b.createBinOp(spv::Op::OpFAdd, float_type_, src, offset);
|
||||||
|
} else if (instr.dimension == TextureDimension::k2D &&
|
||||||
|
(instr.attributes.offset_x || instr.attributes.offset_y)) {
|
||||||
|
auto offset = b.makeCompositeConstant(
|
||||||
|
vec2_float_type_,
|
||||||
|
std::vector<Id>(
|
||||||
|
{b.makeFloatConstant(instr.attributes.offset_x + 0.5f),
|
||||||
|
b.makeFloatConstant(instr.attributes.offset_y + 0.5f)}));
|
||||||
|
src = b.createBinOp(spv::Op::OpFAdd, vec2_float_type_, src, offset);
|
||||||
|
}
|
||||||
|
|
||||||
spv::Builder::TextureParameters params = {0};
|
spv::Builder::TextureParameters params = {0};
|
||||||
params.coords = src;
|
params.coords = src;
|
||||||
params.sampler = texture;
|
params.sampler = texture;
|
||||||
|
|
@ -1723,32 +1741,8 @@ void SpirvShaderTranslator::ProcessScalarAluInstruction(
|
||||||
auto src = LoadFromOperand(instr.operands[i]);
|
auto src = LoadFromOperand(instr.operands[i]);
|
||||||
|
|
||||||
// Pull components out of the vector operands and use them as sources.
|
// Pull components out of the vector operands and use them as sources.
|
||||||
for (size_t j = 0; j < instr.operands[i].component_count; j++) {
|
for (int j = 0; j < instr.operands[i].component_count; j++) {
|
||||||
uint32_t component = 0;
|
sources[x++] = b.createCompositeExtract(src, float_type_, j);
|
||||||
switch (instr.operands[i].components[j]) {
|
|
||||||
case SwizzleSource::kX:
|
|
||||||
component = 0;
|
|
||||||
break;
|
|
||||||
case SwizzleSource::kY:
|
|
||||||
component = 1;
|
|
||||||
break;
|
|
||||||
case SwizzleSource::kZ:
|
|
||||||
component = 2;
|
|
||||||
break;
|
|
||||||
case SwizzleSource::kW:
|
|
||||||
component = 3;
|
|
||||||
break;
|
|
||||||
case SwizzleSource::k0:
|
|
||||||
case SwizzleSource::k1:
|
|
||||||
// Don't believe this can happen.
|
|
||||||
assert_always();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert_always();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
sources[x++] = b.createCompositeExtract(src, float_type_, component);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2424,7 +2418,7 @@ void SpirvShaderTranslator::StoreToResult(Id source_value_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!storage_pointer) {
|
if (!storage_pointer) {
|
||||||
// assert_always();
|
assert_always();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue