diff options
Diffstat (limited to 'src/shader_recompiler')
| -rw-r--r-- | src/shader_recompiler/ir_opt/texture_pass.cpp | 34 | ||||
| -rw-r--r-- | src/shader_recompiler/shader_info.h | 4 |
2 files changed, 35 insertions, 3 deletions
diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp index 597112ba4..4bad811c2 100644 --- a/src/shader_recompiler/ir_opt/texture_pass.cpp +++ b/src/shader_recompiler/ir_opt/texture_pass.cpp | |||
| @@ -19,8 +19,10 @@ namespace { | |||
| 19 | struct ConstBufferAddr { | 19 | struct ConstBufferAddr { |
| 20 | u32 index; | 20 | u32 index; |
| 21 | u32 offset; | 21 | u32 offset; |
| 22 | u32 shift_left; | ||
| 22 | u32 secondary_index; | 23 | u32 secondary_index; |
| 23 | u32 secondary_offset; | 24 | u32 secondary_offset; |
| 25 | u32 secondary_shift_left; | ||
| 24 | IR::U32 dynamic_offset; | 26 | IR::U32 dynamic_offset; |
| 25 | u32 count; | 27 | u32 count; |
| 26 | bool has_secondary; | 28 | bool has_secondary; |
| @@ -182,6 +184,7 @@ std::optional<ConstBufferAddr> TryGetConstBuffer(const IR::Inst* inst) { | |||
| 182 | switch (inst->GetOpcode()) { | 184 | switch (inst->GetOpcode()) { |
| 183 | default: | 185 | default: |
| 184 | return std::nullopt; | 186 | return std::nullopt; |
| 187 | case IR::Opcode::BitwiseXor32: | ||
| 185 | case IR::Opcode::BitwiseOr32: { | 188 | case IR::Opcode::BitwiseOr32: { |
| 186 | std::optional lhs{Track(inst->Arg(0))}; | 189 | std::optional lhs{Track(inst->Arg(0))}; |
| 187 | std::optional rhs{Track(inst->Arg(1))}; | 190 | std::optional rhs{Track(inst->Arg(1))}; |
| @@ -194,19 +197,33 @@ std::optional<ConstBufferAddr> TryGetConstBuffer(const IR::Inst* inst) { | |||
| 194 | if (lhs->count > 1 || rhs->count > 1) { | 197 | if (lhs->count > 1 || rhs->count > 1) { |
| 195 | return std::nullopt; | 198 | return std::nullopt; |
| 196 | } | 199 | } |
| 197 | if (lhs->index > rhs->index || lhs->offset > rhs->offset) { | 200 | if (lhs->shift_left > 0 || lhs->index > rhs->index || lhs->offset > rhs->offset) { |
| 198 | std::swap(lhs, rhs); | 201 | std::swap(lhs, rhs); |
| 199 | } | 202 | } |
| 200 | return ConstBufferAddr{ | 203 | return ConstBufferAddr{ |
| 201 | .index = lhs->index, | 204 | .index = lhs->index, |
| 202 | .offset = lhs->offset, | 205 | .offset = lhs->offset, |
| 206 | .shift_left = lhs->shift_left, | ||
| 203 | .secondary_index = rhs->index, | 207 | .secondary_index = rhs->index, |
| 204 | .secondary_offset = rhs->offset, | 208 | .secondary_offset = rhs->offset, |
| 209 | .secondary_shift_left = rhs->shift_left, | ||
| 205 | .dynamic_offset = {}, | 210 | .dynamic_offset = {}, |
| 206 | .count = 1, | 211 | .count = 1, |
| 207 | .has_secondary = true, | 212 | .has_secondary = true, |
| 208 | }; | 213 | }; |
| 209 | } | 214 | } |
| 215 | case IR::Opcode::ShiftLeftLogical32: { | ||
| 216 | const IR::Value shift{inst->Arg(1)}; | ||
| 217 | if (!shift.IsImmediate()) { | ||
| 218 | return std::nullopt; | ||
| 219 | } | ||
| 220 | std::optional lhs{Track(inst->Arg(0))}; | ||
| 221 | if (lhs) { | ||
| 222 | lhs->shift_left = shift.U32(); | ||
| 223 | } | ||
| 224 | return lhs; | ||
| 225 | break; | ||
| 226 | } | ||
| 210 | case IR::Opcode::GetCbufU32x2: | 227 | case IR::Opcode::GetCbufU32x2: |
| 211 | case IR::Opcode::GetCbufU32: | 228 | case IR::Opcode::GetCbufU32: |
| 212 | break; | 229 | break; |
| @@ -222,8 +239,10 @@ std::optional<ConstBufferAddr> TryGetConstBuffer(const IR::Inst* inst) { | |||
| 222 | return ConstBufferAddr{ | 239 | return ConstBufferAddr{ |
| 223 | .index = index.U32(), | 240 | .index = index.U32(), |
| 224 | .offset = offset.U32(), | 241 | .offset = offset.U32(), |
| 242 | .shift_left = 0, | ||
| 225 | .secondary_index = 0, | 243 | .secondary_index = 0, |
| 226 | .secondary_offset = 0, | 244 | .secondary_offset = 0, |
| 245 | .secondary_shift_left = 0, | ||
| 227 | .dynamic_offset = {}, | 246 | .dynamic_offset = {}, |
| 228 | .count = 1, | 247 | .count = 1, |
| 229 | .has_secondary = false, | 248 | .has_secondary = false, |
| @@ -247,8 +266,10 @@ std::optional<ConstBufferAddr> TryGetConstBuffer(const IR::Inst* inst) { | |||
| 247 | return ConstBufferAddr{ | 266 | return ConstBufferAddr{ |
| 248 | .index = index.U32(), | 267 | .index = index.U32(), |
| 249 | .offset = base_offset, | 268 | .offset = base_offset, |
| 269 | .shift_left = 0, | ||
| 250 | .secondary_index = 0, | 270 | .secondary_index = 0, |
| 251 | .secondary_offset = 0, | 271 | .secondary_offset = 0, |
| 272 | .secondary_shift_left = 0, | ||
| 252 | .dynamic_offset = dynamic_offset, | 273 | .dynamic_offset = dynamic_offset, |
| 253 | .count = 8, | 274 | .count = 8, |
| 254 | .has_secondary = false, | 275 | .has_secondary = false, |
| @@ -267,8 +288,10 @@ TextureInst MakeInst(Environment& env, IR::Block* block, IR::Inst& inst) { | |||
| 267 | addr = ConstBufferAddr{ | 288 | addr = ConstBufferAddr{ |
| 268 | .index = env.TextureBoundBuffer(), | 289 | .index = env.TextureBoundBuffer(), |
| 269 | .offset = inst.Arg(0).U32(), | 290 | .offset = inst.Arg(0).U32(), |
| 291 | .shift_left = 0, | ||
| 270 | .secondary_index = 0, | 292 | .secondary_index = 0, |
| 271 | .secondary_offset = 0, | 293 | .secondary_offset = 0, |
| 294 | .secondary_shift_left = 0, | ||
| 272 | .dynamic_offset = {}, | 295 | .dynamic_offset = {}, |
| 273 | .count = 1, | 296 | .count = 1, |
| 274 | .has_secondary = false, | 297 | .has_secondary = false, |
| @@ -284,8 +307,9 @@ TextureInst MakeInst(Environment& env, IR::Block* block, IR::Inst& inst) { | |||
| 284 | TextureType ReadTextureType(Environment& env, const ConstBufferAddr& cbuf) { | 307 | TextureType ReadTextureType(Environment& env, const ConstBufferAddr& cbuf) { |
| 285 | const u32 secondary_index{cbuf.has_secondary ? cbuf.secondary_index : cbuf.index}; | 308 | const u32 secondary_index{cbuf.has_secondary ? cbuf.secondary_index : cbuf.index}; |
| 286 | const u32 secondary_offset{cbuf.has_secondary ? cbuf.secondary_offset : cbuf.offset}; | 309 | const u32 secondary_offset{cbuf.has_secondary ? cbuf.secondary_offset : cbuf.offset}; |
| 287 | const u32 lhs_raw{env.ReadCbufValue(cbuf.index, cbuf.offset)}; | 310 | const u32 lhs_raw{env.ReadCbufValue(cbuf.index, cbuf.offset) << cbuf.shift_left}; |
| 288 | const u32 rhs_raw{env.ReadCbufValue(secondary_index, secondary_offset)}; | 311 | const u32 rhs_raw{env.ReadCbufValue(secondary_index, secondary_offset) |
| 312 | << cbuf.secondary_shift_left}; | ||
| 289 | return env.ReadTextureType(lhs_raw | rhs_raw); | 313 | return env.ReadTextureType(lhs_raw | rhs_raw); |
| 290 | } | 314 | } |
| 291 | 315 | ||
| @@ -487,8 +511,10 @@ void TexturePass(Environment& env, IR::Program& program) { | |||
| 487 | .has_secondary = cbuf.has_secondary, | 511 | .has_secondary = cbuf.has_secondary, |
| 488 | .cbuf_index = cbuf.index, | 512 | .cbuf_index = cbuf.index, |
| 489 | .cbuf_offset = cbuf.offset, | 513 | .cbuf_offset = cbuf.offset, |
| 514 | .shift_left = cbuf.shift_left, | ||
| 490 | .secondary_cbuf_index = cbuf.secondary_index, | 515 | .secondary_cbuf_index = cbuf.secondary_index, |
| 491 | .secondary_cbuf_offset = cbuf.secondary_offset, | 516 | .secondary_cbuf_offset = cbuf.secondary_offset, |
| 517 | .secondary_shift_left = cbuf.secondary_shift_left, | ||
| 492 | .count = cbuf.count, | 518 | .count = cbuf.count, |
| 493 | .size_shift = DESCRIPTOR_SIZE_SHIFT, | 519 | .size_shift = DESCRIPTOR_SIZE_SHIFT, |
| 494 | }); | 520 | }); |
| @@ -499,8 +525,10 @@ void TexturePass(Environment& env, IR::Program& program) { | |||
| 499 | .has_secondary = cbuf.has_secondary, | 525 | .has_secondary = cbuf.has_secondary, |
| 500 | .cbuf_index = cbuf.index, | 526 | .cbuf_index = cbuf.index, |
| 501 | .cbuf_offset = cbuf.offset, | 527 | .cbuf_offset = cbuf.offset, |
| 528 | .shift_left = cbuf.shift_left, | ||
| 502 | .secondary_cbuf_index = cbuf.secondary_index, | 529 | .secondary_cbuf_index = cbuf.secondary_index, |
| 503 | .secondary_cbuf_offset = cbuf.secondary_offset, | 530 | .secondary_cbuf_offset = cbuf.secondary_offset, |
| 531 | .secondary_shift_left = cbuf.secondary_shift_left, | ||
| 504 | .count = cbuf.count, | 532 | .count = cbuf.count, |
| 505 | .size_shift = DESCRIPTOR_SIZE_SHIFT, | 533 | .size_shift = DESCRIPTOR_SIZE_SHIFT, |
| 506 | }); | 534 | }); |
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h index f5690805c..cc596da4f 100644 --- a/src/shader_recompiler/shader_info.h +++ b/src/shader_recompiler/shader_info.h | |||
| @@ -61,8 +61,10 @@ struct TextureBufferDescriptor { | |||
| 61 | bool has_secondary; | 61 | bool has_secondary; |
| 62 | u32 cbuf_index; | 62 | u32 cbuf_index; |
| 63 | u32 cbuf_offset; | 63 | u32 cbuf_offset; |
| 64 | u32 shift_left; | ||
| 64 | u32 secondary_cbuf_index; | 65 | u32 secondary_cbuf_index; |
| 65 | u32 secondary_cbuf_offset; | 66 | u32 secondary_cbuf_offset; |
| 67 | u32 secondary_shift_left; | ||
| 66 | u32 count; | 68 | u32 count; |
| 67 | u32 size_shift; | 69 | u32 size_shift; |
| 68 | }; | 70 | }; |
| @@ -85,8 +87,10 @@ struct TextureDescriptor { | |||
| 85 | bool has_secondary; | 87 | bool has_secondary; |
| 86 | u32 cbuf_index; | 88 | u32 cbuf_index; |
| 87 | u32 cbuf_offset; | 89 | u32 cbuf_offset; |
| 90 | u32 shift_left; | ||
| 88 | u32 secondary_cbuf_index; | 91 | u32 secondary_cbuf_index; |
| 89 | u32 secondary_cbuf_offset; | 92 | u32 secondary_cbuf_offset; |
| 93 | u32 secondary_shift_left; | ||
| 90 | u32 count; | 94 | u32 count; |
| 91 | u32 size_shift; | 95 | u32 size_shift; |
| 92 | }; | 96 | }; |