mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
rsx: Remove ARGB->D24S8 conversion shader which has been deprecated for years since compute capabilities were added to the emulator
This commit is contained in:
parent
717e851a99
commit
8d8fb4a2e4
@ -600,26 +600,6 @@ void GLGSRender::end()
|
||||
|
||||
m_frame_stats.setup_time += m_profiler.duration();
|
||||
|
||||
gl::command_context cmd{ gl_state };
|
||||
gl::render_target *ds = std::get<1>(m_rtts.m_bound_depth_stencil);
|
||||
|
||||
// Handle special memory barrier for ARGB8->D24S8 in an active DSV
|
||||
if (ds && ds->old_contents.size() == 1 &&
|
||||
ds->old_contents[0].source->get_internal_format() == gl::texture::internal_format::rgba8)
|
||||
{
|
||||
gl_state.enable(GL_FALSE, GL_SCISSOR_TEST);
|
||||
|
||||
// TODO: Stencil transfer
|
||||
gl::g_hw_blitter->fast_clear_image(cmd, ds, 1.f, 0xFF);
|
||||
ds->old_contents[0].init_transfer(ds);
|
||||
|
||||
m_depth_converter.run(ds->old_contents[0].src_rect(),
|
||||
ds->old_contents[0].dst_rect(),
|
||||
ds->old_contents[0].source, ds);
|
||||
|
||||
ds->on_write();
|
||||
}
|
||||
|
||||
// Active texture environment is used to decode shaders
|
||||
m_profiler.start();
|
||||
load_texture_env();
|
||||
@ -645,71 +625,16 @@ void GLGSRender::end()
|
||||
m_gl_texture_cache.release_uncached_temporary_subresources();
|
||||
m_frame_stats.textures_upload_time += m_profiler.duration();
|
||||
|
||||
// Optionally do memory synchronization if the texture stage has not yet triggered this
|
||||
if (true)//g_cfg.video.strict_rendering_mode)
|
||||
gl_state.enable(GL_FALSE, GL_SCISSOR_TEST);
|
||||
|
||||
gl::command_context cmd{ gl_state };
|
||||
if (auto ds = std::get<1>(m_rtts.m_bound_depth_stencil)) ds->write_barrier(cmd);
|
||||
|
||||
for (auto &rtt : m_rtts.m_bound_render_targets)
|
||||
{
|
||||
gl_state.enable(GL_FALSE, GL_SCISSOR_TEST);
|
||||
|
||||
if (ds) ds->write_barrier(cmd);
|
||||
|
||||
for (auto &rtt : m_rtts.m_bound_render_targets)
|
||||
if (auto surface = std::get<1>(rtt))
|
||||
{
|
||||
if (auto surface = std::get<1>(rtt))
|
||||
{
|
||||
surface->write_barrier(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rsx::simple_array<int> buffers_to_clear;
|
||||
bool clear_all_color = true;
|
||||
bool clear_depth = false;
|
||||
|
||||
for (int index = 0; index < 4; index++)
|
||||
{
|
||||
if (m_rtts.m_bound_render_targets[index].first)
|
||||
{
|
||||
if (!m_rtts.m_bound_render_targets[index].second->dirty())
|
||||
clear_all_color = false;
|
||||
else
|
||||
buffers_to_clear.push_back(index);
|
||||
}
|
||||
}
|
||||
|
||||
if (ds && ds->dirty())
|
||||
{
|
||||
clear_depth = true;
|
||||
}
|
||||
|
||||
if (clear_depth || !buffers_to_clear.empty())
|
||||
{
|
||||
gl_state.enable(GL_FALSE, GL_SCISSOR_TEST);
|
||||
GLenum mask = 0;
|
||||
|
||||
if (clear_depth)
|
||||
{
|
||||
gl_state.depth_mask(GL_TRUE);
|
||||
gl_state.clear_depth(1.f);
|
||||
gl_state.clear_stencil(255);
|
||||
mask |= GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
|
||||
}
|
||||
|
||||
if (clear_all_color)
|
||||
mask |= GL_COLOR_BUFFER_BIT;
|
||||
|
||||
glClear(mask);
|
||||
|
||||
if (!buffers_to_clear.empty() && !clear_all_color)
|
||||
{
|
||||
GLfloat colors[] = { 0.f, 0.f, 0.f, 0.f };
|
||||
//It is impossible for the render target to be type A or B here (clear all would have been flagged)
|
||||
for (auto &i : buffers_to_clear)
|
||||
glClearBufferfv(GL_COLOR, i, colors);
|
||||
}
|
||||
|
||||
if (clear_depth)
|
||||
gl_state.depth_mask(rsx::method_registers.depth_write_enabled());
|
||||
surface->write_barrier(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,6 @@ void GLGSRender::on_init_thread()
|
||||
glEnable(GL_CLIP_DISTANCE0 + 4);
|
||||
glEnable(GL_CLIP_DISTANCE0 + 5);
|
||||
|
||||
m_depth_converter.create();
|
||||
m_ui_renderer.create();
|
||||
m_video_output_pass.create();
|
||||
|
||||
@ -460,7 +459,6 @@ void GLGSRender::on_exit()
|
||||
m_null_textures.clear();
|
||||
m_text_printer.close();
|
||||
m_gl_texture_cache.destroy();
|
||||
m_depth_converter.destroy();
|
||||
m_ui_renderer.destroy();
|
||||
m_video_output_pass.destroy();
|
||||
|
||||
|
@ -114,7 +114,6 @@ private:
|
||||
bool manually_flush_ring_buffers = false;
|
||||
|
||||
gl::text_writer m_text_printer;
|
||||
gl::depth_convert_pass m_depth_converter;
|
||||
gl::ui_overlay_renderer m_ui_renderer;
|
||||
gl::video_out_calibration_pass m_video_output_pass;
|
||||
|
||||
|
@ -270,84 +270,6 @@ namespace gl
|
||||
}
|
||||
};
|
||||
|
||||
struct depth_convert_pass : public overlay_pass
|
||||
{
|
||||
depth_convert_pass()
|
||||
{
|
||||
vs_src =
|
||||
"#version 420\n\n"
|
||||
"uniform vec2 tex_scale;\n"
|
||||
"out vec2 tc0;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 positions[] = {vec2(-1., -1.), vec2(1., -1.), vec2(-1., 1.), vec2(1., 1.)};\n"
|
||||
" vec2 coords[] = {vec2(0., 0.), vec2(1., 0.), vec2(0., 1.), vec2(1., 1.)};\n"
|
||||
" gl_Position = vec4(positions[gl_VertexID % 4], 0., 1.);\n"
|
||||
" tc0 = coords[gl_VertexID % 4] * tex_scale;\n"
|
||||
"}\n";
|
||||
|
||||
fs_src =
|
||||
"#version 420\n\n"
|
||||
"in vec2 tc0;\n"
|
||||
"layout(binding=31) uniform sampler2D fs0;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 rgba_in = texture(fs0, tc0);\n"
|
||||
" gl_FragDepth = rgba_in.w * 0.99609 + rgba_in.x * 0.00389 + rgba_in.y * 0.00002;\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
void run(const areai& src_area, const areai& dst_area, gl::texture* source, gl::texture* target)
|
||||
{
|
||||
const auto src_ratio_x = f32(src_area.x2) / source->width();
|
||||
const auto src_ratio_y = f32(src_area.y2) / source->height();
|
||||
|
||||
program_handle.uniforms["tex_scale"] = color2f(src_ratio_x, src_ratio_y);
|
||||
|
||||
saved_sampler_state saved(31, m_sampler);
|
||||
glBindTexture(GL_TEXTURE_2D, source->id());
|
||||
|
||||
overlay_pass::run(static_cast<areau>(dst_area), target->id(), true);
|
||||
}
|
||||
};
|
||||
|
||||
struct rgba8_unorm_rg16_sfloat_convert_pass : public overlay_pass
|
||||
{
|
||||
//Not really needed since directly copying data via ARB_copy_image works out fine
|
||||
rgba8_unorm_rg16_sfloat_convert_pass()
|
||||
{
|
||||
vs_src =
|
||||
"#version 420\n\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 positions[] = {vec2(-1., -1.), vec2(1., -1.), vec2(-1., 1.), vec2(1., 1.)};\n"
|
||||
" gl_Position = vec4(positions[gl_VertexID % 4], 0., 1.);\n"
|
||||
"}\n";
|
||||
|
||||
fs_src =
|
||||
"#version 420\n\n"
|
||||
"layout(binding=31) uniform sampler2D fs0;\n"
|
||||
"layout(location=0) out vec4 ocol;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" uint value = packUnorm4x8(texelFetch(fs0, ivec2(gl_FragCoord.xy), 0).zyxw);\n"
|
||||
" ocol.xy = unpackHalf2x16(value);\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
void run(const areau& viewport, GLuint target, GLuint source)
|
||||
{
|
||||
saved_sampler_state saved(31, m_sampler);
|
||||
glBindTexture(GL_TEXTURE_2D, source);
|
||||
|
||||
overlay_pass::run(viewport, target, false);
|
||||
}
|
||||
};
|
||||
|
||||
struct ui_overlay_renderer : public overlay_pass
|
||||
{
|
||||
u32 num_elements = 0;
|
||||
|
@ -908,52 +908,6 @@ void VKGSRender::end()
|
||||
|
||||
m_profiler.start();
|
||||
|
||||
// Check for data casts
|
||||
// NOTE: This is deprecated and will be removed soon. The memory barrier invoked before rendering does this better
|
||||
auto ds = std::get<1>(m_rtts.m_bound_depth_stencil);
|
||||
if (ds && ds->old_contents.size() == 1 &&
|
||||
ds->old_contents[0].source->info.format == VK_FORMAT_B8G8R8A8_UNORM)
|
||||
{
|
||||
auto key = vk::get_renderpass_key({ static_cast<vk::image*>(ds) });
|
||||
auto render_pass = vk::get_renderpass(*m_device, key);
|
||||
verify("Usupported renderpass configuration" HERE), render_pass != VK_NULL_HANDLE;
|
||||
|
||||
VkClearDepthStencilValue clear = { 1.f, 0xFF };
|
||||
VkImageSubresourceRange range = { VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1 };
|
||||
|
||||
// Initialize source data
|
||||
auto srcobj = vk::as_rtt(ds->old_contents[0].source);
|
||||
srcobj->read_barrier(*m_current_command_buffer);
|
||||
|
||||
auto src = srcobj->get_surface(rsx::surface_access::read);
|
||||
switch (src->current_layout)
|
||||
{
|
||||
case VK_IMAGE_LAYOUT_GENERAL:
|
||||
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
|
||||
break;
|
||||
//case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
|
||||
default:
|
||||
src->change_layout(*m_current_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||
break;
|
||||
}
|
||||
|
||||
// Clear explicitly before starting the inheritance transfer
|
||||
const bool preinitialized = (ds->current_layout == VK_IMAGE_LAYOUT_GENERAL);
|
||||
if (!preinitialized) ds->push_layout(*m_current_command_buffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
vkCmdClearDepthStencilImage(*m_current_command_buffer, ds->value, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear, 1, &range);
|
||||
if (!preinitialized) ds->pop_layout(*m_current_command_buffer);
|
||||
|
||||
// TODO: Stencil transfer
|
||||
ds->old_contents[0].init_transfer(ds);
|
||||
vk::get_overlay_pass<vk::depth_convert_pass>()->run(*m_current_command_buffer,
|
||||
ds->old_contents[0].src_rect(),
|
||||
ds->old_contents[0].dst_rect(),
|
||||
src->get_view(0xAAE4, rsx::default_remap_vector),
|
||||
ds, render_pass);
|
||||
|
||||
ds->on_write();
|
||||
}
|
||||
|
||||
load_texture_env();
|
||||
m_frame_stats.textures_upload_time += m_profiler.duration();
|
||||
|
||||
@ -1019,7 +973,7 @@ void VKGSRender::end()
|
||||
vk::get_appropriate_topology(rsx::method_registers.current_draw_clause.primitive, primitive_emulated);
|
||||
|
||||
// Apply write memory barriers
|
||||
if (ds) ds->write_barrier(*m_current_command_buffer);
|
||||
if (auto ds = std::get<1>(m_rtts.m_bound_depth_stencil)) ds->write_barrier(*m_current_command_buffer);
|
||||
|
||||
for (auto &rtt : m_rtts.m_bound_render_targets)
|
||||
{
|
||||
|
@ -396,76 +396,6 @@ namespace vk
|
||||
}
|
||||
};
|
||||
|
||||
// @Deprecated!!
|
||||
struct depth_convert_pass : public overlay_pass
|
||||
{
|
||||
f32 src_scale_x;
|
||||
f32 src_scale_y;
|
||||
|
||||
depth_convert_pass()
|
||||
{
|
||||
vs_src =
|
||||
"#version 450\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n"
|
||||
"layout(push_constant) uniform static_data{ vec2 scale; };\n"
|
||||
"layout(location=0) out vec2 tc0;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 positions[] = {vec2(-1., -1.), vec2(1., -1.), vec2(-1., 1.), vec2(1., 1.)};\n"
|
||||
" vec2 coords[] = {vec2(0., 0.), vec2(1., 0.), vec2(0., 1.), vec2(1., 1.)};\n"
|
||||
" gl_Position = vec4(positions[gl_VertexIndex % 4], 0., 1.);\n"
|
||||
" tc0 = coords[gl_VertexIndex % 4] * scale;\n"
|
||||
"}\n";
|
||||
|
||||
fs_src =
|
||||
"#version 420\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n"
|
||||
"#extension GL_ARB_shader_stencil_export : enable\n\n"
|
||||
"layout(set=0, binding=1) uniform sampler2D fs0;\n"
|
||||
"layout(location=0) in vec2 tc0;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 rgba_in = texture(fs0, tc0);\n"
|
||||
" gl_FragDepth = rgba_in.w * 0.99609 + rgba_in.x * 0.00389 + rgba_in.y * 0.00002;\n"
|
||||
"}\n";
|
||||
|
||||
renderpass_config.set_depth_mask(true);
|
||||
renderpass_config.enable_depth_test(VK_COMPARE_OP_ALWAYS);
|
||||
}
|
||||
|
||||
std::vector<VkPushConstantRange> get_push_constants() override
|
||||
{
|
||||
VkPushConstantRange constant;
|
||||
constant.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
constant.offset = 0;
|
||||
constant.size = 8;
|
||||
|
||||
return { constant };
|
||||
}
|
||||
|
||||
void update_uniforms(vk::command_buffer& cmd, vk::glsl::program* /*program*/) override
|
||||
{
|
||||
float dst[2] = { src_scale_x, src_scale_y };
|
||||
vkCmdPushConstants(cmd, m_pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, 0, 8, dst);
|
||||
}
|
||||
|
||||
void run(vk::command_buffer& cmd, const areai& src_area, const areai& dst_area, vk::image_view* src, vk::image* dst, VkRenderPass render_pass)
|
||||
{
|
||||
auto real_src = src->image();
|
||||
verify(HERE), real_src;
|
||||
|
||||
src_scale_x = static_cast<f32>(src_area.x2) / real_src->width();
|
||||
src_scale_y = static_cast<f32>(src_area.y2) / real_src->height();
|
||||
|
||||
// Coverage sampling disabled, but actually report correct number of samples
|
||||
renderpass_config.set_multisample_state(dst->samples(), 0xFFFF, false, false, false);
|
||||
|
||||
overlay_pass::run(cmd, static_cast<areau>(dst_area), dst, src, render_pass);
|
||||
}
|
||||
};
|
||||
|
||||
struct ui_overlay_renderer : public overlay_pass
|
||||
{
|
||||
f32 m_time = 0.f;
|
||||
|
Loading…
Reference in New Issue
Block a user