This commit is contained in:
Henrik Rydgård
2022-08-06 18:27:03 +02:00
parent 8d23c5ecfb
commit 2fa9b0d0c7
4 changed files with 12 additions and 29 deletions
+6 -6
View File
@@ -42,9 +42,9 @@ void GenerateDepalShader300(char *buffer, GEBufferFormat pixelFormat, ShaderLang
WRITE(p, "Texture2D<float4> 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) {
-12
View File
@@ -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.
+5 -11
View File
@@ -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);
+1
View File
@@ -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);