mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 04:51:26 +12:00
vk: Fix graphical bugs and crashes
This commit is contained in:
parent
356b2f5910
commit
aac4fbe941
6 changed files with 34 additions and 28 deletions
|
@ -176,7 +176,7 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
|||
{
|
||||
for (const ParamType& PT : m_parr.params[PF_PARAM_UNIFORM])
|
||||
{
|
||||
if (PT.type.starts_with("sampler1D"))
|
||||
if (!PT.type.starts_with("sampler"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
|||
);
|
||||
inputs.push_back(in);
|
||||
|
||||
OS << "layout(set=0, binding=" << in.location << ") uniform " << samplerType << " " << PI.name << ";\n";
|
||||
OS << "layout(set=1, binding=" << in.location << ") uniform " << samplerType << " " << PI.name << ";\n";
|
||||
|
||||
if (properties.redirected_sampler_mask & mask)
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
|||
in.location = vk_prog->binding_table.ftex_stencil_location[id];
|
||||
inputs.push_back(in);
|
||||
|
||||
OS << "layout(set=0, binding=" << in.location << ") uniform u" << samplerType << " " << in.name << ";\n";
|
||||
OS << "layout(set=1, binding=" << in.location << ") uniform u" << samplerType << " " << in.name << ";\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
|||
std::string constants_block;
|
||||
for (const ParamType& PT : m_parr.params[PF_PARAM_UNIFORM])
|
||||
{
|
||||
if (PT.type.starts_with("sampler1D"))
|
||||
if (PT.type.starts_with("sampler"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -249,13 +249,13 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
|||
|
||||
if (!constants_block.empty())
|
||||
{
|
||||
OS << "layout(std140, set = 1, binding = " << vk_prog->binding_table.cbuf_location << ") uniform FragmentConstantsBuffer\n";
|
||||
OS << "layout(std140, set=1, binding=" << vk_prog->binding_table.cbuf_location << ") uniform FragmentConstantsBuffer\n";
|
||||
OS << "{\n";
|
||||
OS << constants_block;
|
||||
OS << "};\n\n";
|
||||
}
|
||||
|
||||
OS << "layout(std140, set = 1, binding = " << vk_prog->binding_table.context_buffer_location << ") uniform FragmentStateBuffer\n";
|
||||
OS << "layout(std140, set=1, binding=" << vk_prog->binding_table.context_buffer_location << ") uniform FragmentStateBuffer\n";
|
||||
OS << "{\n";
|
||||
OS << " float fog_param0;\n";
|
||||
OS << " float fog_param1;\n";
|
||||
|
@ -267,12 +267,12 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
|||
OS << " float wpos_bias;\n";
|
||||
OS << "};\n\n";
|
||||
|
||||
OS << "layout(std140, set = 1, binding = " << vk_prog->binding_table.tex_param_location << ") uniform TextureParametersBuffer\n";
|
||||
OS << "layout(std140, set=1, binding=" << vk_prog->binding_table.tex_param_location << ") uniform TextureParametersBuffer\n";
|
||||
OS << "{\n";
|
||||
OS << " sampler_info texture_parameters[16];\n";
|
||||
OS << "};\n\n";
|
||||
|
||||
OS << "layout(std140, set = 1, binding = " << vk_prog->binding_table.polygon_stipple_params_location << ") uniform RasterizerHeap\n";
|
||||
OS << "layout(std140, set=1, binding=" << vk_prog->binding_table.polygon_stipple_params_location << ") uniform RasterizerHeap\n";
|
||||
OS << "{\n";
|
||||
OS << " uvec4 stipple_pattern[8];\n";
|
||||
OS << "};\n\n";
|
||||
|
@ -484,10 +484,7 @@ void VKFragmentProgram::Decompile(const RSXFragmentProgram& prog)
|
|||
{
|
||||
for (const ParamItem& PI : PT.items)
|
||||
{
|
||||
if (PT.type == "sampler1D" ||
|
||||
PT.type == "sampler2D" ||
|
||||
PT.type == "sampler3D" ||
|
||||
PT.type == "samplerCube")
|
||||
if (PT.type.starts_with("sampler"))
|
||||
continue;
|
||||
|
||||
usz offset = atoi(PI.name.c_str() + 2);
|
||||
|
|
|
@ -2078,11 +2078,15 @@ void VKGSRender::load_program_env()
|
|||
const auto& fs_binding_table = m_fragment_prog->binding_table;
|
||||
|
||||
m_program->bind_uniform(m_vertex_env_buffer_info, vk::glsl::binding_set_index_vertex, vs_binding_table.context_buffer_location);
|
||||
m_program->bind_uniform(m_vertex_constants_buffer_info, vk::glsl::binding_set_index_vertex, vs_binding_table.cbuf_location);
|
||||
m_program->bind_uniform(m_fragment_env_buffer_info, vk::glsl::binding_set_index_fragment, fs_binding_table.context_buffer_location);
|
||||
m_program->bind_uniform(m_fragment_texture_params_buffer_info, vk::glsl::binding_set_index_fragment, fs_binding_table.tex_param_location);
|
||||
m_program->bind_uniform(m_raster_env_buffer_info, vk::glsl::binding_set_index_fragment, fs_binding_table.polygon_stipple_params_location);
|
||||
|
||||
if (vs_binding_table.cbuf_location != umax)
|
||||
{
|
||||
m_program->bind_uniform(m_vertex_constants_buffer_info, vk::glsl::binding_set_index_vertex, vs_binding_table.cbuf_location);
|
||||
}
|
||||
|
||||
if (m_shader_interpreter.is_interpreter(m_program))
|
||||
{
|
||||
m_program->bind_uniform(m_vertex_instructions_buffer_info, vk::glsl::binding_set_index_vertex, m_shader_interpreter.get_vertex_instruction_location());
|
||||
|
|
|
@ -211,6 +211,11 @@ namespace vk
|
|||
auto& sink = m_sets[0];
|
||||
for (auto& set : m_sets)
|
||||
{
|
||||
if (&set == &sink)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto& type_arr : set.m_inputs)
|
||||
{
|
||||
if (type_arr.empty())
|
||||
|
@ -279,6 +284,8 @@ namespace vk
|
|||
return u.name == uniform_name;
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::pair<u32, u32> program::get_uniform_location(::glsl::program_domain domain, program_input_type type, const std::string& uniform_name)
|
||||
|
@ -441,8 +448,8 @@ namespace vk
|
|||
{
|
||||
if (!m_descriptor_pool)
|
||||
{
|
||||
create_descriptor_pool();
|
||||
create_descriptor_set_layout();
|
||||
create_descriptor_pool();
|
||||
}
|
||||
|
||||
return m_descriptor_pool->allocate(m_descriptor_set_layout);
|
||||
|
@ -463,9 +470,6 @@ namespace vk
|
|||
return;
|
||||
}
|
||||
|
||||
auto old_set = m_descriptor_set.value();
|
||||
auto new_set = allocate_descriptor_set();
|
||||
|
||||
auto push_descriptor_slot = [this](unsigned idx)
|
||||
{
|
||||
const auto& slot = m_descriptor_slots[idx];
|
||||
|
@ -504,16 +508,18 @@ namespace vk
|
|||
|
||||
m_copy_cmds.push_back({
|
||||
.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET,
|
||||
.srcSet = old_set,
|
||||
.srcSet = m_previous_set,
|
||||
.srcBinding = i,
|
||||
.dstSet = new_set,
|
||||
.dstSet = m_descriptor_set.value(),
|
||||
.dstBinding = i,
|
||||
.descriptorCount = 1
|
||||
});
|
||||
}
|
||||
|
||||
m_descriptor_set.push(m_copy_cmds); // Write previous state
|
||||
m_descriptor_set = new_set;
|
||||
|
||||
m_previous_set = m_descriptor_set.value();
|
||||
m_descriptor_set = allocate_descriptor_set();
|
||||
}
|
||||
|
||||
void descriptor_table_t::create_descriptor_set_layout()
|
||||
|
|
|
@ -121,6 +121,7 @@ namespace vk
|
|||
vk::descriptor_set m_descriptor_set{};
|
||||
rsx::simple_array<VkDescriptorPoolSize> m_descriptor_pool_sizes;
|
||||
rsx::simple_array<VkDescriptorType> m_descriptor_types;
|
||||
VkDescriptorSet m_previous_set = VK_NULL_HANDLE;
|
||||
|
||||
std::vector<descriptor_slot_t> m_descriptor_slots;
|
||||
std::vector<bool> m_descriptors_dirty;
|
||||
|
|
|
@ -76,7 +76,7 @@ void VKVertexDecompilerThread::insertHeader(std::stringstream &OS)
|
|||
"#extension GL_ARB_separate_shader_objects : enable\n\n";
|
||||
|
||||
OS <<
|
||||
"layout(std140, set = 0, binding = " << vk_prog->binding_table.context_buffer_location << " ) uniform VertexContextBuffer\n"
|
||||
"layout(std140, set=0, binding=" << vk_prog->binding_table.context_buffer_location << ") uniform VertexContextBuffer\n"
|
||||
"{\n"
|
||||
" mat4 scale_offset_mat;\n"
|
||||
" ivec4 user_clip_enabled[2];\n"
|
||||
|
@ -99,7 +99,7 @@ void VKVertexDecompilerThread::insertHeader(std::stringstream &OS)
|
|||
if (m_device_props.emulate_conditional_rendering)
|
||||
{
|
||||
OS <<
|
||||
"layout(std430, set = 0, binding = " << vk_prog->binding_table.cr_pred_buffer_location << ") readonly buffer EXT_Conditional_Rendering\n"
|
||||
"layout(std430, set=0, binding=" << vk_prog->binding_table.cr_pred_buffer_location << ") readonly buffer EXT_Conditional_Rendering\n"
|
||||
"{\n"
|
||||
" uint conditional_rendering_predicate;\n"
|
||||
"};\n\n";
|
||||
|
@ -219,10 +219,7 @@ void VKVertexDecompilerThread::insertConstants(std::stringstream & OS, const std
|
|||
}
|
||||
}
|
||||
|
||||
if (PT.type == "sampler2D" ||
|
||||
PT.type == "samplerCube" ||
|
||||
PT.type == "sampler1D" ||
|
||||
PT.type == "sampler3D")
|
||||
if (PT.type.starts_with("sampler"))
|
||||
{
|
||||
const int id = vk::get_texture_index(PI.name);
|
||||
in.location = vk_prog->binding_table.vtex_location[id];
|
||||
|
@ -249,7 +246,7 @@ void VKVertexDecompilerThread::insertConstants(std::stringstream & OS, const std
|
|||
}
|
||||
}
|
||||
|
||||
OS << "layout(set = 0, binding=" << in.location << ") uniform " << samplerType << " " << PI.name << ";\n";
|
||||
OS << "layout(set=0, binding=" << in.location << ") uniform " << samplerType << " " << PI.name << ";\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -435,7 +435,8 @@ namespace vk
|
|||
|
||||
void descriptor_set::bind(const vk::command_buffer& cmd, VkPipelineBindPoint bind_point, VkPipelineLayout layout)
|
||||
{
|
||||
if ((m_push_type_mask & ~m_update_after_bind_mask) || (m_pending_writes.size() >= max_cache_size))
|
||||
if ((m_push_type_mask & ~m_update_after_bind_mask) ||
|
||||
(m_pending_writes.size() >= max_cache_size))
|
||||
{
|
||||
flush();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue