diff options
5 files changed, 31 insertions, 11 deletions
diff --git a/src/shader_recompiler/ir_opt/rescaling_pass.cpp b/src/shader_recompiler/ir_opt/rescaling_pass.cpp index d5b98ae6e..86c8f0c69 100644 --- a/src/shader_recompiler/ir_opt/rescaling_pass.cpp +++ b/src/shader_recompiler/ir_opt/rescaling_pass.cpp | |||
| @@ -84,10 +84,8 @@ void PatchImageQueryDimensions(IR::Block& block, IR::Inst& inst) { | |||
| 84 | } | 84 | } |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | void PatchImageFetch(IR::Block& block, IR::Inst& inst) { | 87 | void ScaleIntegerCoord(IR::IREmitter& ir, IR::Inst& inst, const IR::U1& is_scaled) { |
| 88 | IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; | ||
| 89 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 88 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 90 | const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))}; | ||
| 91 | const IR::Value coord{inst.Arg(1)}; | 89 | const IR::Value coord{inst.Arg(1)}; |
| 92 | switch (info.type) { | 90 | switch (info.type) { |
| 93 | case TextureType::Color1D: | 91 | case TextureType::Color1D: |
| @@ -121,6 +119,21 @@ void PatchImageFetch(IR::Block& block, IR::Inst& inst) { | |||
| 121 | } | 119 | } |
| 122 | } | 120 | } |
| 123 | 121 | ||
| 122 | void PatchImageFetch(IR::Block& block, IR::Inst& inst) { | ||
| 123 | IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; | ||
| 124 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 125 | const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))}; | ||
| 126 | ScaleIntegerCoord(ir, inst, is_scaled); | ||
| 127 | } | ||
| 128 | |||
| 129 | void PatchImageRead(IR::Block& block, IR::Inst& inst) { | ||
| 130 | IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; | ||
| 131 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 132 | // TODO: Scale conditionally | ||
| 133 | const IR::U1 is_scaled{IR::Value{true}}; | ||
| 134 | ScaleIntegerCoord(ir, inst, is_scaled); | ||
| 135 | } | ||
| 136 | |||
| 124 | void Visit(const IR::Program& program, IR::Block& block, IR::Inst& inst) { | 137 | void Visit(const IR::Program& program, IR::Block& block, IR::Inst& inst) { |
| 125 | const bool is_fragment_shader{program.stage == Stage::Fragment}; | 138 | const bool is_fragment_shader{program.stage == Stage::Fragment}; |
| 126 | switch (inst.GetOpcode()) { | 139 | switch (inst.GetOpcode()) { |
| @@ -144,6 +157,9 @@ void Visit(const IR::Program& program, IR::Block& block, IR::Inst& inst) { | |||
| 144 | case IR::Opcode::ImageFetch: | 157 | case IR::Opcode::ImageFetch: |
| 145 | PatchImageFetch(block, inst); | 158 | PatchImageFetch(block, inst); |
| 146 | break; | 159 | break; |
| 160 | case IR::Opcode::ImageRead: | ||
| 161 | PatchImageRead(block, inst); | ||
| 162 | break; | ||
| 147 | default: | 163 | default: |
| 148 | break; | 164 | break; |
| 149 | } | 165 | } |
diff --git a/src/video_core/renderer_opengl/gl_compute_pipeline.cpp b/src/video_core/renderer_opengl/gl_compute_pipeline.cpp index 02853b078..60c65047b 100644 --- a/src/video_core/renderer_opengl/gl_compute_pipeline.cpp +++ b/src/video_core/renderer_opengl/gl_compute_pipeline.cpp | |||
| @@ -139,7 +139,7 @@ void ComputePipeline::Configure() { | |||
| 139 | } | 139 | } |
| 140 | } | 140 | } |
| 141 | for (const auto& desc : info.image_descriptors) { | 141 | for (const auto& desc : info.image_descriptors) { |
| 142 | add_image(desc, true); | 142 | add_image(desc, desc.is_written); |
| 143 | } | 143 | } |
| 144 | texture_cache.FillComputeImageViews(std::span(views.data(), views.size())); | 144 | texture_cache.FillComputeImageViews(std::span(views.data(), views.size())); |
| 145 | 145 | ||
diff --git a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp index c3d549a6e..11559d6ce 100644 --- a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp +++ b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp | |||
| @@ -362,7 +362,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) { | |||
| 362 | } | 362 | } |
| 363 | if constexpr (Spec::has_images) { | 363 | if constexpr (Spec::has_images) { |
| 364 | for (const auto& desc : info.image_descriptors) { | 364 | for (const auto& desc : info.image_descriptors) { |
| 365 | add_image(desc, true); | 365 | add_image(desc, desc.is_written); |
| 366 | } | 366 | } |
| 367 | } | 367 | } |
| 368 | }}; | 368 | }}; |
diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp index f89b84c6e..6dc52e399 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp | |||
| @@ -159,7 +159,7 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute, | |||
| 159 | } | 159 | } |
| 160 | } | 160 | } |
| 161 | for (const auto& desc : info.image_descriptors) { | 161 | for (const auto& desc : info.image_descriptors) { |
| 162 | add_image(desc, true); | 162 | add_image(desc, desc.is_written); |
| 163 | } | 163 | } |
| 164 | texture_cache.FillComputeImageViews(std::span(views.data(), views.size())); | 164 | texture_cache.FillComputeImageViews(std::span(views.data(), views.size())); |
| 165 | 165 | ||
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 4efb5d735..c29bab678 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -322,20 +322,24 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) { | |||
| 322 | } | 322 | } |
| 323 | return TexturePair(gpu_memory.Read<u32>(addr), via_header_index); | 323 | return TexturePair(gpu_memory.Read<u32>(addr), via_header_index); |
| 324 | }}; | 324 | }}; |
| 325 | const auto add_image{[&](const auto& desc) { | 325 | const auto add_image{[&](const auto& desc, bool blacklist) LAMBDA_FORCEINLINE { |
| 326 | for (u32 index = 0; index < desc.count; ++index) { | 326 | for (u32 index = 0; index < desc.count; ++index) { |
| 327 | const auto handle{read_handle(desc, index)}; | 327 | const auto handle{read_handle(desc, index)}; |
| 328 | views[view_index++] = {handle.first}; | 328 | views[view_index++] = { |
| 329 | .index = handle.first, | ||
| 330 | .blacklist = blacklist, | ||
| 331 | .id = {}, | ||
| 332 | }; | ||
| 329 | } | 333 | } |
| 330 | }}; | 334 | }}; |
| 331 | if constexpr (Spec::has_texture_buffers) { | 335 | if constexpr (Spec::has_texture_buffers) { |
| 332 | for (const auto& desc : info.texture_buffer_descriptors) { | 336 | for (const auto& desc : info.texture_buffer_descriptors) { |
| 333 | add_image(desc); | 337 | add_image(desc, false); |
| 334 | } | 338 | } |
| 335 | } | 339 | } |
| 336 | if constexpr (Spec::has_image_buffers) { | 340 | if constexpr (Spec::has_image_buffers) { |
| 337 | for (const auto& desc : info.image_buffer_descriptors) { | 341 | for (const auto& desc : info.image_buffer_descriptors) { |
| 338 | add_image(desc); | 342 | add_image(desc, false); |
| 339 | } | 343 | } |
| 340 | } | 344 | } |
| 341 | for (const auto& desc : info.texture_descriptors) { | 345 | for (const auto& desc : info.texture_descriptors) { |
| @@ -349,7 +353,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) { | |||
| 349 | } | 353 | } |
| 350 | if constexpr (Spec::has_images) { | 354 | if constexpr (Spec::has_images) { |
| 351 | for (const auto& desc : info.image_descriptors) { | 355 | for (const auto& desc : info.image_descriptors) { |
| 352 | add_image(desc); | 356 | add_image(desc, desc.is_written); |
| 353 | } | 357 | } |
| 354 | } | 358 | } |
| 355 | }}; | 359 | }}; |