mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-19 19:15:26 +00:00
vk: Use dynamic constants offset for transform constants
This commit is contained in:
parent
13db445e06
commit
e9d292f595
5 changed files with 21 additions and 16 deletions
|
@ -76,6 +76,8 @@ vec4 _fetch_constant(const in uint base_offset)
|
|||
// uint override
|
||||
return _fetch_constant(int(base_offset));
|
||||
}
|
||||
#elif defined(VULKAN)
|
||||
#define _fetch_constant(x) vc[x + xform_constants_offset]
|
||||
#else
|
||||
#define _fetch_constant(x) vc[x]
|
||||
#endif
|
||||
|
|
|
@ -136,13 +136,13 @@ namespace vk
|
|||
|
||||
std::array<VkPushConstantRange, 1> push_constants;
|
||||
push_constants[0].offset = 0;
|
||||
push_constants[0].size = 16;
|
||||
push_constants[0].size = 20;
|
||||
push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
|
||||
if (vk::emulate_conditional_rendering())
|
||||
{
|
||||
// Conditional render toggle
|
||||
push_constants[0].size = 20;
|
||||
push_constants[0].size = 24;
|
||||
}
|
||||
|
||||
const auto set_layout = vk::descriptors::create_layout(bindings);
|
||||
|
|
|
@ -2108,7 +2108,8 @@ void VKGSRender::load_program_env()
|
|||
if (!io_buf.empty())
|
||||
{
|
||||
m_transform_constants_ring_info.unmap();
|
||||
m_vertex_constants_buffer_info = { m_transform_constants_ring_info.heap->value, mem_offset, io_buf.size() };
|
||||
m_vertex_constants_buffer_info = { m_transform_constants_ring_info.heap->value, 0, VK_WHOLE_SIZE };
|
||||
m_xform_constants_dynamic_offset = mem_offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2310,21 +2311,19 @@ void VKGSRender::update_vertex_env(u32 id, const vk::vertex_upload_info& vertex_
|
|||
base_offset = 0;
|
||||
}
|
||||
|
||||
u8 data_size = 16;
|
||||
u32 draw_info[5];
|
||||
|
||||
draw_info[0] = vertex_info.vertex_index_base;
|
||||
draw_info[1] = vertex_info.vertex_index_offset;
|
||||
draw_info[2] = id;
|
||||
draw_info[3] = (id * 16) + (base_offset / 8);
|
||||
rsx::simple_array<u32> dynamic_constants;
|
||||
dynamic_constants.push_back(vertex_info.vertex_index_base); // Vertex index base
|
||||
dynamic_constants.push_back(vertex_info.vertex_index_offset); // Vertex index offset
|
||||
dynamic_constants.push_back(id); // Draw id
|
||||
dynamic_constants.push_back((id * 16) + (base_offset / 8)); // Vertex layout offset
|
||||
dynamic_constants.push_back(m_xform_constants_dynamic_offset); // Vertex constants offset
|
||||
|
||||
if (vk::emulate_conditional_rendering())
|
||||
{
|
||||
draw_info[4] = cond_render_ctrl.hw_cond_active ? 1 : 0;
|
||||
data_size = 20;
|
||||
dynamic_constants.push_back(cond_render_ctrl.hw_cond_active ? 1 : 0);
|
||||
}
|
||||
|
||||
vkCmdPushConstants(*m_current_command_buffer, m_pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, 0, data_size, draw_info);
|
||||
vkCmdPushConstants(*m_current_command_buffer, m_pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, 0, dynamic_constants.size_bytes(), dynamic_constants.data());
|
||||
|
||||
const usz data_offset = (id * 128) + m_vertex_layout_stream_info.offset;
|
||||
auto dst = m_vertex_layout_ring_info.map(data_offset, 128);
|
||||
|
|
|
@ -160,6 +160,8 @@ private:
|
|||
VkDescriptorBufferInfo m_vertex_instructions_buffer_info {};
|
||||
VkDescriptorBufferInfo m_fragment_instructions_buffer_info {};
|
||||
|
||||
u32 m_xform_constants_dynamic_offset = 0; // We manage transform_constants dynamic offset manually to alleviate performance penalty of doing a hot-patch of constants.
|
||||
|
||||
std::array<vk::frame_context_t, VK_MAX_ASYNC_FRAMES> frame_context_storage;
|
||||
//Temp frame context to use if the real frame queue is overburdened. Only used for storage
|
||||
vk::frame_context_t m_aux_frame_context;
|
||||
|
|
|
@ -29,8 +29,9 @@ std::string VKVertexDecompilerThread::compareFunction(COMPARE f, const std::stri
|
|||
|
||||
void VKVertexDecompilerThread::insertHeader(std::stringstream &OS)
|
||||
{
|
||||
OS << "#version 450\n\n";
|
||||
OS << "#extension GL_ARB_separate_shader_objects : enable\n\n";
|
||||
OS <<
|
||||
"#version 450\n\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n\n";
|
||||
|
||||
OS <<
|
||||
"layout(std140, set = 0, binding = 0) uniform VertexContextBuffer\n"
|
||||
|
@ -59,7 +60,8 @@ void VKVertexDecompilerThread::insertHeader(std::stringstream &OS)
|
|||
" uint vertex_base_index;\n"
|
||||
" uint vertex_index_offset;\n"
|
||||
" uint draw_id;\n"
|
||||
" uint layout_ptr_offset;\n";
|
||||
" uint layout_ptr_offset;\n"
|
||||
" uint xform_constants_offset;\n";
|
||||
|
||||
if (m_device_props.emulate_conditional_rendering)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue