Skip to content

Commit 091d35c

Browse files
MajorPainTheCactusLibretroAdmin
authored andcommitted
Fixed the menu in D3D11 and D3D12 when using HDR native shader's
Vulkan still has issues
1 parent 12d188e commit 091d35c

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

gfx/drivers/d3d11.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3988,7 +3988,13 @@ static bool d3d11_gfx_frame(
39883988
}
39893989

39903990
{
3991-
d3d11->hdr.ubo_values.scanlines = false;
3991+
const float prev_iscanlines = d3d11->hdr.ubo_values.scanlines;
3992+
const float prev_inverse_tonemap = d3d11->hdr.ubo_values.inverse_tonemap;
3993+
const float prev_hdr10 = d3d11->hdr.ubo_values.hdr10;
3994+
3995+
d3d11->hdr.ubo_values.scanlines = 0.0f;
3996+
d3d11->hdr.ubo_values.inverse_tonemap = 1.0f;
3997+
d3d11->hdr.ubo_values.hdr10 = 1.0f;
39923998

39933999
D3D11_MAPPED_SUBRESOURCE mapped_ubo;
39944000

@@ -3999,6 +4005,10 @@ static bool d3d11_gfx_frame(
39994005
*ubo = d3d11->hdr.ubo_values;
40004006
}
40014007
d3d11->context->lpVtbl->Unmap(d3d11->context, (D3D11Resource)d3d11->hdr.ubo, 0);
4008+
4009+
d3d11->hdr.ubo_values.scanlines = prev_iscanlines;
4010+
d3d11->hdr.ubo_values.inverse_tonemap = prev_inverse_tonemap;
4011+
d3d11->hdr.ubo_values.hdr10 = prev_hdr10;
40024012
}
40034013

40044014
context->lpVtbl->VSSetConstantBuffers(context, 0, 1, &d3d11->hdr.ubo);

gfx/drivers/d3d12.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4631,7 +4631,13 @@ static bool d3d12_gfx_frame(
46314631
d3d12->samplers[RARCH_FILTER_UNSPEC][RARCH_WRAP_DEFAULT]);
46324632

46334633
{
4634-
d3d12->hdr.ubo_values.scanlines = false;
4634+
const float prev_iscanlines = d3d12->hdr.ubo_values.scanlines;
4635+
const float prev_inverse_tonemap = d3d12->hdr.ubo_values.inverse_tonemap;
4636+
const float prev_hdr10 = d3d12->hdr.ubo_values.hdr10;
4637+
4638+
d3d12->hdr.ubo_values.scanlines = 0.0f;
4639+
d3d12->hdr.ubo_values.inverse_tonemap = 1.0f;
4640+
d3d12->hdr.ubo_values.hdr10 = 1.0f;
46354641

46364642
{
46374643
dxgi_hdr_uniform_t* mapped_ubo;
@@ -4646,6 +4652,11 @@ static bool d3d12_gfx_frame(
46464652
cmd->lpVtbl->SetGraphicsRootConstantBufferView(
46474653
cmd, ROOT_ID_UBO,
46484654
d3d12->hdr.ubo_post_view.BufferLocation);
4655+
4656+
4657+
d3d12->hdr.ubo_values.scanlines = prev_iscanlines;
4658+
d3d12->hdr.ubo_values.inverse_tonemap = prev_inverse_tonemap;
4659+
d3d12->hdr.ubo_values.hdr10 = prev_hdr10;
46494660
}
46504661

46514662
cmd->lpVtbl->IASetVertexBuffers(cmd, 0, 1, &d3d12->frame.vbo_view);

gfx/drivers/vulkan.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4579,7 +4579,14 @@ static void vulkan_run_hdr_pipeline(VkPipeline pipeline, VkRenderPass render_pas
45794579
VkRenderPassBeginInfo rp_info;
45804580
VkClearValue clear_color;
45814581

4582-
vk->hdr.ubo_values.mvp = vk->mvp_no_rot;
4582+
//const bool prev_scanlines = vk->hdr.ubo_values.scanlines;
4583+
const float prev_inverse_tonemap = vk->hdr.ubo_values.inverse_tonemap;
4584+
const float prev_hdr10 = vk->hdr.ubo_values.hdr10;
4585+
4586+
vk->hdr.ubo_values.mvp = vk->mvp_no_rot;
4587+
//vk->hdr.ubo_values.scanlines = false;
4588+
vk->hdr.ubo_values.inverse_tonemap = 1.0f;
4589+
vk->hdr.ubo_values.hdr10 = 1.0f;
45834590

45844591
rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
45854592
rp_info.pNext = NULL;
@@ -4627,7 +4634,7 @@ static void vulkan_run_hdr_pipeline(VkPipeline pipeline, VkRenderPass render_pas
46274634
0,
46284635
ubo->buffer,
46294636
0,
4630-
ubo->size);
4637+
ubo->size);
46314638

46324639
image_info.sampler = vk->samplers.nearest;
46334640
image_info.imageView = source_image->view;
@@ -4698,6 +4705,9 @@ static void vulkan_run_hdr_pipeline(VkPipeline pipeline, VkRenderPass render_pas
46984705
vkCmdDraw(vk->cmd, 6, 1, 0, 0);
46994706

47004707
vkCmdEndRenderPass(vk->cmd);
4708+
4709+
vk->hdr.ubo_values.inverse_tonemap = prev_inverse_tonemap;
4710+
vk->hdr.ubo_values.hdr10 = prev_hdr10;
47014711
}
47024712

47034713
static bool vulkan_frame(void *data, const void *frame,
@@ -5160,8 +5170,7 @@ static bool vulkan_frame(void *data, const void *frame,
51605170
#ifdef VULKAN_HDR_SWAPCHAIN
51615171
/* Copy over back buffer to swap chain render targets */
51625172
if ((vk->context->flags & VK_CTX_FLAG_HDR_ENABLE) &&
5163-
(vk->flags & VK_FLAG_MENU_ENABLE) &&
5164-
(!filter_chain || !vulkan_filter_chain_emits_hdr10(filter_chain)))
5173+
(vk->flags & VK_FLAG_MENU_ENABLE))
51655174
{
51665175
backbuffer = &vk->backbuffers[swapchain_index];
51675176
/* Prepare source buffer for reading */
@@ -5192,8 +5201,7 @@ static bool vulkan_frame(void *data, const void *frame,
51925201
VkImageLayout backbuffer_layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
51935202
#ifdef VULKAN_HDR_SWAPCHAIN
51945203
struct vk_image* readback_source = backbuffer;
5195-
if((vk->context->flags & VK_CTX_FLAG_HDR_ENABLE) &&
5196-
(!filter_chain || !vulkan_filter_chain_emits_hdr10(filter_chain)))
5204+
if((vk->context->flags & VK_CTX_FLAG_HDR_ENABLE))
51975205
{
51985206
if (vk->flags & VK_FLAG_MENU_ENABLE)
51995207
{

0 commit comments

Comments
 (0)