mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-10 05:28:56 +02:00
fix for push constants
This commit is contained in:
parent
e85ec57ac8
commit
49d3508ec3
3 changed files with 114 additions and 12 deletions
97
.patch/snapdragon_gsr/0002-push-constants-retrofit.patch
Normal file
97
.patch/snapdragon_gsr/0002-push-constants-retrofit.patch
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
diff --git a/d926/sgsr/v1/include/glsl/sgsr1_shader_mobile.frag b/d926/sgsr/v1/include/glsl/sgsr1_shader_mobile.frag
|
||||||
|
index 69927af..c942bbc 100644
|
||||||
|
--- a/d926/sgsr/v1/include/glsl/sgsr1_shader_mobile.frag
|
||||||
|
+++ b/d926/sgsr/v1/include/glsl/sgsr1_shader_mobile.frag
|
||||||
|
@@ -34,11 +34,10 @@ precision highp int;
|
||||||
|
////////////////////////
|
||||||
|
|
||||||
|
#if defined(UseUniformBlock)
|
||||||
|
-layout (set=0, binding = 0) uniform UniformBlock
|
||||||
|
-{
|
||||||
|
- highp vec4 ViewportInfo[1];
|
||||||
|
+layout( push_constant ) uniform constants {
|
||||||
|
+ highp vec4 ViewportInfo;
|
||||||
|
};
|
||||||
|
-layout(set = 0, binding = 1) uniform mediump sampler2D ps0;
|
||||||
|
+layout(set = 0, binding = 0) uniform mediump sampler2D ps0;
|
||||||
|
#else
|
||||||
|
uniform highp vec4 ViewportInfo[1];
|
||||||
|
uniform mediump sampler2D ps0;
|
||||||
|
@@ -82,21 +81,21 @@ void main()
|
||||||
|
//if ( mode!=4 && xCenter*xCenter+yCenter*yCenter<=0.4 * 0.4)
|
||||||
|
if ( mode!=4)
|
||||||
|
{
|
||||||
|
- highp vec2 imgCoord = ((in_TEXCOORD0.xy*ViewportInfo[0].zw)+vec2(-0.5,0.5));
|
||||||
|
+ highp vec2 imgCoord = ((in_TEXCOORD0.xy*ViewportInfo.zw)+vec2(-0.5,0.5));
|
||||||
|
highp vec2 imgCoordPixel = floor(imgCoord);
|
||||||
|
- highp vec2 coord = (imgCoordPixel*ViewportInfo[0].xy);
|
||||||
|
+ highp vec2 coord = (imgCoordPixel*ViewportInfo.xy);
|
||||||
|
vec2 pl = (imgCoord+(-imgCoordPixel));
|
||||||
|
vec4 left = textureGather(ps0,coord, mode);
|
||||||
|
|
||||||
|
float edgeVote = abs(left.z - left.y) + abs(color[mode] - left.y) + abs(color[mode] - left.z) ;
|
||||||
|
if(edgeVote > edgeThreshold)
|
||||||
|
{
|
||||||
|
- coord.x += ViewportInfo[0].x;
|
||||||
|
+ coord.x += ViewportInfo.x;
|
||||||
|
|
||||||
|
- vec4 right = textureGather(ps0,coord + vec2(ViewportInfo[0].x, 0.0), mode);
|
||||||
|
+ vec4 right = textureGather(ps0,coord + vec2(ViewportInfo.x, 0.0), mode);
|
||||||
|
vec4 upDown;
|
||||||
|
- upDown.xy = textureGather(ps0,coord + vec2(0.0, -ViewportInfo[0].y),mode).wz;
|
||||||
|
- upDown.zw = textureGather(ps0,coord+ vec2(0.0, ViewportInfo[0].y), mode).yx;
|
||||||
|
+ upDown.xy = textureGather(ps0,coord + vec2(0.0, -ViewportInfo.y),mode).wz;
|
||||||
|
+ upDown.zw = textureGather(ps0,coord+ vec2(0.0, ViewportInfo.y), mode).yx;
|
||||||
|
|
||||||
|
float mean = (left.y+left.z+right.x+right.w)*0.25;
|
||||||
|
left = left - vec4(mean);
|
||||||
|
diff --git a/d926/sgsr/v1/include/glsl/sgsr1_shader_mobile_edge_direction.frag b/d926/sgsr/v1/include/glsl/sgsr1_shader_mobile_edge_direction.frag
|
||||||
|
index 1f1daa6..128a348 100644
|
||||||
|
--- a/d926/sgsr/v1/include/glsl/sgsr1_shader_mobile_edge_direction.frag
|
||||||
|
+++ b/d926/sgsr/v1/include/glsl/sgsr1_shader_mobile_edge_direction.frag
|
||||||
|
@@ -40,13 +40,12 @@ precision highp int;
|
||||||
|
////////////////////////
|
||||||
|
|
||||||
|
#if defined(UseUniformBlock)
|
||||||
|
-layout (set=0, binding = 0) uniform UniformBlock
|
||||||
|
-{
|
||||||
|
- highp vec4 ViewportInfo[1];
|
||||||
|
+layout( push_constant ) uniform constants {
|
||||||
|
+ highp vec4 ViewportInfo;
|
||||||
|
};
|
||||||
|
-layout(set = 0, binding = 1) uniform mediump sampler2D ps0;
|
||||||
|
+layout(set = 0, binding = 0) uniform mediump sampler2D ps0;
|
||||||
|
#else
|
||||||
|
-uniform highp vec4 ViewportInfo[1];
|
||||||
|
+uniform highp vec4 ViewportInfo;
|
||||||
|
uniform mediump sampler2D ps0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@@ -113,21 +112,21 @@ void main()
|
||||||
|
//if ( OperationMode!=4 && xCenter*xCenter+yCenter*yCenter<=0.4 * 0.4)
|
||||||
|
if ( OperationMode!=4)
|
||||||
|
{
|
||||||
|
- highp vec2 imgCoord = ((in_TEXCOORD0.xy*ViewportInfo[0].zw)+vec2(-0.5,0.5));
|
||||||
|
+ highp vec2 imgCoord = ((in_TEXCOORD0.xy*ViewportInfo.zw)+vec2(-0.5,0.5));
|
||||||
|
highp vec2 imgCoordPixel = floor(imgCoord);
|
||||||
|
- highp vec2 coord = (imgCoordPixel*ViewportInfo[0].xy);
|
||||||
|
+ highp vec2 coord = (imgCoordPixel*ViewportInfo.xy);
|
||||||
|
vec2 pl = (imgCoord+(-imgCoordPixel));
|
||||||
|
vec4 left = textureGather(ps0,coord, OperationMode);
|
||||||
|
|
||||||
|
float edgeVote = abs(left.z - left.y) + abs(color[OperationMode] - left.y) + abs(color[OperationMode] - left.z) ;
|
||||||
|
if(edgeVote > EdgeThreshold)
|
||||||
|
{
|
||||||
|
- coord.x += ViewportInfo[0].x;
|
||||||
|
+ coord.x += ViewportInfo.x;
|
||||||
|
|
||||||
|
- vec4 right = textureGather(ps0,coord + vec2(ViewportInfo[0].x, 0.0), OperationMode);
|
||||||
|
+ vec4 right = textureGather(ps0,coord + vec2(ViewportInfo.x, 0.0), OperationMode);
|
||||||
|
vec4 upDown;
|
||||||
|
- upDown.xy = textureGather(ps0,coord + vec2(0.0, -ViewportInfo[0].y),OperationMode).wz;
|
||||||
|
- upDown.zw = textureGather(ps0,coord+ vec2(0.0, ViewportInfo[0].y), OperationMode).yx;
|
||||||
|
+ upDown.xy = textureGather(ps0,coord + vec2(0.0, -ViewportInfo.y),OperationMode).wz;
|
||||||
|
+ upDown.zw = textureGather(ps0,coord+ vec2(0.0, ViewportInfo.y), OperationMode).yx;
|
||||||
|
|
||||||
|
float mean = (left.y+left.z+right.x+right.w)*0.25;
|
||||||
|
left = left - vec4(mean);
|
||||||
|
|
@ -120,6 +120,9 @@ void Layer::ConfigureDraw(PresentPushConstants* out_push_constants,
|
||||||
if (fsr) {
|
if (fsr) {
|
||||||
source_image_view = fsr->Draw(scheduler, image_index, source_image, source_image_view, render_extent, crop_rect);
|
source_image_view = fsr->Draw(scheduler, image_index, source_image, source_image_view, render_extent, crop_rect);
|
||||||
crop_rect = {0, 0, 1, 1};
|
crop_rect = {0, 0, 1, 1};
|
||||||
|
} else if (sgsr) {
|
||||||
|
source_image_view = sgsr->Draw(scheduler, image_index, source_image, source_image_view, render_extent, crop_rect);
|
||||||
|
crop_rect = {0, 0, 1, 1};
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMatrixData(*out_push_constants, layout);
|
SetMatrixData(*out_push_constants, layout);
|
||||||
|
|
|
||||||
|
|
@ -94,22 +94,25 @@ void SGSR::UploadImages(Scheduler& scheduler) {
|
||||||
|
|
||||||
VkImageView SGSR::Draw(Scheduler& scheduler, size_t image_index, VkImage source_image, VkImageView source_image_view, VkExtent2D input_image_extent, const Common::Rectangle<f32>& crop_rect) {
|
VkImageView SGSR::Draw(Scheduler& scheduler, size_t image_index, VkImage source_image, VkImageView source_image_view, VkExtent2D input_image_extent, const Common::Rectangle<f32>& crop_rect) {
|
||||||
Images& images = m_dynamic_images[image_index];
|
Images& images = m_dynamic_images[image_index];
|
||||||
VkImage stage0_image = *images.images[0];
|
auto const stage0_image = *images.images[0];
|
||||||
VkImage stage1_image = *images.images[1];
|
auto const stage1_image = *images.images[1];
|
||||||
VkDescriptorSet stage0_descriptor_set = images.descriptor_sets[0];
|
auto const stage0_descriptor_set = images.descriptor_sets[0];
|
||||||
VkDescriptorSet stage1_descriptor_set = images.descriptor_sets[1];
|
auto const stage1_descriptor_set = images.descriptor_sets[1];
|
||||||
VkFramebuffer stage0_framebuffer = *images.framebuffers[0];
|
auto const stage0_framebuffer = *images.framebuffers[0];
|
||||||
VkFramebuffer stage1_framebuffer = *images.framebuffers[1];
|
auto const stage1_framebuffer = *images.framebuffers[1];
|
||||||
|
auto const stage0_pipeline = *m_stage_pipeline[0];
|
||||||
|
auto const stage1_pipeline = *m_stage_pipeline[1];
|
||||||
|
|
||||||
VkPipelineLayout pipeline_layout = *m_pipeline_layout;
|
VkPipelineLayout pipeline_layout = *m_pipeline_layout;
|
||||||
VkRenderPass renderpass = *m_renderpass;
|
VkRenderPass renderpass = *m_renderpass;
|
||||||
VkExtent2D extent = m_extent;
|
VkExtent2D extent = m_extent;
|
||||||
|
|
||||||
const f32 input_image_width = f32(input_image_extent.width);
|
const f32 input_image_width = f32(input_image_extent.width);
|
||||||
const f32 input_image_height = f32(input_image_extent.height);
|
const f32 input_image_height = f32(input_image_extent.height);
|
||||||
const f32 viewport_width = (crop_rect.right - crop_rect.left) * input_image_width;
|
|
||||||
const f32 viewport_x = crop_rect.left * input_image_width;
|
const f32 viewport_x = crop_rect.left * input_image_width;
|
||||||
const f32 viewport_height = (crop_rect.bottom - crop_rect.top) * input_image_height;
|
|
||||||
const f32 viewport_y = crop_rect.top * input_image_height;
|
const f32 viewport_y = crop_rect.top * input_image_height;
|
||||||
|
const f32 viewport_width = (crop_rect.right - crop_rect.left) * input_image_width;
|
||||||
|
const f32 viewport_height = (crop_rect.bottom - crop_rect.top) * input_image_height;
|
||||||
|
|
||||||
// highp vec4
|
// highp vec4
|
||||||
PushConstants viewport_con{};
|
PushConstants viewport_con{};
|
||||||
|
|
@ -122,20 +125,19 @@ VkImageView SGSR::Draw(Scheduler& scheduler, size_t image_index, VkImage source_
|
||||||
UpdateDescriptorSets(source_image_view, image_index);
|
UpdateDescriptorSets(source_image_view, image_index);
|
||||||
|
|
||||||
scheduler.RequestOutsideRenderPassOperationContext();
|
scheduler.RequestOutsideRenderPassOperationContext();
|
||||||
scheduler.Record([=, this](vk::CommandBuffer cmdbuf) {
|
scheduler.Record([=](vk::CommandBuffer cmdbuf) {
|
||||||
TransitionImageLayout(cmdbuf, source_image, VK_IMAGE_LAYOUT_GENERAL);
|
TransitionImageLayout(cmdbuf, source_image, VK_IMAGE_LAYOUT_GENERAL);
|
||||||
TransitionImageLayout(cmdbuf, stage0_image, VK_IMAGE_LAYOUT_GENERAL);
|
TransitionImageLayout(cmdbuf, stage0_image, VK_IMAGE_LAYOUT_GENERAL);
|
||||||
BeginRenderPass(cmdbuf, renderpass, stage0_framebuffer, extent);
|
BeginRenderPass(cmdbuf, renderpass, stage0_framebuffer, extent);
|
||||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *m_stage_pipeline[0]);
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, stage0_pipeline);
|
||||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, stage0_descriptor_set, {});
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, stage0_descriptor_set, {});
|
||||||
cmdbuf.PushConstants(pipeline_layout, VK_SHADER_STAGE_FRAGMENT_BIT, viewport_con);
|
cmdbuf.PushConstants(pipeline_layout, VK_SHADER_STAGE_FRAGMENT_BIT, viewport_con);
|
||||||
cmdbuf.Draw(3, 1, 0, 0);
|
cmdbuf.Draw(3, 1, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
//
|
|
||||||
TransitionImageLayout(cmdbuf, stage0_image, VK_IMAGE_LAYOUT_GENERAL);
|
TransitionImageLayout(cmdbuf, stage0_image, VK_IMAGE_LAYOUT_GENERAL);
|
||||||
TransitionImageLayout(cmdbuf, stage1_image, VK_IMAGE_LAYOUT_GENERAL);
|
TransitionImageLayout(cmdbuf, stage1_image, VK_IMAGE_LAYOUT_GENERAL);
|
||||||
BeginRenderPass(cmdbuf, renderpass, stage1_framebuffer, extent);
|
BeginRenderPass(cmdbuf, renderpass, stage1_framebuffer, extent);
|
||||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *m_stage_pipeline[1]);
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, stage1_pipeline);
|
||||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, stage1_descriptor_set, {});
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, stage1_descriptor_set, {});
|
||||||
cmdbuf.PushConstants(pipeline_layout, VK_SHADER_STAGE_FRAGMENT_BIT, viewport_con);
|
cmdbuf.PushConstants(pipeline_layout, VK_SHADER_STAGE_FRAGMENT_BIT, viewport_con);
|
||||||
cmdbuf.Draw(3, 1, 0, 0);
|
cmdbuf.Draw(3, 1, 0, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue