diff --git a/GPU/Common/DepalettizeShaderCommon.cpp b/GPU/Common/DepalettizeShaderCommon.cpp index 8c72b770d2..b4baadee0e 100644 --- a/GPU/Common/DepalettizeShaderCommon.cpp +++ b/GPU/Common/DepalettizeShaderCommon.cpp @@ -42,9 +42,9 @@ void GenerateDepalShader300(char *buffer, GEBufferFormat pixelFormat, ShaderLang WRITE(p, "Texture2D pal : register(t1);\n"); // Support for depth. if (pixelFormat == GE_FORMAT_DEPTH16) { - WRITE(p, "cbuffer params : register(b0) {\n"); - WRITE(p, " float z_scale; float z_offset;\n"); - WRITE(p, "};\n"); + DepthScaleFactors factors = GetDepthScaleFactors(); + WRITE(p, "static const float z_scale = %f;\n", factors.scale); + WRITE(p, "static const float z_offset = %f;\n", factors.offset); } } else if (language == GLSL_VULKAN) { WRITE(p, "#version 450\n"); @@ -57,9 +57,9 @@ void GenerateDepalShader300(char *buffer, GEBufferFormat pixelFormat, ShaderLang // Support for depth. if (pixelFormat == GE_FORMAT_DEPTH16) { - WRITE(p, "layout (push_constant) uniform params {\n"); - WRITE(p, " float z_scale; float z_offset;\n"); - WRITE(p, "};\n"); + DepthScaleFactors factors = GetDepthScaleFactors(); + WRITE(p, "const float z_scale = %f;\n", factors.scale); + WRITE(p, "const float z_offset = %f;\n", factors.offset); } } else { if (gl_extensions.IsGLES) { diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index 232ecd03d0..a1aaccb80e 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -419,18 +419,6 @@ void TextureCacheD3D11::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer, context_->PSSetSamplers(1, 1, &stockD3D11.samplerPoint2DWrap); draw_->BindFramebufferAsTexture(framebuffer->fbo, 0, depth ? Draw::FB_DEPTH_BIT : Draw::FB_COLOR_BIT, 0); context_->PSSetSamplers(0, 1, &stockD3D11.samplerPoint2DWrap); - - if (depth) { - DepthScaleFactors scaleFactors = GetDepthScaleFactors(); - DepthPushConstants push; - push.z_scale = scaleFactors.scale; - push.z_offset = scaleFactors.offset; - D3D11_MAPPED_SUBRESOURCE map; - context_->Map(depalConstants_, 0, D3D11_MAP_WRITE_DISCARD, 0, &map); - memcpy(map.pData, &push, sizeof(push)); - context_->Unmap(depalConstants_, 0); - context_->PSSetConstantBuffers(0, 1, &depalConstants_); - } shaderApply.Shade(); context_->PSSetShaderResources(0, 1, &nullTexture); // Make D3D11 validation happy. Really of no consequence since we rebind anyway. diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 50a2a48cb1..3720c873e0 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -406,6 +406,11 @@ void TextureCacheVulkan::Unbind() { InvalidateLastTexture(); } +void TextureCacheVulkan::BindAsClutTexture(Draw::Texture *tex) { + VkImageView clutTexture = (VkImageView)draw_->GetNativeObject(Draw::NativeObject::TEXTURE_VIEW, tex); + drawEngine_->SetDepalTexture(clutTexture); +} + void TextureCacheVulkan::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer, GETextureFormat texFormat, FramebufferNotificationChannel channel) { SamplerCacheKey samplerKey = GetFramebufferSamplingParams(framebuffer->bufferWidth, framebuffer->bufferHeight); @@ -519,17 +524,6 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer VulkanRenderManager *renderManager = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); renderManager->BindPipeline(depalShader->pipeline, (PipelineFlags)0); - if (depth) { - DepthScaleFactors scaleFactors = GetDepthScaleFactors(); - struct DepthPushConstants { - float z_scale; - float z_offset; - }; - DepthPushConstants push; - push.z_scale = scaleFactors.scale; - push.z_offset = scaleFactors.offset; - renderManager->PushConstants(vulkan2D_->GetPipelineLayout(), VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(DepthPushConstants), &push); - } renderManager->SetScissor(0, 0, (int)framebuffer->renderWidth, (int)framebuffer->renderHeight); renderManager->SetViewport(VkViewport{ 0.f, 0.f, (float)framebuffer->renderWidth, (float)framebuffer->renderHeight, 0.f, 1.f }); renderManager->Draw(vulkan2D_->GetPipelineLayout(), descSet, 0, nullptr, pushed, offset, 4); diff --git a/GPU/Vulkan/TextureCacheVulkan.h b/GPU/Vulkan/TextureCacheVulkan.h index 346c0b9a17..c29a7756f7 100644 --- a/GPU/Vulkan/TextureCacheVulkan.h +++ b/GPU/Vulkan/TextureCacheVulkan.h @@ -102,6 +102,7 @@ protected: void BindTexture(TexCacheEntry *entry) override; void Unbind() override; void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override; + void BindAsClutTexture(Draw::Texture *tex) override; private: void LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePtr, int rowPitch, int level, int scaleFactor, VkFormat dstFmt);