From 6221fecf3bd584d1b036b2e9bd76ffd903192b5d Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Thu, 10 Dec 2015 02:52:27 +0100 Subject: [PATCH] common/d3d12/gl: Start implementing cubemap sampling --- rpcs3/Emu/RSX/CgBinaryProgram.h | 3 +- .../RSX/Common/FragmentProgramDecompiler.cpp | 41 ++++++++++++++++--- .../RSX/Common/FragmentProgramDecompiler.h | 3 +- rpcs3/Emu/RSX/Common/ShaderParam.h | 2 + rpcs3/Emu/RSX/Common/TextureUtils.cpp | 9 ++++ rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp | 4 ++ .../D3D12/D3D12FragmentProgramDecompiler.cpp | 28 +++++++++---- .../D3D12/D3D12FragmentProgramDecompiler.h | 2 +- rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp | 11 +++++ rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h | 4 +- rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp | 16 ++++++-- rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp | 4 ++ rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp | 4 +- rpcs3/Emu/RSX/GL/GLFragmentProgram.h | 7 ++-- rpcs3/Emu/RSX/GL/GLGSRender.cpp | 10 +++++ rpcs3/Emu/RSX/GL/GLProgramBuffer.h | 2 +- rpcs3/Emu/RSX/RSXFragmentProgram.h | 8 ++++ 17 files changed, 130 insertions(+), 28 deletions(-) diff --git a/rpcs3/Emu/RSX/CgBinaryProgram.h b/rpcs3/Emu/RSX/CgBinaryProgram.h index 80c2a92dd2..5d357e47dd 100644 --- a/rpcs3/Emu/RSX/CgBinaryProgram.h +++ b/rpcs3/Emu/RSX/CgBinaryProgram.h @@ -325,7 +325,8 @@ public: auto& vmfprog = vm::ps3::_ref(ptr + vmprog.program); u32 size; u32 ctrl = (vmfprog.outputFromH0 ? 0 : 0x40) | (vmfprog.depthReplace ? 0xe : 0); - GLFragmentDecompilerThread(m_glsl_shader, param_array, ptr + vmprog.ucode, size, ctrl).Task(); + std::vector td; + GLFragmentDecompilerThread(m_glsl_shader, param_array, ptr + vmprog.ucode, size, ctrl, td).Task(); vm::close(); } } diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp index 0831194f15..2f05e08db6 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp @@ -5,12 +5,13 @@ #include "FragmentProgramDecompiler.h" -FragmentProgramDecompiler::FragmentProgramDecompiler(u32 addr, u32& size, u32 ctrl) : +FragmentProgramDecompiler::FragmentProgramDecompiler(u32 addr, u32& size, u32 ctrl, const std::vector &texture_dimensions) : m_addr(addr), m_size(size), m_const_index(0), m_location(0), - m_ctrl(ctrl) + m_ctrl(ctrl), + m_texture_dimensions(texture_dimensions) { m_size = 0; } @@ -128,7 +129,7 @@ std::string FragmentProgramDecompiler::AddConst() std::string FragmentProgramDecompiler::AddTex() { - return m_parr.AddParam(PF_PARAM_UNIFORM, "sampler2D", std::string("tex") + std::to_string(dst.tex_num)); + return m_parr.AddParam(PF_PARAM_UNIFORM, (m_texture_dimensions[dst.tex_num] == texture_dimension::texture_dimension_cubemap) ? "samplerCube" : "sampler2D", std::string("tex") + std::to_string(dst.tex_num)); } std::string FragmentProgramDecompiler::Format(const std::string& code) @@ -416,9 +417,39 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode) case RSX_FP_OPCODE_DDY: SetDst(getFunction(FUNCTION::FUNCTION_DFDY)); return true; case RSX_FP_OPCODE_NRM: SetDst("normalize($0)"); return true; case RSX_FP_OPCODE_BEM: LOG_ERROR(RSX, "Unimplemented TEX_SRB instruction: BEM"); return true; - case RSX_FP_OPCODE_TEX: SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE)); return true; + case RSX_FP_OPCODE_TEX: + if (dst.tex_num >= m_texture_dimensions.size()) + { + SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE)); + return true; + } + switch (m_texture_dimensions[dst.tex_num]) + { + case texture_dimension::texture_dimension_2d: + SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE)); + return true; + case texture_dimension::texture_dimension_cubemap: + SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_CUBE_SAMPLE)); + return true; + } + return false; case RSX_FP_OPCODE_TEXBEM: SetDst("texture($t, $0.xy, $1.x)"); return true; - case RSX_FP_OPCODE_TXP: SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE_PROJ)); return true; //TODO: More testing (Sonic The Hedgehog (NPUB-30442/NPEB-00478) and The Simpsons Arcade Game (NPUB30563)) + case RSX_FP_OPCODE_TXP: + if (dst.tex_num >= m_texture_dimensions.size()) + { + SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE_PROJ)); + return true; + } + switch (m_texture_dimensions[dst.tex_num]) + { + case texture_dimension::texture_dimension_2d: + SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE_PROJ)); + return true; + case texture_dimension::texture_dimension_cubemap: + SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_CUBE_SAMPLE_PROJ)); + return true; + } + return false; case RSX_FP_OPCODE_TXPBEM: SetDst("textureProj($t, $0.xyz, $1.x)"); return true; case RSX_FP_OPCODE_TXD: LOG_ERROR(RSX, "Unimplemented TEX_SRB instruction: TXD"); return true; case RSX_FP_OPCODE_TXB: SetDst("texture($t, $0.xy, $1.x)"); return true; diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h index a6f5d9de73..6294db0e5f 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h @@ -22,6 +22,7 @@ class FragmentProgramDecompiler std::string main; u32 m_addr; u32& m_size; + const std::vector m_texture_dimensions; u32 m_const_index; u32 m_offset; u32 m_location; @@ -107,6 +108,6 @@ protected: virtual void insertMainEnd(std::stringstream &OS) = 0; public: ParamArray m_parr; - FragmentProgramDecompiler(u32 addr, u32& size, u32 ctrl); + FragmentProgramDecompiler(u32 addr, u32& size, u32 ctrl, const std::vector &texture_dimensions); std::string Decompile(); }; diff --git a/rpcs3/Emu/RSX/Common/ShaderParam.h b/rpcs3/Emu/RSX/Common/ShaderParam.h index cfeb5c5911..69443dd6cb 100644 --- a/rpcs3/Emu/RSX/Common/ShaderParam.h +++ b/rpcs3/Emu/RSX/Common/ShaderParam.h @@ -15,6 +15,8 @@ enum class FUNCTION { FUNCTION_DFDY, FUNCTION_TEXTURE_SAMPLE, FUNCTION_TEXTURE_SAMPLE_PROJ, + FUNCTION_TEXTURE_CUBE_SAMPLE, + FUNCTION_TEXTURE_CUBE_SAMPLE_PROJ, }; enum class COMPARE { diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index fae7e941d0..6ebdeba724 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -115,6 +115,13 @@ struct texel_16bX4_format { } }; +/** + * Texture upload template. + * The template iterates over all depth (including cubemap) and over all mipmaps. + * The alignment is 256 for mipmap levels and 512 for depth (TODO: make this customisable for Vulkan ?) + * The template takes a struct with a "copy_mipmap_level" static function that copy the given mipmap level and returns the offset to add to the src buffer for next + * mipmap level (to allow same code for packed/non packed texels) + */ template std::vector copy_texture_data(void *dst, const void *src, size_t widthInBlock, size_t heightInBlock, size_t depth, size_t mipmapCount) noexcept { @@ -141,6 +148,7 @@ std::vector copy_texture_data(void *dst, const void *src, size_ miplevel_height_in_block = MAX2(miplevel_height_in_block / 2, 1); miplevel_width_in_block = MAX2(miplevel_width_in_block / 2, 1); } + offsetInSrc = align(offsetInSrc, 128); } return Result; } @@ -249,6 +257,7 @@ std::vector upload_placed_texture(const rsx::texture &texture, { size_t w = texture.width(), h = texture.height(); size_t depth = texture.depth(); + if (texture.cubemap()) depth *= 6; int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp b/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp index 786c75ff9b..1c8f7e3c05 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp @@ -46,6 +46,10 @@ std::string getFunctionImp(FUNCTION f) return "$t.Sample($tsampler, $0.xy * $t_scale)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLE_PROJ: return "$t.Sample($tsampler, ($0.xy / $0.z) * $t_scale)"; + case FUNCTION::FUNCTION_TEXTURE_CUBE_SAMPLE: + return "$t.Sample($tsampler, $0.xyz)"; + case FUNCTION::FUNCTION_TEXTURE_CUBE_SAMPLE_PROJ: + return "$t.Sample($tsampler, ($0.xyz / $0.w))"; case FUNCTION::FUNCTION_DFDX: return "ddx($0)"; case FUNCTION::FUNCTION_DFDY: diff --git a/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp index 8e5daf93ee..ddd83875d5 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp @@ -7,8 +7,8 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" -D3D12FragmentDecompiler::D3D12FragmentDecompiler(u32 addr, u32& size, u32 ctrl) : - FragmentProgramDecompiler(addr, size, ctrl) +D3D12FragmentDecompiler::D3D12FragmentDecompiler(u32 addr, u32& size, u32 ctrl, const std::vector &texture_dimensions) : + FragmentProgramDecompiler(addr, size, ctrl, texture_dimensions) { } @@ -110,7 +110,7 @@ void D3D12FragmentDecompiler::insertConstants(std::stringstream & OS) OS << "{" << std::endl; for (ParamType PT : m_parr.params[PF_PARAM_UNIFORM]) { - if (PT.type == "sampler2D") + if (PT.type == "sampler2D" || PT.type == "samplerCube") continue; for (ParamItem PI : PT.items) OS << " " << PT.type << " " << PI.name << ";" << std::endl; @@ -119,13 +119,23 @@ void D3D12FragmentDecompiler::insertConstants(std::stringstream & OS) for (ParamType PT : m_parr.params[PF_PARAM_UNIFORM]) { - if (PT.type != "sampler2D") - continue; - for (ParamItem PI : PT.items) + if (PT.type == "sampler2D") { - size_t textureIndex = atoi(PI.name.data() + 3); - OS << "Texture2D " << PI.name << " : register(t" << textureIndex << ");" << std::endl; - OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");" << std::endl; + for (ParamItem PI : PT.items) + { + size_t textureIndex = atoi(PI.name.data() + 3); + OS << "Texture2D " << PI.name << " : register(t" << textureIndex << ");" << std::endl; + OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");" << std::endl; + } + } + else if (PT.type == "samplerCube") + { + for (ParamItem PI : PT.items) + { + size_t textureIndex = atoi(PI.name.data() + 3); + OS << "TextureCube " << PI.name << " : register(t" << textureIndex << ");" << std::endl; + OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");" << std::endl; + } } } } diff --git a/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.h b/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.h index bbba1ea8a7..29882f8126 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.h @@ -20,5 +20,5 @@ protected: virtual void insertMainStart(std::stringstream &OS) override; virtual void insertMainEnd(std::stringstream &OS) override; public: - D3D12FragmentDecompiler(u32 addr, u32& size, u32 ctrl); + D3D12FragmentDecompiler(u32 addr, u32& size, u32 ctrl, const std::vector &texture_dimensions); }; diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp index 45f7e97928..89392c0b96 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp @@ -56,6 +56,17 @@ bool D3D12GSRender::load_program() fragment_program.offset = shader_program & ~0x3; fragment_program.addr = rsx::get_address(fragment_program.offset, (shader_program & 0x3) - 1); fragment_program.ctrl = rsx::method_registers[NV4097_SET_SHADER_CONTROL]; + fragment_program.texture_dimensions.clear(); + + for (u32 i = 0; i < rsx::limits::textures_count; ++i) + { + if (!textures[i].enabled()) + fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_2d); + else if (textures[i].cubemap()) + fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_cubemap); + else + fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_2d); + } D3D12PipelineProperties prop = {}; prop.Topology = get_primitive_topology_type(draw_mode); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h index ecfe56aa92..39c5663984 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h @@ -147,7 +147,7 @@ struct D3D12Traits static void RecompileFragmentProgram(RSXFragmentProgram *RSXFP, FragmentProgramData& fragmentProgramData, size_t ID) { - D3D12FragmentDecompiler FS(RSXFP->addr, RSXFP->size, RSXFP->ctrl); + D3D12FragmentDecompiler FS(RSXFP->addr, RSXFP->size, RSXFP->ctrl, RSXFP->texture_dimensions); const std::string &shader = FS.Decompile(); fragmentProgramData.Compile(shader, Shader::SHADER_TYPE::SHADER_TYPE_FRAGMENT); fragmentProgramData.m_textureCount = 0; @@ -155,7 +155,7 @@ struct D3D12Traits { for (const ParamItem PI : PT.items) { - if (PT.type == "sampler2D") + if (PT.type == "sampler2D" || PT.type == "samplerCube") { size_t texture_unit = atoi(PI.name.c_str() + 3); fragmentProgramData.m_textureCount = std::max(texture_unit + 1, fragmentProgramData.m_textureCount); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp index ab3d4c1ec9..09330ae770 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp @@ -52,6 +52,8 @@ ComPtr upload_single_texture( data_heap &texture_buffer_heap) { size_t w = texture.width(), h = texture.height(); + size_t depth = texture.depth(); + if (texture.cubemap()) depth *= 6; int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); DXGI_FORMAT dxgi_format = get_texture_format(format); @@ -70,7 +72,7 @@ ComPtr upload_single_texture( ThrowIfFailed(device->CreateCommittedResource( &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT), D3D12_HEAP_FLAG_NONE, - &CD3DX12_RESOURCE_DESC::Tex2D(dxgi_format, (UINT)w, (UINT)h, 1, texture.mipmap()), + &CD3DX12_RESOURCE_DESC::Tex2D(dxgi_format, (UINT)w, (UINT)h, depth, texture.mipmap()), D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(result.GetAddressOf()) @@ -174,9 +176,17 @@ void D3D12GSRender::upload_and_bind_textures(ID3D12GraphicsCommandList *command_ } D3D12_SHADER_RESOURCE_VIEW_DESC shared_resource_view_desc = {}; - shared_resource_view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; + if (textures[i].cubemap()) + { + shared_resource_view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE; + shared_resource_view_desc.TextureCube.MipLevels = textures[i].mipmap(); + } + else + { + shared_resource_view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; + shared_resource_view_desc.Texture2D.MipLevels = textures[i].mipmap(); + } shared_resource_view_desc.Format = get_texture_format(format); - shared_resource_view_desc.Texture2D.MipLevels = textures[i].mipmap(); switch (format) { diff --git a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp index c4fb1c0d1d..afa7be3b7c 100644 --- a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp @@ -44,6 +44,10 @@ std::string getFunctionImpl(FUNCTION f) return "texture($t, $0.xy)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLE_PROJ: return "textureProj($t, $0.xyz, $1.x)"; // Note: $1.x is bias + case FUNCTION::FUNCTION_TEXTURE_CUBE_SAMPLE: + return "texture($t, $0.xyz)"; + case FUNCTION::FUNCTION_TEXTURE_CUBE_SAMPLE_PROJ: + return "textureProj($t, $0.xyzw, $1.x)"; // Note: $1.x is bias case FUNCTION::FUNCTION_DFDX: return "dFdx($0)"; case FUNCTION::FUNCTION_DFDY: diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp index 2bf09ea511..4e7afca038 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp @@ -156,9 +156,9 @@ GLFragmentProgram::~GLFragmentProgram() // } //} -void GLFragmentProgram::Decompile(RSXFragmentProgram& prog) +void GLFragmentProgram::Decompile(RSXFragmentProgram& prog, const std::vector &td) { - GLFragmentDecompilerThread decompiler(shader, parr, prog.addr, prog.size, prog.ctrl); + GLFragmentDecompilerThread decompiler(shader, parr, prog.addr, prog.size, prog.ctrl, td); decompiler.Task(); for (const ParamType& PT : decompiler.m_parr.params[PF_PARAM_UNIFORM]) { diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.h b/rpcs3/Emu/RSX/GL/GLFragmentProgram.h index ad20788ea5..4a1f07c03d 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.h +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.h @@ -9,8 +9,8 @@ struct GLFragmentDecompilerThread : public FragmentProgramDecompiler std::string& m_shader; ParamArray& m_parrDummy; public: - GLFragmentDecompilerThread(std::string& shader, ParamArray& parr, u32 addr, u32& size, u32 ctrl) - : FragmentProgramDecompiler(addr, size, ctrl) + GLFragmentDecompilerThread(std::string& shader, ParamArray& parr, u32 addr, u32& size, u32 ctrl, const std::vector &texture_dimensions) + : FragmentProgramDecompiler(addr, size, ctrl, texture_dimensions) , m_shader(shader) , m_parrDummy(parr) { @@ -49,8 +49,9 @@ public: /** * Decompile a fragment shader located in the PS3's Memory. This function operates synchronously. * @param prog RSXShaderProgram specifying the location and size of the shader in memory + * @param td texture dimensions of input textures */ - void Decompile(RSXFragmentProgram& prog); + void Decompile(RSXFragmentProgram& prog, const std::vector &td); /** Compile the decompiled fragment shader into a format we can use with OpenGL. */ void Compile(); diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index e4c9b1f8b9..df978c95d7 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -1231,6 +1231,16 @@ bool GLGSRender::load_program() fragment_program.addr = rsx::get_address(fragment_program.offset, (shader_program & 0x3) - 1); fragment_program.ctrl = rsx::method_registers[NV4097_SET_SHADER_CONTROL]; + for (u32 i = 0; i < rsx::limits::textures_count; ++i) + { + if (!textures[i].enabled()) + fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_2d); + else if (textures[i].cubemap()) + fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_cubemap); + else + fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_2d); + } + __glcheck m_program = m_prog_buffer.getGraphicPipelineState(&vertex_program, &fragment_program, nullptr, nullptr); __glcheck m_program->use(); diff --git a/rpcs3/Emu/RSX/GL/GLProgramBuffer.h b/rpcs3/Emu/RSX/GL/GLProgramBuffer.h index 28652bf975..39df0b9fd6 100644 --- a/rpcs3/Emu/RSX/GL/GLProgramBuffer.h +++ b/rpcs3/Emu/RSX/GL/GLProgramBuffer.h @@ -14,7 +14,7 @@ struct GLTraits static void RecompileFragmentProgram(RSXFragmentProgram *RSXFP, FragmentProgramData& fragmentProgramData, size_t ID) { - fragmentProgramData.Decompile(*RSXFP); + fragmentProgramData.Decompile(*RSXFP, RSXFP->texture_dimensions); fragmentProgramData.Compile(); //checkForGlError("m_fragment_prog.Compile"); diff --git a/rpcs3/Emu/RSX/RSXFragmentProgram.h b/rpcs3/Emu/RSX/RSXFragmentProgram.h index ac2f8a69e9..1bde687d92 100644 --- a/rpcs3/Emu/RSX/RSXFragmentProgram.h +++ b/rpcs3/Emu/RSX/RSXFragmentProgram.h @@ -204,12 +204,20 @@ static const std::string rsx_fp_op_names[] = "NULL", "BRK", "CAL", "IFE", "LOOP", "REP", "RET" }; +enum class texture_dimension +{ + texture_dimension_2d, + texture_dimension_2d_array, + texture_dimension_cubemap, +}; + struct RSXFragmentProgram { u32 size; u32 addr; u32 offset; u32 ctrl; + std::vector texture_dimensions; RSXFragmentProgram() : size(0)