From c5a06dab0a9404c627bba187e0d8534a1566cfba Mon Sep 17 00:00:00 2001 From: kd-11 Date: Thu, 13 May 2021 00:56:01 +0300 Subject: [PATCH] rsx: Refactor program texture state handling to be persistent across shader swaps --- rpcs3/Emu/RSX/GL/GLDraw.cpp | 4 +- rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp | 2 +- rpcs3/Emu/RSX/GL/GLFragmentProgram.h | 5 +- rpcs3/Emu/RSX/GL/GLGSRender.cpp | 9 +- rpcs3/Emu/RSX/GL/GLHelpers.h | 2 +- rpcs3/Emu/RSX/GL/GLProgramBuffer.h | 2 +- rpcs3/Emu/RSX/GL/GLShaderInterpreter.cpp | 4 +- rpcs3/Emu/RSX/GL/GLShaderInterpreter.h | 2 +- rpcs3/Emu/RSX/GL/GLVertexProgram.cpp | 2 +- rpcs3/Emu/RSX/GL/GLVertexProgram.h | 3 +- .../{ => Program}/CgBinaryFragmentProgram.cpp | 2 +- rpcs3/Emu/RSX/{ => Program}/CgBinaryProgram.h | 0 .../{ => Program}/CgBinaryVertexProgram.cpp | 2 +- .../FragmentProgramDecompiler.cpp | 8 +- .../FragmentProgramDecompiler.h | 2 +- .../RSX/{Common => Program}/GLSLCommon.cpp | 0 .../Emu/RSX/{Common => Program}/GLSLCommon.h | 0 rpcs3/Emu/RSX/{Common => Program}/GLSLTypes.h | 0 .../{Common => Program}/ProgramStateCache.cpp | 17 ++- .../{Common => Program}/ProgramStateCache.h | 4 +- .../RSX/{ => Program}/RSXFragmentProgram.h | 15 ++- .../Emu/RSX/{ => Program}/RSXVertexProgram.h | 7 +- .../{Common => Program}/ShaderInterpreter.h | 4 +- .../Emu/RSX/{Common => Program}/ShaderParam.h | 0 .../VertexProgramDecompiler.cpp | 0 .../VertexProgramDecompiler.h | 2 +- .../program_state_cache2.hpp | 0 rpcs3/Emu/RSX/Program/program_util.cpp | 109 ++++++++++++++++++ rpcs3/Emu/RSX/Program/program_util.h | 55 +++++++++ rpcs3/Emu/RSX/RSXThread.cpp | 49 ++++---- rpcs3/Emu/RSX/RSXThread.h | 12 +- rpcs3/Emu/RSX/VK/VKCommonDecompiler.h | 2 +- rpcs3/Emu/RSX/VK/VKDraw.cpp | 4 +- rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp | 2 +- rpcs3/Emu/RSX/VK/VKFragmentProgram.h | 5 +- rpcs3/Emu/RSX/VK/VKGSRender.cpp | 8 +- rpcs3/Emu/RSX/VK/VKProgramBuffer.h | 2 +- rpcs3/Emu/RSX/VK/VKProgramPipeline.h | 2 +- rpcs3/Emu/RSX/VK/VKShaderInterpreter.cpp | 4 +- rpcs3/Emu/RSX/VK/VKVertexProgram.cpp | 2 +- rpcs3/Emu/RSX/VK/VKVertexProgram.h | 3 +- rpcs3/Emu/RSX/rsx_cache.h | 22 ++-- rpcs3/emucore.vcxproj | 35 +++--- rpcs3/emucore.vcxproj.filters | 100 ++++++++-------- rpcs3/rpcs3qt/cg_disasm_window.cpp | 2 +- 45 files changed, 337 insertions(+), 179 deletions(-) rename rpcs3/Emu/RSX/{ => Program}/CgBinaryFragmentProgram.cpp (99%) rename rpcs3/Emu/RSX/{ => Program}/CgBinaryProgram.h (100%) rename rpcs3/Emu/RSX/{ => Program}/CgBinaryVertexProgram.cpp (99%) rename rpcs3/Emu/RSX/{Common => Program}/FragmentProgramDecompiler.cpp (99%) rename rpcs3/Emu/RSX/{Common => Program}/FragmentProgramDecompiler.h (99%) rename rpcs3/Emu/RSX/{Common => Program}/GLSLCommon.cpp (100%) rename rpcs3/Emu/RSX/{Common => Program}/GLSLCommon.h (100%) rename rpcs3/Emu/RSX/{Common => Program}/GLSLTypes.h (100%) rename rpcs3/Emu/RSX/{Common => Program}/ProgramStateCache.cpp (95%) rename rpcs3/Emu/RSX/{Common => Program}/ProgramStateCache.h (99%) rename rpcs3/Emu/RSX/{ => Program}/RSXFragmentProgram.h (97%) rename rpcs3/Emu/RSX/{ => Program}/RSXVertexProgram.h (97%) rename rpcs3/Emu/RSX/{Common => Program}/ShaderInterpreter.h (83%) rename rpcs3/Emu/RSX/{Common => Program}/ShaderParam.h (100%) rename rpcs3/Emu/RSX/{Common => Program}/VertexProgramDecompiler.cpp (100%) rename rpcs3/Emu/RSX/{Common => Program}/VertexProgramDecompiler.h (99%) rename rpcs3/Emu/RSX/{Common => Program}/program_state_cache2.hpp (100%) create mode 100644 rpcs3/Emu/RSX/Program/program_util.cpp create mode 100644 rpcs3/Emu/RSX/Program/program_util.h diff --git a/rpcs3/Emu/RSX/GL/GLDraw.cpp b/rpcs3/Emu/RSX/GL/GLDraw.cpp index 527e389b70..04c0b7a65e 100644 --- a/rpcs3/Emu/RSX/GL/GLDraw.cpp +++ b/rpcs3/Emu/RSX/GL/GLDraw.cpp @@ -359,7 +359,7 @@ void GLGSRender::bind_texture_env() { view->bind(); - if (current_fragment_program.redirected_textures & (1 << i)) + if (current_fragment_program.texture_state.redirected_textures & (1 << i)) { _SelectTexture(GL_STENCIL_MIRRORS_START + i); @@ -373,7 +373,7 @@ void GLGSRender::bind_texture_env() auto target = gl::get_target(current_fragment_program.get_texture_dimension(i)); glBindTexture(target, m_null_textures[target]->id()); - if (current_fragment_program.redirected_textures & (1 << i)) + if (current_fragment_program.texture_state.redirected_textures & (1 << i)) { _SelectTexture(GL_STENCIL_MIRRORS_START + i); glBindTexture(target, m_null_textures[target]->id()); diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp index 67cbcc0ece..016b628289 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp @@ -4,7 +4,7 @@ #include "Emu/system_config.h" #include "GLCommonDecompiler.h" #include "../GCM.h" -#include "../Common/GLSLCommon.h" +#include "../Program/GLSLCommon.h" std::string GLFragmentDecompilerThread::getFloatTypeName(usz elementCount) { diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.h b/rpcs3/Emu/RSX/GL/GLFragmentProgram.h index a5586b6a10..ffd6904af7 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.h +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.h @@ -1,7 +1,6 @@ #pragma once -#include "../Common/FragmentProgramDecompiler.h" -#include "../Common/GLSLTypes.h" -#include "Emu/RSX/RSXFragmentProgram.h" +#include "../Program/FragmentProgramDecompiler.h" +#include "../Program/GLSLTypes.h" #include "GLHelpers.h" namespace glsl diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 4feba073b3..6382468b20 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -6,7 +6,7 @@ #include "Emu/Memory/vm_locking.h" #include "Emu/RSX/rsx_methods.h" -#include "../Common/program_state_cache2.hpp" +#include "../Program/program_state_cache2.hpp" u64 GLGSRender::get_cycles() { @@ -647,7 +647,7 @@ bool GLGSRender::load_program() get_current_vertex_program(vs_sampler_state); current_vertex_program.skip_vertex_input_check = true; //not needed for us since decoding is done server side - current_fragment_program.unnormalized_coords = 0; //unused + current_fragment_program.texture_state.unnormalized_coords = 0; //unused } else if (m_program) { @@ -801,8 +801,7 @@ void GLGSRender::load_program_env() { // Fragment texture parameters auto mapping = m_texture_parameters_buffer->alloc_from_heap(256, m_uniform_buffer_offset_align); - auto buf = static_cast(mapping.first); - fill_fragment_texture_parameters(buf, current_fragment_program); + current_fragment_program.texture_params.write_to(mapping.first, current_fp_metadata.referenced_textures_mask); m_texture_parameters_buffer->bind_range(GL_FRAGMENT_TEXTURE_PARAMS_BIND_SLOT, mapping.second, 256); } @@ -848,7 +847,7 @@ void GLGSRender::load_program_env() // Control mask const auto control_masks = reinterpret_cast(fp_buf); control_masks[0] = rsx::method_registers.shader_control(); - control_masks[1] = current_fragment_program.texture_dimensions; + control_masks[1] = current_fragment_program.texture_state.texture_dimensions; // Bind textures m_shader_interpreter.update_fragment_textures(fs_sampler_state, current_fp_metadata.referenced_textures_mask, reinterpret_cast(fp_buf + 16)); diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.h b/rpcs3/Emu/RSX/GL/GLHelpers.h index 9aeee91b34..bdd96d6f3d 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.h +++ b/rpcs3/Emu/RSX/GL/GLHelpers.h @@ -10,7 +10,7 @@ #include "GLExecutionState.h" #include "../GCM.h" #include "../Common/TextureUtils.h" -#include "../Common/GLSLTypes.h" +#include "../Program/GLSLTypes.h" #include "Emu/system_config.h" #include "Utilities/mutex.h" diff --git a/rpcs3/Emu/RSX/GL/GLProgramBuffer.h b/rpcs3/Emu/RSX/GL/GLProgramBuffer.h index 1ec4598153..a7eb8f98ad 100644 --- a/rpcs3/Emu/RSX/GL/GLProgramBuffer.h +++ b/rpcs3/Emu/RSX/GL/GLProgramBuffer.h @@ -3,7 +3,7 @@ #include "GLFragmentProgram.h" #include "GLHelpers.h" #include "GLPipelineCompiler.h" -#include "../Common/ProgramStateCache.h" +#include "../Program/ProgramStateCache.h" #include "../rsx_utils.h" struct GLTraits diff --git a/rpcs3/Emu/RSX/GL/GLShaderInterpreter.cpp b/rpcs3/Emu/RSX/GL/GLShaderInterpreter.cpp index 6e6e3ea82f..422455071b 100644 --- a/rpcs3/Emu/RSX/GL/GLShaderInterpreter.cpp +++ b/rpcs3/Emu/RSX/GL/GLShaderInterpreter.cpp @@ -4,8 +4,8 @@ #include "GLVertexProgram.h" #include "GLFragmentProgram.h" #include "../rsx_methods.h" -#include "../Common/ShaderInterpreter.h" -#include "../Common/GLSLCommon.h" +#include "../Program/ShaderInterpreter.h" +#include "../Program/GLSLCommon.h" namespace gl { diff --git a/rpcs3/Emu/RSX/GL/GLShaderInterpreter.h b/rpcs3/Emu/RSX/GL/GLShaderInterpreter.h index 25102cd1db..6603488601 100644 --- a/rpcs3/Emu/RSX/GL/GLShaderInterpreter.h +++ b/rpcs3/Emu/RSX/GL/GLShaderInterpreter.h @@ -1,6 +1,6 @@ #pragma once #include "GLHelpers.h" -#include "../Common/ProgramStateCache.h" +#include "../Program/ProgramStateCache.h" #include "../Common/TextureUtils.h" #include diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp index 33aca9f605..ee6a4e6660 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp @@ -4,7 +4,7 @@ #include "Emu/System.h" #include "GLCommonDecompiler.h" -#include "../Common/GLSLCommon.h" +#include "../Program/GLSLCommon.h" #include diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.h b/rpcs3/Emu/RSX/GL/GLVertexProgram.h index bf95df95e0..4f61930e46 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.h +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.h @@ -1,6 +1,5 @@ #pragma once -#include "../Common/VertexProgramDecompiler.h" -#include "Emu/RSX/RSXVertexProgram.h" +#include "../Program/VertexProgramDecompiler.h" #include "GLHelpers.h" #include diff --git a/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp b/rpcs3/Emu/RSX/Program/CgBinaryFragmentProgram.cpp similarity index 99% rename from rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp rename to rpcs3/Emu/RSX/Program/CgBinaryFragmentProgram.cpp index 65a73e030f..eff0619460 100644 --- a/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/Program/CgBinaryFragmentProgram.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "CgBinaryProgram.h" -#include "Emu/RSX/RSXFragmentProgram.h" +#include "RSXFragmentProgram.h" #include diff --git a/rpcs3/Emu/RSX/CgBinaryProgram.h b/rpcs3/Emu/RSX/Program/CgBinaryProgram.h similarity index 100% rename from rpcs3/Emu/RSX/CgBinaryProgram.h rename to rpcs3/Emu/RSX/Program/CgBinaryProgram.h diff --git a/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp b/rpcs3/Emu/RSX/Program/CgBinaryVertexProgram.cpp similarity index 99% rename from rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp rename to rpcs3/Emu/RSX/Program/CgBinaryVertexProgram.cpp index b82726dd30..98725e0d49 100644 --- a/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp +++ b/rpcs3/Emu/RSX/Program/CgBinaryVertexProgram.cpp @@ -2,7 +2,7 @@ #include "CgBinaryProgram.h" #include "Emu/System.h" -#include "Emu/RSX/RSXVertexProgram.h" +#include "RSXVertexProgram.h" void CgBinaryDisasm::AddScaCodeDisasm(const std::string& code) { diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp similarity index 99% rename from rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp rename to rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp index e0fd69f5f0..65fbb751b1 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp @@ -971,7 +971,7 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode) if (type != rsx::texture_dimension_extended::texture_dimension_3d) { - if (m_prog.shadow_textures & ref_mask) + if (m_prog.texture_state.shadow_textures & ref_mask) { properties.shadow_sampler_mask |= ref_mask; select = 4; @@ -980,7 +980,7 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode) else { properties.common_access_sampler_mask |= ref_mask; - if (m_prog.redirected_textures & ref_mask) + if (m_prog.texture_state.redirected_textures & ref_mask) { properties.redirected_sampler_mask |= ref_mask; select = 5; @@ -1064,8 +1064,8 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode) { AddTex(); - if (m_prog.redirected_textures & (1 << dst.tex_num) || - m_prog.shadow_textures & (1 << dst.tex_num)) + if (m_prog.texture_state.redirected_textures & (1 << dst.tex_num) || + m_prog.texture_state.shadow_textures & (1 << dst.tex_num)) { // Doesn't make sense to sample with derivates for these types rsx_log.error("[Unimplemented warning] TXD operation performed on shadow/redirected texture!"); diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h b/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.h similarity index 99% rename from rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h rename to rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.h index 1d02a8326a..d489f50c76 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h +++ b/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.h @@ -1,6 +1,6 @@ #pragma once #include "ShaderParam.h" -#include "Emu/RSX/RSXFragmentProgram.h" +#include "RSXFragmentProgram.h" #include // Helper for GPR occupancy tracking diff --git a/rpcs3/Emu/RSX/Common/GLSLCommon.cpp b/rpcs3/Emu/RSX/Program/GLSLCommon.cpp similarity index 100% rename from rpcs3/Emu/RSX/Common/GLSLCommon.cpp rename to rpcs3/Emu/RSX/Program/GLSLCommon.cpp diff --git a/rpcs3/Emu/RSX/Common/GLSLCommon.h b/rpcs3/Emu/RSX/Program/GLSLCommon.h similarity index 100% rename from rpcs3/Emu/RSX/Common/GLSLCommon.h rename to rpcs3/Emu/RSX/Program/GLSLCommon.h diff --git a/rpcs3/Emu/RSX/Common/GLSLTypes.h b/rpcs3/Emu/RSX/Program/GLSLTypes.h similarity index 100% rename from rpcs3/Emu/RSX/Common/GLSLTypes.h rename to rpcs3/Emu/RSX/Program/GLSLTypes.h diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp b/rpcs3/Emu/RSX/Program/ProgramStateCache.cpp similarity index 95% rename from rpcs3/Emu/RSX/Common/ProgramStateCache.cpp rename to rpcs3/Emu/RSX/Program/ProgramStateCache.cpp index d53ed3c193..c5b15a9f17 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp +++ b/rpcs3/Emu/RSX/Program/ProgramStateCache.cpp @@ -252,7 +252,7 @@ usz vertex_program_storage_hash::operator()(const RSXVertexProgram &program) con { usz hash = vertex_program_utils::get_vertex_program_ucode_hash(program); hash ^= program.output_mask; - hash ^= program.texture_dimensions; + hash ^= program.texture_state.texture_dimensions; return hash; } @@ -260,7 +260,7 @@ bool vertex_program_compare::operator()(const RSXVertexProgram &binary1, const R { if (binary1.output_mask != binary2.output_mask) return false; - if (binary1.texture_dimensions != binary2.texture_dimensions) + if (binary1.texture_state != binary2.texture_state) return false; if (binary1.data.size() != binary2.data.size()) return false; @@ -451,20 +451,19 @@ usz fragment_program_storage_hash::operator()(const RSXFragmentProgram& program) { usz hash = fragment_program_utils::get_fragment_program_ucode_hash(program); hash ^= program.ctrl; - hash ^= program.texture_dimensions; - hash ^= program.unnormalized_coords; hash ^= +program.two_sided_lighting; - hash ^= program.shadow_textures; - hash ^= program.redirected_textures; + hash ^= program.texture_state.texture_dimensions; + hash ^= program.texture_state.unnormalized_coords; + hash ^= program.texture_state.shadow_textures; + hash ^= program.texture_state.redirected_textures; return hash; } bool fragment_program_compare::operator()(const RSXFragmentProgram& binary1, const RSXFragmentProgram& binary2) const { - if (binary1.ctrl != binary2.ctrl || binary1.texture_dimensions != binary2.texture_dimensions || binary1.unnormalized_coords != binary2.unnormalized_coords || - binary1.two_sided_lighting != binary2.two_sided_lighting || - binary1.shadow_textures != binary2.shadow_textures || binary1.redirected_textures != binary2.redirected_textures) + if (binary1.ctrl != binary2.ctrl || binary1.texture_state != binary2.texture_state || + binary1.two_sided_lighting != binary2.two_sided_lighting) return false; const void* instBuffer1 = binary1.get_data(); diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Program/ProgramStateCache.h similarity index 99% rename from rpcs3/Emu/RSX/Common/ProgramStateCache.h rename to rpcs3/Emu/RSX/Program/ProgramStateCache.h index 02bffe509b..c34dcf97ba 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Program/ProgramStateCache.h @@ -1,7 +1,7 @@ #pragma once -#include "Emu/RSX/RSXFragmentProgram.h" -#include "Emu/RSX/RSXVertexProgram.h" +#include "RSXFragmentProgram.h" +#include "RSXVertexProgram.h" #include "Utilities/mutex.h" #include "util/logs.hpp" diff --git a/rpcs3/Emu/RSX/RSXFragmentProgram.h b/rpcs3/Emu/RSX/Program/RSXFragmentProgram.h similarity index 97% rename from rpcs3/Emu/RSX/RSXFragmentProgram.h rename to rpcs3/Emu/RSX/Program/RSXFragmentProgram.h index 91f07bff1b..b860a5d681 100644 --- a/rpcs3/Emu/RSX/RSXFragmentProgram.h +++ b/rpcs3/Emu/RSX/Program/RSXFragmentProgram.h @@ -1,7 +1,9 @@ #pragma once -#include "gcm_enums.h" -#include "util/types.hpp" +#include "program_util.h" + +#include +#include enum register_type { @@ -298,20 +300,17 @@ struct RSXFragmentProgram u32 ucode_length = 0; u32 total_length = 0; u32 ctrl = 0; - u16 unnormalized_coords = 0; - u16 redirected_textures = 0; - u16 shadow_textures = 0; bool two_sided_lighting = false; - u32 texture_dimensions = 0; u32 texcoord_control_mask = 0; - float texture_scale[16][4]{}; + rsx::fragment_program_texture_state texture_state; + rsx::fragment_program_texture_config texture_params; bool valid = false; rsx::texture_dimension_extended get_texture_dimension(u8 id) const { - return rsx::texture_dimension_extended{static_cast((texture_dimensions >> (id * 2)) & 0x3)}; + return rsx::texture_dimension_extended{static_cast((texture_state.texture_dimensions >> (id * 2)) & 0x3)}; } bool texcoord_is_2d(u8 index) const diff --git a/rpcs3/Emu/RSX/RSXVertexProgram.h b/rpcs3/Emu/RSX/Program/RSXVertexProgram.h similarity index 97% rename from rpcs3/Emu/RSX/RSXVertexProgram.h rename to rpcs3/Emu/RSX/Program/RSXVertexProgram.h index 7c568e47a0..92013bfde8 100644 --- a/rpcs3/Emu/RSX/RSXVertexProgram.h +++ b/rpcs3/Emu/RSX/Program/RSXVertexProgram.h @@ -1,7 +1,6 @@ #pragma once -#include "gcm_enums.h" -#include "util/types.hpp" +#include "program_util.h" #include #include @@ -235,8 +234,8 @@ struct RSXVertexProgram std::vector data; std::vector rsx_vertex_inputs; u32 output_mask; - u32 texture_dimensions; bool skip_vertex_input_check; + rsx::vertex_program_texture_state texture_state; u32 base_address; u32 entry; @@ -245,6 +244,6 @@ struct RSXVertexProgram rsx::texture_dimension_extended get_texture_dimension(u8 id) const { - return rsx::texture_dimension_extended{static_cast((texture_dimensions >> (id * 2)) & 0x3)}; + return rsx::texture_dimension_extended{static_cast((texture_state.texture_dimensions >> (id * 2)) & 0x3)}; } }; diff --git a/rpcs3/Emu/RSX/Common/ShaderInterpreter.h b/rpcs3/Emu/RSX/Program/ShaderInterpreter.h similarity index 83% rename from rpcs3/Emu/RSX/Common/ShaderInterpreter.h rename to rpcs3/Emu/RSX/Program/ShaderInterpreter.h index b316477f30..06a81501a7 100644 --- a/rpcs3/Emu/RSX/Common/ShaderInterpreter.h +++ b/rpcs3/Emu/RSX/Program/ShaderInterpreter.h @@ -24,7 +24,7 @@ namespace program_common static std::string get_vertex_interpreter() { const char* s = - #include "Interpreter/VertexInterpreter.glsl" + #include "../Common/Interpreter/VertexInterpreter.glsl" ; return s; } @@ -32,7 +32,7 @@ namespace program_common static std::string get_fragment_interpreter() { const char* s = - #include "Interpreter/FragmentInterpreter.glsl" + #include "../Common/Interpreter/FragmentInterpreter.glsl" ; return s; } diff --git a/rpcs3/Emu/RSX/Common/ShaderParam.h b/rpcs3/Emu/RSX/Program/ShaderParam.h similarity index 100% rename from rpcs3/Emu/RSX/Common/ShaderParam.h rename to rpcs3/Emu/RSX/Program/ShaderParam.h diff --git a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp b/rpcs3/Emu/RSX/Program/VertexProgramDecompiler.cpp similarity index 100% rename from rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp rename to rpcs3/Emu/RSX/Program/VertexProgramDecompiler.cpp diff --git a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h b/rpcs3/Emu/RSX/Program/VertexProgramDecompiler.h similarity index 99% rename from rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h rename to rpcs3/Emu/RSX/Program/VertexProgramDecompiler.h index 7e50d88df8..1ce4f96fd0 100644 --- a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h +++ b/rpcs3/Emu/RSX/Program/VertexProgramDecompiler.h @@ -1,5 +1,5 @@ #pragma once -#include "Emu/RSX/RSXVertexProgram.h" +#include "RSXVertexProgram.h" #include #include #include "ShaderParam.h" diff --git a/rpcs3/Emu/RSX/Common/program_state_cache2.hpp b/rpcs3/Emu/RSX/Program/program_state_cache2.hpp similarity index 100% rename from rpcs3/Emu/RSX/Common/program_state_cache2.hpp rename to rpcs3/Emu/RSX/Program/program_state_cache2.hpp diff --git a/rpcs3/Emu/RSX/Program/program_util.cpp b/rpcs3/Emu/RSX/Program/program_util.cpp new file mode 100644 index 0000000000..ea0e8d3bb0 --- /dev/null +++ b/rpcs3/Emu/RSX/Program/program_util.cpp @@ -0,0 +1,109 @@ +#include "stdafx.h" +#include "program_util.h" + +namespace rsx +{ + // Convert u16 to u32 + static u32 duplicate_and_extend(u16 bits) + { + u32 x = bits; + + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + return x | (x << 1); + } + + void fragment_program_texture_config::masked_transfer(void* dst, const void* src, u16 mask) + { + // Try to optimize for the very common case (first 4 slots used) + switch (mask) + { + case 0: + return; + case 1: + std::memcpy(dst, src, 16); return; + case 3: + std::memcpy(dst, src, 32); return; + case 7: + std::memcpy(dst, src, 48); return; + case 15: + std::memcpy(dst, src, 64); return; + default: + break; + }; + + const auto start = std::countr_zero(mask); + const auto end = 16 - std::countl_zero(mask); + const auto mem_offset = (start * 16); + const auto mem_size = (end - start) * 16; + std::memcpy(static_cast(dst) + mem_offset, reinterpret_cast(src) + mem_offset, mem_size); + } + + void fragment_program_texture_config::write_to(void* dst, u16 mask) + { + masked_transfer(dst, slots_, mask); + } + + void fragment_program_texture_config::load_from(const void* src, u16 mask) + { + masked_transfer(slots_, src, mask); + } + + void fragment_program_texture_state::clear(u32 index) + { + const u16 clear_mask = ~(static_cast(1 << index)); + unnormalized_coords &= clear_mask; + redirected_textures &= clear_mask; + shadow_textures &= clear_mask; + } + + void fragment_program_texture_state::import(const fragment_program_texture_state& other, u16 mask) + { + unnormalized_coords = other.unnormalized_coords & mask; + redirected_textures = other.redirected_textures & mask; + shadow_textures = other.shadow_textures & mask; + texture_dimensions = other.texture_dimensions & duplicate_and_extend(mask); + } + + void fragment_program_texture_state::set_dimension(texture_dimension_extended type, u32 index) + { + const auto offset = (index * 2); + const auto mask = 3 << offset; + texture_dimensions &= ~mask; + texture_dimensions |= static_cast(type) << offset; + } + + bool fragment_program_texture_state::operator == (const fragment_program_texture_state& other) const + { + return texture_dimensions == other.texture_dimensions && + redirected_textures == other.redirected_textures && + shadow_textures == other.shadow_textures && + unnormalized_coords == other.unnormalized_coords; + } + + void vertex_program_texture_state::clear(u32 /*index*/) + { + // Nothing to do yet + } + + void vertex_program_texture_state::import(const vertex_program_texture_state& other, u16 mask) + { + texture_dimensions = other.texture_dimensions & duplicate_and_extend(mask); + } + + void vertex_program_texture_state::set_dimension(texture_dimension_extended type, u32 index) + { + const auto offset = (index * 2); + const auto mask = 3 << offset; + texture_dimensions &= ~mask; + texture_dimensions |= static_cast(type) << offset; + } + + bool vertex_program_texture_state::operator == (const vertex_program_texture_state& other) const + { + return texture_dimensions == other.texture_dimensions; + } +} diff --git a/rpcs3/Emu/RSX/Program/program_util.h b/rpcs3/Emu/RSX/Program/program_util.h new file mode 100644 index 0000000000..836390ed89 --- /dev/null +++ b/rpcs3/Emu/RSX/Program/program_util.h @@ -0,0 +1,55 @@ +#pragma once + +#include "util/types.hpp" +#include "../gcm_enums.h" + +#include + +namespace rsx +{ +#pragma pack(push, 1) + struct fragment_program_texture_config + { + struct TIU_slot + { + float scale_x; + float scale_y; + u32 remap; + u32 control; + } + slots_[16]; // QT headers will collide with any variable named 'slots' because reasons + + template + TIU_slot& operator[](T index) { return slots_[index]; } + + void write_to(void* dst, u16 mask); + void load_from(const void* src, u16 mask); + + static void masked_transfer(void* dst, const void* src, u16 mask); + }; +#pragma pack(pop) + + struct fragment_program_texture_state + { + u32 texture_dimensions = 0; + u16 unnormalized_coords = 0; + u16 redirected_textures = 0; + u16 shadow_textures = 0; + u16 reserved = 0; + + void clear(u32 index); + void import(const fragment_program_texture_state& other, u16 mask); + void set_dimension(texture_dimension_extended type, u32 index); + bool operator == (const fragment_program_texture_state& other) const; + }; + + struct vertex_program_texture_state + { + u32 texture_dimensions = 0; + + void clear(u32 index); + void import(const vertex_program_texture_state& other, u16 mask); + void set_dimension(texture_dimension_extended type, u32 index); + bool operator == (const vertex_program_texture_state& other) const; + }; +} diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index b100c07c4a..9e3a56fd6a 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -5,7 +5,6 @@ #include "Emu/Cell/timers.hpp" #include "Common/BufferUtils.h" -#include "Common/GLSLCommon.h" #include "Common/texture_cache.h" #include "Common/surface_store.h" #include "Capture/rsx_capture.h" @@ -16,6 +15,7 @@ #include "Emu/Cell/lv2/sys_time.h" #include "Emu/Cell/Modules/cellGcmSys.h" #include "Overlays/overlay_perf_metrics.h" +#include "Program/GLSLCommon.h" #include "Utilities/date_time.h" #include "Utilities/span.h" #include "Utilities/StrUtil.h" @@ -854,19 +854,6 @@ namespace rsx stream_vector(dst + 4, 0u, fog_mode, std::bit_cast(wpos_scale), std::bit_cast(wpos_bias)); } - void thread::fill_fragment_texture_parameters(void* buffer, const RSXFragmentProgram& fragment_program) - { - // Copy only the relevant section - if (current_fp_metadata.referenced_textures_mask) - { - const auto start = std::countr_zero(current_fp_metadata.referenced_textures_mask); - const auto end = 16 - std::countl_zero(current_fp_metadata.referenced_textures_mask); - const auto mem_offset = (start * 16); - const auto mem_size = (end - start) * 16; - memcpy(static_cast(buffer) + mem_offset, reinterpret_cast(fragment_program.texture_scale) + mem_offset, mem_size); - } - } - u64 thread::timestamp() { const u64 freq = sys_time_get_timebase_frequency(); @@ -1571,6 +1558,7 @@ namespace rsx current_fragment_program.offset = program_offset + current_fp_metadata.program_start_offset; current_fragment_program.ucode_length = current_fp_metadata.program_ucode_length; current_fragment_program.total_length = current_fp_metadata.program_ucode_length + current_fp_metadata.program_start_offset; + current_fragment_program.texture_state.import(current_fp_texture_state, current_fp_metadata.referenced_textures_mask); current_fragment_program.valid = true; if (!(m_graphics_state & rsx::pipeline_state::fragment_program_state_dirty)) @@ -1610,6 +1598,8 @@ namespace rsx current_vertex_program // [out] Program object ); + current_vertex_program.texture_state.import(current_vp_texture_state, current_vp_metadata.referenced_textures_mask); + if (!(m_graphics_state & rsx::pipeline_state::vertex_program_state_dirty)) { // Verify current texture state is valid @@ -1653,9 +1643,12 @@ namespace rsx const auto &tex = rsx::method_registers.vertex_textures[i]; if (tex.enabled() && (current_vp_metadata.referenced_textures_mask & (1 << i))) { - current_vertex_program.texture_dimensions |= (static_cast(sampler_descriptors[i]->image_type) << (i << 1)); + current_vp_texture_state.clear(i); + current_vp_texture_state.set_dimension(sampler_descriptors[i]->image_type, i); } } + + current_vertex_program.texture_state.import(current_vp_texture_state, current_vp_metadata.referenced_textures_mask); } void thread::analyse_inputs_interleaved(vertex_input_layout& result) const @@ -1835,13 +1828,7 @@ namespace rsx current_fragment_program.ctrl = rsx::method_registers.shader_control() & (CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS | CELL_GCM_SHADER_CONTROL_DEPTH_EXPORT); current_fragment_program.texcoord_control_mask = rsx::method_registers.texcoord_control_mask(); - current_fragment_program.texture_dimensions = 0; - current_fragment_program.unnormalized_coords = 0; current_fragment_program.two_sided_lighting = rsx::method_registers.two_side_light_en(); - current_fragment_program.redirected_textures = 0; - current_fragment_program.shadow_textures = 0; - - memset(current_fragment_program.texture_scale, 0, sizeof(current_fragment_program.texture_scale)); if (method_registers.current_draw_clause.primitive == primitive_type::points && method_registers.point_sprite_enabled()) @@ -1857,14 +1844,15 @@ namespace rsx auto &tex = rsx::method_registers.fragment_textures[i]; if (tex.enabled()) { - current_fragment_program.texture_scale[i][0] = sampler_descriptors[i]->scale_x; - current_fragment_program.texture_scale[i][1] = sampler_descriptors[i]->scale_y; - current_fragment_program.texture_scale[i][2] = std::bit_cast(tex.remap()); + current_fragment_program.texture_params[i].scale_x = sampler_descriptors[i]->scale_x; + current_fragment_program.texture_params[i].scale_y = sampler_descriptors[i]->scale_y; + current_fragment_program.texture_params[i].remap = tex.remap(); m_graphics_state |= rsx::pipeline_state::fragment_texture_state_dirty; u32 texture_control = 0; - current_fragment_program.texture_dimensions |= (static_cast(sampler_descriptors[i]->image_type) << (i << 1)); + current_fp_texture_state.clear(i); + current_fp_texture_state.set_dimension(sampler_descriptors[i]->image_type, i); if (tex.alpha_kill_enabled()) { @@ -1877,7 +1865,7 @@ namespace rsx const u32 format = raw_format & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); if (raw_format & CELL_GCM_TEXTURE_UN) - current_fragment_program.unnormalized_coords |= (1 << i); + current_fp_texture_state.unnormalized_coords |= (1 << i); if (sampler_descriptors[i]->format_class != RSX_FORMAT_CLASS_COLOR) { @@ -1897,7 +1885,7 @@ namespace rsx case CELL_GCM_TEXTURE_D8R8G8B8: { // Emulate bitcast in shader - current_fragment_program.redirected_textures |= (1 << i); + current_fp_texture_state.redirected_textures |= (1 << i); const auto float_en = (sampler_descriptors[i]->format_class == RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32)? 1 : 0; texture_control |= (float_en << texture_control_bits::DEPTH_FLOAT); break; @@ -1918,7 +1906,7 @@ namespace rsx compare_mode < rsx::comparison_function::always && compare_mode > rsx::comparison_function::never) { - current_fragment_program.shadow_textures |= (1 << i); + current_fp_texture_state.shadow_textures |= (1 << i); } break; } @@ -1995,10 +1983,13 @@ namespace rsx #ifdef __APPLE__ texture_control |= (sampler_descriptors[i]->encoded_component_map() << 16); #endif - current_fragment_program.texture_scale[i][3] = std::bit_cast(texture_control); + current_fragment_program.texture_params[i].control = texture_control; } } + // Update texture configuration + current_fragment_program.texture_state.import(current_fp_texture_state, current_fp_metadata.referenced_textures_mask); + //Sanity checks if (current_fragment_program.ctrl & CELL_GCM_SHADER_CONTROL_DEPTH_EXPORT) { diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 8d488f1b84..e60a97f823 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -11,10 +11,10 @@ #include "rsx_cache.h" #include "RSXFIFO.h" #include "RSXOffload.h" -#include "RSXVertexProgram.h" -#include "RSXFragmentProgram.h" #include "rsx_utils.h" #include "Common/texture_cache_types.h" +#include "Program/RSXVertexProgram.h" +#include "Program/RSXFragmentProgram.h" #include "Utilities/Thread.h" #include "Utilities/geometry.h" @@ -739,6 +739,9 @@ namespace rsx RSXVertexProgram current_vertex_program = {}; RSXFragmentProgram current_fragment_program = {}; + vertex_program_texture_state current_vp_texture_state = {}; + fragment_program_texture_state current_fp_texture_state = {}; + // Runs shader prefetch and resolves pipeline status flags void analyse_current_rsx_pipeline(); @@ -911,11 +914,6 @@ namespace rsx */ void fill_fragment_state_buffer(void* buffer, const RSXFragmentProgram& fragment_program); - /** - * Fill buffer with fragment texture parameter constants (texture matrix) - */ - void fill_fragment_texture_parameters(void* buffer, const RSXFragmentProgram& fragment_program); - /** * Notify that a section of memory has been mapped * If there is a notify_memory_unmapped request on this range yet to be handled, diff --git a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.h b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.h index e1f85cb27e..5a28cfd86f 100644 --- a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.h +++ b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.h @@ -1,5 +1,5 @@ #pragma once -#include "../Common/GLSLTypes.h" +#include "../Program/GLSLTypes.h" namespace vk { diff --git a/rpcs3/Emu/RSX/VK/VKDraw.cpp b/rpcs3/Emu/RSX/VK/VKDraw.cpp index 83663e999e..a1527708b3 100644 --- a/rpcs3/Emu/RSX/VK/VKDraw.cpp +++ b/rpcs3/Emu/RSX/VK/VKDraw.cpp @@ -441,7 +441,7 @@ void VKGSRender::bind_texture_env() ::glsl::program_domain::glsl_fragment_program, m_current_frame->descriptor_set); - if (current_fragment_program.redirected_textures & (1 << i)) + if (current_fragment_program.texture_state.redirected_textures & (1 << i)) { // Stencil mirror required auto root_image = static_cast(view->image()); @@ -473,7 +473,7 @@ void VKGSRender::bind_texture_env() ::glsl::program_domain::glsl_fragment_program, m_current_frame->descriptor_set); - if (current_fragment_program.redirected_textures & (1 << i)) + if (current_fragment_program.texture_state.redirected_textures & (1 << i)) { m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(*m_current_command_buffer, view_type)->value, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, i, diff --git a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp index adb0c060b0..fb868cd695 100644 --- a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp @@ -4,7 +4,7 @@ #include "VKHelpers.h" #include "vkutils/device.h" #include "Emu/system_config.h" -#include "../Common/GLSLCommon.h" +#include "../Program/GLSLCommon.h" #include "../GCM.h" std::string VKFragmentDecompilerThread::getFloatTypeName(usz elementCount) diff --git a/rpcs3/Emu/RSX/VK/VKFragmentProgram.h b/rpcs3/Emu/RSX/VK/VKFragmentProgram.h index 8252a45037..787f38ec05 100644 --- a/rpcs3/Emu/RSX/VK/VKFragmentProgram.h +++ b/rpcs3/Emu/RSX/VK/VKFragmentProgram.h @@ -1,7 +1,6 @@ #pragma once -#include "../Common/FragmentProgramDecompiler.h" -#include "../Common/GLSLTypes.h" -#include "Emu/RSX/RSXFragmentProgram.h" +#include "../Program/FragmentProgramDecompiler.h" +#include "../Program/GLSLTypes.h" #include "VulkanAPI.h" #include "VKProgramPipeline.h" #include "vkutils/pipeline_binding_table.h" diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index cd68714fc9..edcfb53570 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -17,7 +17,7 @@ #include "Emu/RSX/rsx_methods.h" #include "Emu/Memory/vm_locking.h" -#include "../Common/program_state_cache2.hpp" +#include "../Program/program_state_cache2.hpp" #include "util/asm.hpp" @@ -1655,7 +1655,7 @@ bool VKGSRender::load_program() // Load current program from buffer vertex_program.skip_vertex_input_check = true; - fragment_program.unnormalized_coords = 0; + fragment_program.texture_state.unnormalized_coords = 0; m_program = m_prog_buffer->get_graphics_pipeline(vertex_program, fragment_program, properties, shadermode != shader_mode::recompiler, true, pipeline_layout); @@ -1791,7 +1791,7 @@ void VKGSRender::load_program_env() auto mem = m_fragment_texture_params_ring_info.alloc<256>(256); auto buf = m_fragment_texture_params_ring_info.map(mem, 256); - fill_fragment_texture_parameters(buf, current_fragment_program); + current_fragment_program.texture_params.write_to(buf, current_fp_metadata.referenced_textures_mask); m_fragment_texture_params_ring_info.unmap(); m_fragment_texture_params_buffer_info = { m_fragment_texture_params_ring_info.heap->value, mem, 256 }; } @@ -1841,7 +1841,7 @@ void VKGSRender::load_program_env() // Control mask const auto control_masks = reinterpret_cast(fp_buf); control_masks[0] = rsx::method_registers.shader_control(); - control_masks[1] = current_fragment_program.texture_dimensions; + control_masks[1] = current_fragment_program.texture_state.texture_dimensions; std::memcpy(fp_buf + 16, current_fragment_program.get_data(), current_fragment_program.ucode_length); m_fragment_instructions_buffer.unmap(); diff --git a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h index f877c0409a..2b73de6faf 100644 --- a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h +++ b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h @@ -1,9 +1,9 @@ #pragma once #include "VKVertexProgram.h" #include "VKFragmentProgram.h" -#include "../Common/ProgramStateCache.h" #include "VKRenderPass.h" #include "VKPipelineCompiler.h" +#include "../Program/ProgramStateCache.h" #include "util/fnv_hash.hpp" diff --git a/rpcs3/Emu/RSX/VK/VKProgramPipeline.h b/rpcs3/Emu/RSX/VK/VKProgramPipeline.h index 81e36800ef..f6d8d94738 100644 --- a/rpcs3/Emu/RSX/VK/VKProgramPipeline.h +++ b/rpcs3/Emu/RSX/VK/VKProgramPipeline.h @@ -2,7 +2,7 @@ #include "VulkanAPI.h" #include "VKCommonDecompiler.h" -#include "../Common/GLSLTypes.h" +#include "../Program/GLSLTypes.h" #include #include diff --git a/rpcs3/Emu/RSX/VK/VKShaderInterpreter.cpp b/rpcs3/Emu/RSX/VK/VKShaderInterpreter.cpp index fb0118654b..f39aca242a 100644 --- a/rpcs3/Emu/RSX/VK/VKShaderInterpreter.cpp +++ b/rpcs3/Emu/RSX/VK/VKShaderInterpreter.cpp @@ -4,8 +4,8 @@ #include "VKFragmentProgram.h" #include "VKGSRender.h" -#include "../Common/GLSLCommon.h" -#include "../Common/ShaderInterpreter.h" +#include "../Program/GLSLCommon.h" +#include "../Program/ShaderInterpreter.h" #include "../rsx_methods.h" namespace vk diff --git a/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp b/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp index 9e4e3324e3..0d7576a34a 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp @@ -4,7 +4,7 @@ #include "VKCommonDecompiler.h" #include "VKHelpers.h" #include "vkutils/device.h" -#include "../Common/GLSLCommon.h" +#include "../Program/GLSLCommon.h" std::string VKVertexDecompilerThread::getFloatTypeName(usz elementCount) diff --git a/rpcs3/Emu/RSX/VK/VKVertexProgram.h b/rpcs3/Emu/RSX/VK/VKVertexProgram.h index 044249ddfd..5170f7abc7 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexProgram.h +++ b/rpcs3/Emu/RSX/VK/VKVertexProgram.h @@ -1,6 +1,5 @@ #pragma once -#include "../Common/VertexProgramDecompiler.h" -#include "Emu/RSX/RSXVertexProgram.h" +#include "../Program/VertexProgramDecompiler.h" #include "Utilities/Thread.h" #include "VulkanAPI.h" #include "VKProgramPipeline.h" diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index a09913facf..cde688c70d 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -2,7 +2,7 @@ #include "Utilities/File.h" #include "Utilities/lockless.h" #include "Utilities/Thread.h" -#include "Common/ProgramStateCache.h" +#include "Program/ProgramStateCache.h" #include "Emu/System.h" #include "Emu/cache_utils.hpp" #include "Common/texture_cache_checker.h" @@ -358,7 +358,7 @@ namespace rsx pipeline = data.pipeline_properties; vp.output_mask = data.vp_ctrl; - vp.texture_dimensions = data.vp_texture_dimensions; + vp.texture_state.texture_dimensions = data.vp_texture_dimensions; vp.base_address = data.vp_base_address; vp.entry = data.vp_entry; @@ -377,12 +377,12 @@ namespace rsx } fp.ctrl = data.fp_ctrl; - fp.texture_dimensions = data.fp_texture_dimensions; + fp.texture_state.texture_dimensions = data.fp_texture_dimensions; + fp.texture_state.unnormalized_coords = data.fp_unnormalized_coords; + fp.texture_state.shadow_textures = data.fp_shadow_textures; + fp.texture_state.redirected_textures = data.fp_redirected_textures; fp.texcoord_control_mask = data.fp_texcoord_control; - fp.unnormalized_coords = data.fp_unnormalized_coords; fp.two_sided_lighting = !!(data.fp_lighting_flags & 0x1); - fp.shadow_textures = data.fp_shadow_textures; - fp.redirected_textures = data.fp_redirected_textures; return result; } @@ -396,7 +396,7 @@ namespace rsx data_block.pipeline_storage_hash = m_storage.get_hash(pipeline); data_block.vp_ctrl = vp.output_mask; - data_block.vp_texture_dimensions = vp.texture_dimensions; + data_block.vp_texture_dimensions = vp.texture_state.texture_dimensions; data_block.vp_base_address = vp.base_address; data_block.vp_entry = vp.entry; @@ -421,12 +421,12 @@ namespace rsx } data_block.fp_ctrl = fp.ctrl; - data_block.fp_texture_dimensions = fp.texture_dimensions; + data_block.fp_texture_dimensions = fp.texture_state.texture_dimensions; data_block.fp_texcoord_control = fp.texcoord_control_mask; - data_block.fp_unnormalized_coords = fp.unnormalized_coords; + data_block.fp_unnormalized_coords = fp.texture_state.unnormalized_coords; data_block.fp_lighting_flags = u16(fp.two_sided_lighting); - data_block.fp_shadow_textures = fp.shadow_textures; - data_block.fp_redirected_textures = fp.redirected_textures; + data_block.fp_shadow_textures = fp.texture_state.shadow_textures; + data_block.fp_redirected_textures = fp.texture_state.redirected_textures; return data_block; } diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 392d660097..14d6070594 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -77,6 +77,8 @@ + + @@ -335,15 +337,14 @@ - - + + - - - + + - + NotUsing @@ -457,7 +458,10 @@ - + + + + @@ -682,7 +686,7 @@ - + @@ -708,23 +712,22 @@ - + - - - + + - + - + - + - + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 0d2e623621..d7585c43d0 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -76,6 +76,9 @@ {84c0e40e-efb6-4cfd-b2f5-13c720b09105} + + {d055ca32-157a-4d8c-895e-29509858fcb0} + @@ -150,9 +153,6 @@ Emu\GPU\RSX - - Emu\GPU\RSX - Utilities @@ -162,9 +162,6 @@ Utilities - - Emu\GPU\RSX - Emu\Cell @@ -174,12 +171,6 @@ Utilities - - Emu\GPU\RSX\Common - - - Emu\GPU\RSX\Common - Utilities @@ -198,9 +189,6 @@ Emu\GPU\RSX\Common - - Emu\GPU\RSX\Common - Emu\GPU\RSX\Null @@ -210,9 +198,6 @@ Emu\GPU\RSX - - Emu\GPU\RSX\Common - Emu\GPU\RSX\Common @@ -990,6 +975,24 @@ Emu + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + + + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + @@ -1106,8 +1109,8 @@ Emu\GPU\RSX - - Emu\GPU\RSX + + Emu\GPU\RSX\Program Emu\GPU\RSX @@ -1115,11 +1118,11 @@ Emu\GPU\RSX - - Emu\GPU\RSX + + Emu\GPU\RSX\Program - - Emu\GPU\RSX + + Emu\GPU\RSX\Program Emu\GPU\RSX @@ -1163,21 +1166,6 @@ Utilities - - Emu\GPU\RSX\Common - - - Emu\GPU\RSX\Common - - - Emu\GPU\RSX\Common - - - Emu\GPU\RSX\Common - - - Emu\GPU\RSX\Common - Emu\Cell @@ -1634,9 +1622,6 @@ Utilities - - Emu\GPU\RSX\Common - Utilities @@ -1859,9 +1844,6 @@ Utilities - - Emu\GPU\RSX\Common - Emu\Audio\FAudio @@ -1940,6 +1922,34 @@ Emu + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + + + Emu\GPU\RSX\Program + diff --git a/rpcs3/rpcs3qt/cg_disasm_window.cpp b/rpcs3/rpcs3qt/cg_disasm_window.cpp index a052ff3480..9cc62f881a 100644 --- a/rpcs3/rpcs3qt/cg_disasm_window.cpp +++ b/rpcs3/rpcs3qt/cg_disasm_window.cpp @@ -9,7 +9,7 @@ #include #include -#include "Emu/RSX/CgBinaryProgram.h" +#include "Emu/RSX/Program/CgBinaryProgram.h" LOG_CHANNEL(gui_log, "GUI");