From 9d25b88368f220a40caeaea396d8edf50a55df71 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 22 Feb 2023 13:09:37 +0100 Subject: [PATCH] Latte: Add support for MIN_DX10 shader instruction --- src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 1 - src/Cafe/HW/Latte/Core/LatteShader.cpp | 2 ++ .../HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp | 1 + .../LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp | 1 + .../LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp | 9 +++++---- .../LegacyShaderDecompiler/LatteDecompilerInstructions.h | 1 + src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp | 2 -- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index 6b794de9..9b996590 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -588,7 +588,6 @@ bool LatteMRT::UpdateCurrentFBO() if (depthBufferView == nullptr) { // create depth buffer view - forceLogDebug_printf("Creating depth buffer tex %08x %dx%d slice %d", depthBufferPhysMem, depthBufferHeight, depthBufferWidth, depthBufferViewFirstSlice); if(depthBufferViewFirstSlice == 0) depthBufferView = LatteTexture_CreateMapping(depthBufferPhysMem, 0, depthBufferWidth, depthBufferHeight, 1, depthBufferPitch, depthBufferTileMode, depthBufferSwizzle, 0, 1, 0, 1, depthBufferFormat, Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, true); else diff --git a/src/Cafe/HW/Latte/Core/LatteShader.cpp b/src/Cafe/HW/Latte/Core/LatteShader.cpp index 4bbee700..4ac6c1fe 100644 --- a/src/Cafe/HW/Latte/Core/LatteShader.cpp +++ b/src/Cafe/HW/Latte/Core/LatteShader.cpp @@ -813,6 +813,8 @@ LatteDecompilerShader* LatteShader_CompileSeparablePixelShader(uint64 baseHash, void LatteSHRC_UpdateVertexShader(uint8* vertexShaderPtr, uint32 vertexShaderSize, bool usesGeometryShader) { + // todo - should include VTX_SEMANTIC table in state + LatteSHRC_UpdateVSBaseHash(vertexShaderPtr, vertexShaderSize, usesGeometryShader); uint64 vsAuxHash = 0; auto itBaseShader = sVertexShaders.find(_shaderBaseHash_vs); diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp index 8bad99e0..919c3094 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp @@ -345,6 +345,7 @@ bool LatteDecompiler_IsALUTransInstruction(bool isOP3, uint32 opcode) opcode == ALU_OP2_INST_SETGE_UINT || opcode == ALU_OP2_INST_SETGT_UINT || opcode == ALU_OP2_INST_MAX_DX10 || + opcode == ALU_OP2_INST_MIN_DX10 || opcode == ALU_OP2_INST_PRED_SETE || opcode == ALU_OP2_INST_PRED_SETNE || opcode == ALU_OP2_INST_PRED_SETGE || diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp index 412f45ce..66562896 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp @@ -176,6 +176,7 @@ bool _isIntegerInstruction(const LatteDecompilerALUInstruction& aluInstruction) case ALU_OP2_INST_COS: case ALU_OP2_INST_RNDNE: case ALU_OP2_INST_MAX_DX10: + case ALU_OP2_INST_MIN_DX10: case ALU_OP2_INST_SETGT: case ALU_OP2_INST_SETGE: case ALU_OP2_INST_SETNE: diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp index 97703b11..2fb269fb 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp @@ -1038,7 +1038,8 @@ void _emitALUOP2InstructionCode(LatteDecompilerShaderContext* shaderContext, Lat } else if( aluInstruction->opcode == ALU_OP2_INST_MAX || aluInstruction->opcode == ALU_OP2_INST_MIN || - aluInstruction->opcode == ALU_OP2_INST_MAX_DX10 ) + aluInstruction->opcode == ALU_OP2_INST_MAX_DX10 || + aluInstruction->opcode == ALU_OP2_INST_MIN_DX10 ) { outputType = _getALUInstructionOutputDataType(shaderContext, aluInstruction); _emitInstructionOutputVariableName(shaderContext, aluInstruction); @@ -1048,10 +1049,10 @@ void _emitALUOP2InstructionCode(LatteDecompilerShaderContext* shaderContext, Lat src->add("max"); else if( aluInstruction->opcode == ALU_OP2_INST_MIN ) src->add("min"); - else if( aluInstruction->opcode == ALU_OP2_INST_MAX_DX10 ) - { + else if (aluInstruction->opcode == ALU_OP2_INST_MAX_DX10) src->add("max"); - } + else if (aluInstruction->opcode == ALU_OP2_INST_MIN_DX10) + src->add("min"); src->add("("); _emitOperandInputCode(shaderContext, aluInstruction, 0, LATTE_DECOMPILER_DTYPE_FLOAT); src->add(", "); diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h index 7c07155d..4cb1982e 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h @@ -31,6 +31,7 @@ #define ALU_OP2_INST_MAX (0x003) #define ALU_OP2_INST_MIN (0x004) #define ALU_OP2_INST_MAX_DX10 (0x005) +#define ALU_OP2_INST_MIN_DX10 (0x006) #define ALU_OP2_INST_SETE (0x008) #define ALU_OP2_INST_SETGT (0x009) #define ALU_OP2_INST_SETGE (0x00A) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp index 502d84be..45e4a933 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp @@ -209,7 +209,6 @@ uint32 VkTextureChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumA VkResult r = vkAllocateMemory(m_device, &allocInfo, nullptr, &imageMemory); if (r != VK_SUCCESS) continue; - forceLog_printf("Vulkan-Info: Allocated additional memory for textures from device-local memory"); m_list_chunkInfo[chunkIndex].mem = imageMemory; return allocationSize; } @@ -225,7 +224,6 @@ uint32 VkTextureChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumA VkResult r = vkAllocateMemory(m_device, &allocInfo, nullptr, &imageMemory); if (r != VK_SUCCESS) continue; - forceLog_printf("Vulkan-Info: Allocated additional memory for textures from host-local memory"); m_list_chunkInfo[chunkIndex].mem = imageMemory; return allocationSize; }