1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-02-01 04:51:49 +01:00

rsx: Handle vertex shaders with no constant references

- If no vc[] refs exist, do not upload anything!
This commit is contained in:
kd-11 2022-03-24 01:23:20 +03:00 committed by kd-11
parent d057ffe80f
commit de0e660d28
4 changed files with 24 additions and 25 deletions

View File

@ -800,14 +800,17 @@ void GLGSRender::load_program_env()
if (update_transform_constants)
{
// Vertex constants
const std::vector<u16>& constant_ids = m_vertex_prog ? m_vertex_prog->constant_ids : std::vector<u16>{};
const usz transform_constants_size = constant_ids.empty() ? 8192 : constant_ids.size() * 16;
const usz transform_constants_size = (!m_vertex_prog || m_vertex_prog->has_indexed_constants) ? 8192 : m_vertex_prog->constant_ids.size() * 16;
if (transform_constants_size)
{
auto mapping = m_transform_constants_buffer->alloc_from_heap(transform_constants_size, m_uniform_buffer_offset_align);
auto buf = static_cast<u8*>(mapping.first);
auto mapping = m_transform_constants_buffer->alloc_from_heap(transform_constants_size, m_uniform_buffer_offset_align);
auto buf = static_cast<u8*>(mapping.first);
fill_vertex_program_constants_data(buf, m_vertex_prog ? m_vertex_prog->constant_ids : std::vector<u16>{});
const std::vector<u16>& constant_ids = (transform_constants_size == 8192) ? std::vector<u16>{} : m_vertex_prog->constant_ids;
fill_vertex_program_constants_data(buf, m_vertex_prog ? m_vertex_prog->constant_ids : std::vector<u16>{});
m_transform_constants_buffer->bind_range(GL_VERTEX_CONSTANT_BUFFERS_BIND_SLOT, mapping.second, transform_constants_size);
m_transform_constants_buffer->bind_range(GL_VERTEX_CONSTANT_BUFFERS_BIND_SLOT, mapping.second, transform_constants_size);
}
}
if (update_fragment_constants && !update_instruction_buffers)

View File

@ -276,11 +276,8 @@ void GLVertexProgram::Decompile(const RSXVertexProgram& prog)
GLVertexDecompilerThread decompiler(prog, source, parr);
decompiler.Task();
if (has_indexed_constants = decompiler.properties.has_indexed_constants;
!has_indexed_constants)
{
constant_ids = std::vector<u16>(decompiler.m_constant_ids.begin(), decompiler.m_constant_ids.end());
}
has_indexed_constants = decompiler.properties.has_indexed_constants;
constant_ids = std::vector<u16>(decompiler.m_constant_ids.begin(), decompiler.m_constant_ids.end());
shader.create(::glsl::program_domain::glsl_vertex_program, source);
id = shader.id();

View File

@ -1952,18 +1952,20 @@ void VKGSRender::load_program_env()
if (update_transform_constants)
{
check_heap_status(VK_HEAP_CHECK_TRANSFORM_CONSTANTS_STORAGE);
// Transform constants
const std::vector<u16>& constant_ids = m_vertex_prog ? m_vertex_prog->constant_ids : std::vector<u16>{};
const usz transform_constants_size = constant_ids.empty() ? 8192 : utils::align(constant_ids.size() * 16, m_device->gpu().get_limits().minUniformBufferOffsetAlignment);
const usz transform_constants_size = (!m_vertex_prog || m_vertex_prog->has_indexed_constants) ? 8192 : m_vertex_prog->constant_ids.size() * 16;
if (transform_constants_size)
{
check_heap_status(VK_HEAP_CHECK_TRANSFORM_CONSTANTS_STORAGE);
auto mem = m_transform_constants_ring_info.alloc<1>(transform_constants_size);
auto buf = m_transform_constants_ring_info.map(mem, transform_constants_size);
auto mem = m_transform_constants_ring_info.alloc<1>(transform_constants_size);
auto buf = m_transform_constants_ring_info.map(mem, transform_constants_size);
fill_vertex_program_constants_data(buf, constant_ids);
m_transform_constants_ring_info.unmap();
m_vertex_constants_buffer_info = { m_transform_constants_ring_info.heap->value, mem, transform_constants_size };
const std::vector<u16>& constant_ids = (transform_constants_size == 8192) ? std::vector<u16>{} : m_vertex_prog->constant_ids;
fill_vertex_program_constants_data(buf, constant_ids);
m_transform_constants_ring_info.unmap();
m_vertex_constants_buffer_info = { m_transform_constants_ring_info.heap->value, mem, transform_constants_size };
}
}
if (update_fragment_constants && !update_instruction_buffers)

View File

@ -350,11 +350,8 @@ void VKVertexProgram::Decompile(const RSXVertexProgram& prog)
VKVertexDecompilerThread decompiler(prog, source, parr, *this);
decompiler.Task();
if (has_indexed_constants = decompiler.properties.has_indexed_constants;
!has_indexed_constants)
{
constant_ids = std::vector<u16>(decompiler.m_constant_ids.begin(), decompiler.m_constant_ids.end());
}
has_indexed_constants = decompiler.properties.has_indexed_constants;
constant_ids = std::vector<u16>(decompiler.m_constant_ids.begin(), decompiler.m_constant_ids.end());
shader.create(::glsl::program_domain::glsl_vertex_program, source);
}