summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrChat <arkolbed@gmail.com>2017-12-22 23:15:18 -0600
committerDrChat <arkolbed@gmail.com>2017-12-22 23:15:18 -0600
commit516c113423a4c2e61839858347e0137f81cd365f (patch)
tree50cbb2075d03727b1604973261009e65264b42af
parent20099e51afc19390f8b21555dd662cef411a1aaa (diff)
[SPIR-V] Fix tfetches with an offset
-rw-r--r--src/xenia/gpu/spirv_shader_translator.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/xenia/gpu/spirv_shader_translator.cc b/src/xenia/gpu/spirv_shader_translator.cc
index aaf311623..7ec5b9535 100644
--- a/src/xenia/gpu/spirv_shader_translator.cc
+++ b/src/xenia/gpu/spirv_shader_translator.cc
@@ -1465,19 +1465,29 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
params.sampler = image;
params.lod = b.makeIntConstant(0);
size = b.createTextureQueryCall(spv::Op::OpImageQuerySizeLod, params);
+
+ if (instr.dimension == TextureDimension::k1D) {
+ size = b.createUnaryOp(spv::Op::OpConvertSToF, float_type_, size);
+ } else if (instr.dimension == TextureDimension::k2D) {
+ size =
+ b.createUnaryOp(spv::Op::OpConvertSToF, vec2_float_type_, size);
+ } else if (instr.dimension == TextureDimension::k3D) {
+ size =
+ b.createUnaryOp(spv::Op::OpConvertSToF, vec3_float_type_, size);
+ } else if (instr.dimension == TextureDimension::kCube) {
+ size =
+ b.createUnaryOp(spv::Op::OpConvertSToF, vec4_float_type_, size);
+ }
}
if (instr.dimension == TextureDimension::k1D) {
+ src = b.createCompositeExtract(src, float_type_, 0);
if (instr.attributes.offset_x) {
- auto offset = b.makeCompositeConstant(
- vec2_float_type_,
- std::vector<Id>(
- {b.makeFloatConstant(instr.attributes.offset_x + 0.5f),
- b.makeFloatConstant(0.f)}));
- offset =
- b.createBinOp(spv::Op::OpFDiv, vec2_float_type_, offset, size);
- src = b.createBinOp(spv::Op::OpFAdd, vec2_float_type_, src, offset);
+ auto offset = b.makeFloatConstant(instr.attributes.offset_x + 0.5f);
+ offset = b.createBinOp(spv::Op::OpFDiv, float_type_, offset, size);
+ src = b.createBinOp(spv::Op::OpFAdd, float_type_, src, offset);
}
+
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb944006.aspx
// "Because the runtime does not support 1D textures, the compiler will
// use a 2D texture with the knowledge that the y-coordinate is
@@ -1486,6 +1496,8 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
vec2_float_type_,
std::vector<Id>({src, b.makeFloatConstant(0.0f)}));
} else if (instr.dimension == TextureDimension::k2D) {
+ src = b.createRvalueSwizzle(spv::NoPrecision, vec2_float_type_, src,
+ std::vector<uint32_t>({0, 1}));
if (instr.attributes.offset_x || instr.attributes.offset_y) {
auto offset = b.makeCompositeConstant(
vec2_float_type_,