2021-07-18 21:06:12 +00:00
|
|
|
// Copyright 2021 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "common/alignment.h"
|
2021-07-22 01:25:34 +00:00
|
|
|
#include "common/settings.h"
|
2021-07-18 21:06:12 +00:00
|
|
|
#include "shader_recompiler/environment.h"
|
2021-07-22 01:25:34 +00:00
|
|
|
#include "shader_recompiler/frontend/ir/ir_emitter.h"
|
2021-07-18 21:06:12 +00:00
|
|
|
#include "shader_recompiler/frontend/ir/modifiers.h"
|
|
|
|
#include "shader_recompiler/frontend/ir/program.h"
|
|
|
|
#include "shader_recompiler/frontend/ir/value.h"
|
|
|
|
#include "shader_recompiler/ir_opt/passes.h"
|
|
|
|
#include "shader_recompiler/shader_info.h"
|
|
|
|
|
|
|
|
namespace Shader::Optimization {
|
|
|
|
namespace {
|
2021-09-30 00:53:30 +00:00
|
|
|
[[nodiscard]] bool IsTextureTypeRescalable(TextureType type) {
|
|
|
|
switch (type) {
|
|
|
|
case TextureType::Color2D:
|
|
|
|
case TextureType::ColorArray2D:
|
|
|
|
return true;
|
|
|
|
case TextureType::Color1D:
|
|
|
|
case TextureType::ColorArray1D:
|
|
|
|
case TextureType::Color3D:
|
|
|
|
case TextureType::ColorCube:
|
|
|
|
case TextureType::ColorArrayCube:
|
|
|
|
case TextureType::Buffer:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-29 23:47:18 +00:00
|
|
|
void VisitMark(IR::Block& block, IR::Inst& inst) {
|
2021-09-18 00:26:33 +00:00
|
|
|
switch (inst.GetOpcode()) {
|
|
|
|
case IR::Opcode::ShuffleIndex:
|
|
|
|
case IR::Opcode::ShuffleUp:
|
|
|
|
case IR::Opcode::ShuffleDown:
|
|
|
|
case IR::Opcode::ShuffleButterfly: {
|
2021-09-18 01:31:29 +00:00
|
|
|
const IR::Value shfl_arg{inst.Arg(0)};
|
|
|
|
if (shfl_arg.IsImmediate()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
const IR::Inst* const arg_inst{shfl_arg.InstRecursive()};
|
|
|
|
if (arg_inst->GetOpcode() != IR::Opcode::BitCastU32F32) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
const IR::Value bitcast_arg{arg_inst->Arg(0)};
|
|
|
|
if (bitcast_arg.IsImmediate()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IR::Inst* const bitcast_inst{bitcast_arg.InstRecursive()};
|
2021-10-29 23:47:18 +00:00
|
|
|
bool must_patch_outside = false;
|
2021-09-18 01:31:29 +00:00
|
|
|
if (bitcast_inst->GetOpcode() == IR::Opcode::GetAttribute) {
|
|
|
|
const IR::Attribute attr{bitcast_inst->Arg(0).Attribute()};
|
2021-09-18 00:26:33 +00:00
|
|
|
switch (attr) {
|
|
|
|
case IR::Attribute::PositionX:
|
|
|
|
case IR::Attribute::PositionY:
|
2021-09-18 01:31:29 +00:00
|
|
|
bitcast_inst->SetFlags<u32>(0xDEADBEEF);
|
2021-10-29 23:47:18 +00:00
|
|
|
must_patch_outside = true;
|
2021-09-18 00:26:33 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-10-29 23:47:18 +00:00
|
|
|
if (must_patch_outside) {
|
|
|
|
const auto it{IR::Block::InstructionList::s_iterator_to(inst)};
|
|
|
|
IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
|
|
|
|
const IR::F32 new_inst{&*block.PrependNewInst(it, inst)};
|
|
|
|
const IR::F32 up_factor{ir.FPRecip(ir.ResolutionDownFactor())};
|
|
|
|
const IR::Value converted{ir.FPMul(new_inst, up_factor)};
|
|
|
|
inst.ReplaceUsesWith(converted);
|
|
|
|
}
|
2021-09-18 00:26:33 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-10-29 23:47:18 +00:00
|
|
|
|
2021-09-18 00:26:33 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-09-29 01:37:54 +00:00
|
|
|
|
2021-07-22 01:25:34 +00:00
|
|
|
void PatchFragCoord(IR::Block& block, IR::Inst& inst) {
|
2021-07-18 21:06:12 +00:00
|
|
|
IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
|
2021-07-22 01:25:34 +00:00
|
|
|
const IR::F32 down_factor{ir.ResolutionDownFactor()};
|
2021-07-22 07:29:00 +00:00
|
|
|
const IR::F32 frag_coord{ir.GetAttribute(inst.Arg(0).Attribute())};
|
2021-07-22 01:25:34 +00:00
|
|
|
const IR::F32 downscaled_frag_coord{ir.FPMul(frag_coord, down_factor)};
|
|
|
|
inst.ReplaceUsesWith(downscaled_frag_coord);
|
2021-07-18 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
2021-10-29 15:02:57 +00:00
|
|
|
void PatchPointSize(IR::Block& block, IR::Inst& inst) {
|
|
|
|
IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
|
|
|
|
const IR::F32 point_value{inst.Arg(1)};
|
|
|
|
const IR::F32 up_factor{ir.FPRecip(ir.ResolutionDownFactor())};
|
|
|
|
const IR::F32 upscaled_point_value{ir.FPMul(point_value, up_factor)};
|
|
|
|
inst.SetArg(1, upscaled_point_value);
|
|
|
|
}
|
|
|
|
|
2021-07-26 01:20:56 +00:00
|
|
|
[[nodiscard]] IR::U32 Scale(IR::IREmitter& ir, const IR::U1& is_scaled, const IR::U32& value) {
|
|
|
|
IR::U32 scaled_value{value};
|
|
|
|
if (const u32 up_scale = Settings::values.resolution_info.up_scale; up_scale != 1) {
|
2021-08-01 23:03:15 +00:00
|
|
|
scaled_value = ir.IMul(scaled_value, ir.Imm32(up_scale));
|
2021-07-26 01:20:56 +00:00
|
|
|
}
|
|
|
|
if (const u32 down_shift = Settings::values.resolution_info.down_shift; down_shift != 0) {
|
2021-08-01 23:03:15 +00:00
|
|
|
scaled_value = ir.ShiftRightArithmetic(scaled_value, ir.Imm32(down_shift));
|
2021-07-26 01:20:56 +00:00
|
|
|
}
|
2021-09-29 01:37:54 +00:00
|
|
|
return IR::U32{ir.Select(is_scaled, scaled_value, value)};
|
2021-07-26 01:20:56 +00:00
|
|
|
}
|
|
|
|
|
2021-08-07 00:59:05 +00:00
|
|
|
[[nodiscard]] IR::U32 SubScale(IR::IREmitter& ir, const IR::U1& is_scaled, const IR::U32& value,
|
|
|
|
const IR::Attribute attrib) {
|
2021-09-29 01:37:54 +00:00
|
|
|
const IR::F32 up_factor{ir.Imm32(Settings::values.resolution_info.up_factor)};
|
|
|
|
const IR::F32 base{ir.FPMul(ir.ConvertUToF(32, 32, value), up_factor)};
|
2021-09-18 04:43:41 +00:00
|
|
|
const IR::F32 frag_coord{ir.GetAttribute(attrib)};
|
2021-09-29 01:37:54 +00:00
|
|
|
const IR::F32 down_factor{ir.Imm32(Settings::values.resolution_info.down_factor)};
|
|
|
|
const IR::F32 floor{ir.FPMul(up_factor, ir.FPFloor(ir.FPMul(frag_coord, down_factor)))};
|
|
|
|
const IR::F16F32F64 deviation{ir.FPAdd(base, ir.FPAdd(frag_coord, ir.FPNeg(floor)))};
|
|
|
|
return IR::U32{ir.Select(is_scaled, ir.ConvertFToU(32, deviation), value)};
|
2021-08-07 00:59:05 +00:00
|
|
|
}
|
|
|
|
|
2021-09-29 01:37:54 +00:00
|
|
|
[[nodiscard]] IR::U32 DownScale(IR::IREmitter& ir, const IR::U1& is_scaled, const IR::U32& value) {
|
2021-08-01 23:03:15 +00:00
|
|
|
IR::U32 scaled_value{value};
|
2021-07-26 01:20:56 +00:00
|
|
|
if (const u32 down_shift = Settings::values.resolution_info.down_shift; down_shift != 0) {
|
2021-08-01 23:03:15 +00:00
|
|
|
scaled_value = ir.ShiftLeftLogical(scaled_value, ir.Imm32(down_shift));
|
2021-07-26 01:20:56 +00:00
|
|
|
}
|
|
|
|
if (const u32 up_scale = Settings::values.resolution_info.up_scale; up_scale != 1) {
|
2021-08-01 23:03:15 +00:00
|
|
|
scaled_value = ir.IDiv(scaled_value, ir.Imm32(up_scale));
|
2021-07-26 01:20:56 +00:00
|
|
|
}
|
2021-09-29 01:37:54 +00:00
|
|
|
return IR::U32{ir.Select(is_scaled, scaled_value, value)};
|
2021-07-26 01:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PatchImageQueryDimensions(IR::Block& block, IR::Inst& inst) {
|
|
|
|
const auto it{IR::Block::InstructionList::s_iterator_to(inst)};
|
|
|
|
IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
|
|
|
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
2021-08-01 23:03:15 +00:00
|
|
|
const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))};
|
2021-07-26 01:20:56 +00:00
|
|
|
switch (info.type) {
|
|
|
|
case TextureType::Color2D:
|
|
|
|
case TextureType::ColorArray2D: {
|
|
|
|
const IR::Value new_inst{&*block.PrependNewInst(it, inst)};
|
2021-08-01 23:03:15 +00:00
|
|
|
const IR::U32 width{DownScale(ir, is_scaled, IR::U32{ir.CompositeExtract(new_inst, 0)})};
|
|
|
|
const IR::U32 height{DownScale(ir, is_scaled, IR::U32{ir.CompositeExtract(new_inst, 1)})};
|
2021-07-26 01:20:56 +00:00
|
|
|
const IR::Value replacement{ir.CompositeConstruct(
|
|
|
|
width, height, ir.CompositeExtract(new_inst, 2), ir.CompositeExtract(new_inst, 3))};
|
|
|
|
inst.ReplaceUsesWith(replacement);
|
|
|
|
break;
|
|
|
|
}
|
2021-08-01 23:03:15 +00:00
|
|
|
case TextureType::Color1D:
|
|
|
|
case TextureType::ColorArray1D:
|
2021-07-26 01:20:56 +00:00
|
|
|
case TextureType::Color3D:
|
|
|
|
case TextureType::ColorCube:
|
|
|
|
case TextureType::ColorArrayCube:
|
|
|
|
case TextureType::Buffer:
|
|
|
|
// Nothing to patch here
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-29 01:29:17 +00:00
|
|
|
void ScaleIntegerComposite(IR::IREmitter& ir, IR::Inst& inst, const IR::U1& is_scaled,
|
|
|
|
size_t index) {
|
|
|
|
const IR::Value composite{inst.Arg(index)};
|
|
|
|
if (composite.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2021-07-26 01:20:56 +00:00
|
|
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
2021-09-29 01:29:17 +00:00
|
|
|
const IR::U32 x{Scale(ir, is_scaled, IR::U32{ir.CompositeExtract(composite, 0)})};
|
|
|
|
const IR::U32 y{Scale(ir, is_scaled, IR::U32{ir.CompositeExtract(composite, 1)})};
|
2021-07-26 01:20:56 +00:00
|
|
|
switch (info.type) {
|
2021-09-29 01:29:17 +00:00
|
|
|
case TextureType::Color2D:
|
|
|
|
inst.SetArg(index, ir.CompositeConstruct(x, y));
|
2021-07-26 01:20:56 +00:00
|
|
|
break;
|
|
|
|
case TextureType::ColorArray2D: {
|
2021-09-29 01:29:17 +00:00
|
|
|
const IR::U32 z{ir.CompositeExtract(composite, 2)};
|
|
|
|
inst.SetArg(index, ir.CompositeConstruct(x, y, z));
|
2021-07-26 01:20:56 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-08-01 23:03:15 +00:00
|
|
|
case TextureType::Color1D:
|
|
|
|
case TextureType::ColorArray1D:
|
2021-07-26 01:20:56 +00:00
|
|
|
case TextureType::Color3D:
|
|
|
|
case TextureType::ColorCube:
|
|
|
|
case TextureType::ColorArrayCube:
|
|
|
|
case TextureType::Buffer:
|
|
|
|
// Nothing to patch here
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-12 08:31:56 +00:00
|
|
|
void ScaleIntegerOffsetComposite(IR::IREmitter& ir, IR::Inst& inst, const IR::U1& is_scaled,
|
|
|
|
size_t index) {
|
|
|
|
const IR::Value composite{inst.Arg(index)};
|
|
|
|
if (composite.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
|
|
|
const IR::U32 x{Scale(ir, is_scaled, IR::U32{ir.CompositeExtract(composite, 0)})};
|
|
|
|
const IR::U32 y{Scale(ir, is_scaled, IR::U32{ir.CompositeExtract(composite, 1)})};
|
|
|
|
switch (info.type) {
|
|
|
|
case TextureType::ColorArray2D:
|
|
|
|
case TextureType::Color2D:
|
|
|
|
inst.SetArg(index, ir.CompositeConstruct(x, y));
|
|
|
|
break;
|
|
|
|
case TextureType::Color1D:
|
|
|
|
case TextureType::ColorArray1D:
|
|
|
|
case TextureType::Color3D:
|
|
|
|
case TextureType::ColorCube:
|
|
|
|
case TextureType::ColorArrayCube:
|
|
|
|
case TextureType::Buffer:
|
|
|
|
// Nothing to patch here
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-29 01:29:17 +00:00
|
|
|
void SubScaleCoord(IR::IREmitter& ir, IR::Inst& inst, const IR::U1& is_scaled) {
|
2021-08-07 00:59:05 +00:00
|
|
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
|
|
|
const IR::Value coord{inst.Arg(1)};
|
2021-09-29 01:29:17 +00:00
|
|
|
const IR::U32 coord_x{ir.CompositeExtract(coord, 0)};
|
|
|
|
const IR::U32 coord_y{ir.CompositeExtract(coord, 1)};
|
|
|
|
|
|
|
|
const IR::U32 scaled_x{SubScale(ir, is_scaled, coord_x, IR::Attribute::PositionX)};
|
|
|
|
const IR::U32 scaled_y{SubScale(ir, is_scaled, coord_y, IR::Attribute::PositionY)};
|
2021-08-07 00:59:05 +00:00
|
|
|
switch (info.type) {
|
2021-09-29 01:29:17 +00:00
|
|
|
case TextureType::Color2D:
|
|
|
|
inst.SetArg(1, ir.CompositeConstruct(scaled_x, scaled_y));
|
2021-08-07 00:59:05 +00:00
|
|
|
break;
|
|
|
|
case TextureType::ColorArray2D: {
|
|
|
|
const IR::U32 z{ir.CompositeExtract(coord, 2)};
|
2021-09-29 01:29:17 +00:00
|
|
|
inst.SetArg(1, ir.CompositeConstruct(scaled_x, scaled_y, z));
|
2021-08-07 00:59:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TextureType::Color1D:
|
|
|
|
case TextureType::ColorArray1D:
|
|
|
|
case TextureType::Color3D:
|
|
|
|
case TextureType::ColorCube:
|
|
|
|
case TextureType::ColorArrayCube:
|
|
|
|
case TextureType::Buffer:
|
|
|
|
// Nothing to patch here
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-29 01:29:17 +00:00
|
|
|
void SubScaleImageFetch(IR::Block& block, IR::Inst& inst) {
|
|
|
|
IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
|
|
|
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
2021-09-30 00:53:30 +00:00
|
|
|
if (!IsTextureTypeRescalable(info.type)) {
|
|
|
|
return;
|
|
|
|
}
|
2021-09-29 01:29:17 +00:00
|
|
|
const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))};
|
|
|
|
SubScaleCoord(ir, inst, is_scaled);
|
|
|
|
// Scale ImageFetch offset
|
2022-03-12 08:31:56 +00:00
|
|
|
ScaleIntegerOffsetComposite(ir, inst, is_scaled, 2);
|
2021-09-29 01:29:17 +00:00
|
|
|
}
|
|
|
|
|
2021-08-07 00:59:05 +00:00
|
|
|
void SubScaleImageRead(IR::Block& block, IR::Inst& inst) {
|
|
|
|
IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
|
|
|
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
2021-09-30 00:53:30 +00:00
|
|
|
if (!IsTextureTypeRescalable(info.type)) {
|
|
|
|
return;
|
|
|
|
}
|
2021-08-07 00:59:05 +00:00
|
|
|
const IR::U1 is_scaled{ir.IsImageScaled(ir.Imm32(info.descriptor_index))};
|
2021-09-29 01:29:17 +00:00
|
|
|
SubScaleCoord(ir, inst, is_scaled);
|
2021-08-07 00:59:05 +00:00
|
|
|
}
|
|
|
|
|
2021-08-01 05:26:02 +00:00
|
|
|
void PatchImageFetch(IR::Block& block, IR::Inst& inst) {
|
|
|
|
IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
|
|
|
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
2021-09-30 00:53:30 +00:00
|
|
|
if (!IsTextureTypeRescalable(info.type)) {
|
|
|
|
return;
|
|
|
|
}
|
2021-08-01 05:26:02 +00:00
|
|
|
const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))};
|
2021-09-29 01:29:17 +00:00
|
|
|
ScaleIntegerComposite(ir, inst, is_scaled, 1);
|
|
|
|
// Scale ImageFetch offset
|
2022-03-12 08:31:56 +00:00
|
|
|
ScaleIntegerOffsetComposite(ir, inst, is_scaled, 2);
|
2021-08-01 05:26:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PatchImageRead(IR::Block& block, IR::Inst& inst) {
|
|
|
|
IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
|
|
|
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
2021-09-30 00:53:30 +00:00
|
|
|
if (!IsTextureTypeRescalable(info.type)) {
|
|
|
|
return;
|
|
|
|
}
|
2021-08-01 21:57:45 +00:00
|
|
|
const IR::U1 is_scaled{ir.IsImageScaled(ir.Imm32(info.descriptor_index))};
|
2021-09-29 01:29:17 +00:00
|
|
|
ScaleIntegerComposite(ir, inst, is_scaled, 1);
|
2021-08-01 05:26:02 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 01:25:34 +00:00
|
|
|
void Visit(const IR::Program& program, IR::Block& block, IR::Inst& inst) {
|
|
|
|
const bool is_fragment_shader{program.stage == Stage::Fragment};
|
2021-07-18 21:06:12 +00:00
|
|
|
switch (inst.GetOpcode()) {
|
|
|
|
case IR::Opcode::GetAttribute: {
|
2021-07-22 01:25:34 +00:00
|
|
|
const IR::Attribute attr{inst.Arg(0).Attribute()};
|
|
|
|
switch (attr) {
|
|
|
|
case IR::Attribute::PositionX:
|
|
|
|
case IR::Attribute::PositionY:
|
2021-09-18 00:26:33 +00:00
|
|
|
if (is_fragment_shader && inst.Flags<u32>() != 0xDEADBEEF) {
|
2021-07-22 01:25:34 +00:00
|
|
|
PatchFragCoord(block, inst);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2021-07-18 21:06:12 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-10-29 15:02:57 +00:00
|
|
|
case IR::Opcode::SetAttribute: {
|
|
|
|
const IR::Attribute attr{inst.Arg(0).Attribute()};
|
|
|
|
switch (attr) {
|
|
|
|
case IR::Attribute::PointSize:
|
|
|
|
if (inst.Flags<u32>() != 0xDEADBEEF) {
|
|
|
|
PatchPointSize(block, inst);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-07-22 01:25:34 +00:00
|
|
|
case IR::Opcode::ImageQueryDimensions:
|
2021-09-27 02:43:06 +00:00
|
|
|
PatchImageQueryDimensions(block, inst);
|
2021-07-18 21:06:12 +00:00
|
|
|
break;
|
2021-07-22 01:25:34 +00:00
|
|
|
case IR::Opcode::ImageFetch:
|
2021-08-07 00:59:05 +00:00
|
|
|
if (is_fragment_shader) {
|
|
|
|
SubScaleImageFetch(block, inst);
|
2021-09-29 01:29:17 +00:00
|
|
|
} else {
|
2021-08-07 00:59:05 +00:00
|
|
|
PatchImageFetch(block, inst);
|
|
|
|
}
|
2021-07-18 21:06:12 +00:00
|
|
|
break;
|
2021-08-01 05:26:02 +00:00
|
|
|
case IR::Opcode::ImageRead:
|
2021-08-07 00:59:05 +00:00
|
|
|
if (is_fragment_shader) {
|
|
|
|
SubScaleImageRead(block, inst);
|
2021-09-29 01:29:17 +00:00
|
|
|
} else {
|
2021-08-07 00:59:05 +00:00
|
|
|
PatchImageRead(block, inst);
|
|
|
|
}
|
2021-08-01 05:26:02 +00:00
|
|
|
break;
|
2021-07-18 21:06:12 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-07-22 01:25:34 +00:00
|
|
|
} // Anonymous namespace
|
2021-07-18 21:06:12 +00:00
|
|
|
|
2021-07-22 01:25:34 +00:00
|
|
|
void RescalingPass(IR::Program& program) {
|
2021-09-29 01:37:54 +00:00
|
|
|
const bool is_fragment_shader{program.stage == Stage::Fragment};
|
|
|
|
if (is_fragment_shader) {
|
|
|
|
for (IR::Block* const block : program.post_order_blocks) {
|
|
|
|
for (IR::Inst& inst : block->Instructions()) {
|
2021-10-29 23:47:18 +00:00
|
|
|
VisitMark(*block, inst);
|
2021-09-29 01:37:54 +00:00
|
|
|
}
|
2021-09-18 00:26:33 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-18 21:06:12 +00:00
|
|
|
for (IR::Block* const block : program.post_order_blocks) {
|
|
|
|
for (IR::Inst& inst : block->Instructions()) {
|
2021-07-22 01:25:34 +00:00
|
|
|
Visit(program, *block, inst);
|
2021-07-18 21:06:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Shader::Optimization
|