rsx: Minor optimizations

This commit is contained in:
kd-11 2018-02-09 13:32:30 +03:00
parent a5500ebfa4
commit bd297d079d
6 changed files with 46 additions and 10 deletions

View File

@ -297,7 +297,7 @@ void GLGSRender::end()
for (int i = 0; i < rsx::limits::fragment_textures_count; ++i)
{
if (m_program->uniforms.has_location("tex" + std::to_string(i), &unused_location))
if (m_program->uniforms.has_location(rsx::constants::fragment_texture_names[i], &unused_location))
{
auto sampler_state = static_cast<gl::texture_cache::sampled_image_descriptor*>(fs_sampler_state[i].get());
auto &tex = rsx::method_registers.fragment_textures[i];
@ -333,7 +333,7 @@ void GLGSRender::end()
for (int i = 0; i < rsx::limits::vertex_textures_count; ++i)
{
if (m_program->uniforms.has_location("vtex" + std::to_string(i), &unused_location))
if (m_program->uniforms.has_location(rsx::constants::vertex_texture_names[i], &unused_location))
{
auto sampler_state = static_cast<gl::texture_cache::sampled_image_descriptor*>(vs_sampler_state[i].get());
glActiveTexture(GL_TEXTURE0 + rsx::limits::fragment_textures_count + i);

View File

@ -729,6 +729,21 @@ namespace rsx
flush_commands_flag = false;
break;
}
case NV4097_SET_TEXTURE_OFFSET:
case NV4097_SET_TEXTURE_FORMAT:
case NV4097_SET_TEXTURE_ADDRESS:
case NV4097_SET_TEXTURE_CONTROL0:
case NV4097_SET_TEXTURE_CONTROL1:
case NV4097_SET_TEXTURE_FILTER:
case NV4097_SET_TEXTURE_IMAGE_RECT:
case NV4097_SET_TEXTURE_BORDER_COLOR:
{
//Safe to ignore if value has not changed
if (method_registers.test(reg, value))
flush_commands_flag = false;
break;
}
}
if (flush_commands_flag)

View File

@ -45,6 +45,20 @@ namespace rsx
};
}
namespace constants
{
static std::array<const char*, 16> fragment_texture_names =
{
"tex0", "tex1", "tex2", "tex3", "tex4", "tex5", "tex6", "tex7",
"tex8", "tex9", "tex10", "tex11", "tex12", "tex13", "tex14", "tex15",
};
static std::array<const char*, 4> vertex_texture_names =
{
"vtex0", "vtex1", "vtex2", "vtex3",
};
}
enum framebuffer_creation_context : u8
{
context_draw = 0,

View File

@ -1232,11 +1232,11 @@ void VKGSRender::end()
for (int i = 0; i < rsx::limits::fragment_textures_count; ++i)
{
if (m_program->has_uniform("tex" + std::to_string(i)))
if (m_program->has_uniform(rsx::constants::fragment_texture_names[i]))
{
if (!rsx::method_registers.fragment_textures[i].enabled())
{
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(*m_current_command_buffer), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "tex" + std::to_string(i), m_current_frame->descriptor_set);
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(*m_current_command_buffer), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, rsx::constants::fragment_texture_names[i], m_current_frame->descriptor_set);
continue;
}
@ -1252,21 +1252,21 @@ void VKGSRender::end()
if (!image_ptr)
{
LOG_ERROR(RSX, "Texture upload failed to texture index %d. Binding null sampler.", i);
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(*m_current_command_buffer), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "tex" + std::to_string(i), m_current_frame->descriptor_set);
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(*m_current_command_buffer), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, rsx::constants::fragment_texture_names[i], m_current_frame->descriptor_set);
continue;
}
m_program->bind_uniform({ fs_sampler_handles[i]->value, image_ptr->value, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "tex" + std::to_string(i), m_current_frame->descriptor_set);
m_program->bind_uniform({ fs_sampler_handles[i]->value, image_ptr->value, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, rsx::constants::fragment_texture_names[i], m_current_frame->descriptor_set);
}
}
for (int i = 0; i < rsx::limits::vertex_textures_count; ++i)
{
if (m_program->has_uniform("vtex" + std::to_string(i)))
if (m_program->has_uniform(rsx::constants::vertex_texture_names[i]))
{
if (!rsx::method_registers.vertex_textures[i].enabled())
{
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(*m_current_command_buffer), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "vtex" + std::to_string(i), m_current_frame->descriptor_set);
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(*m_current_command_buffer), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, rsx::constants::vertex_texture_names[i], m_current_frame->descriptor_set);
continue;
}
@ -1282,11 +1282,11 @@ void VKGSRender::end()
if (!image_ptr)
{
LOG_ERROR(RSX, "Texture upload failed to vtexture index %d. Binding null sampler.", i);
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(*m_current_command_buffer), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "vtex" + std::to_string(i), m_current_frame->descriptor_set);
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(*m_current_command_buffer), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, rsx::constants::vertex_texture_names[i], m_current_frame->descriptor_set);
continue;
}
m_program->bind_uniform({ vs_sampler_handles[i]->value, image_ptr->value, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "vtex" + std::to_string(i), m_current_frame->descriptor_set);
m_program->bind_uniform({ vs_sampler_handles[i]->value, image_ptr->value, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, rsx::constants::vertex_texture_names[i], m_current_frame->descriptor_set);
}
}

View File

@ -1190,6 +1190,11 @@ namespace rsx
registers[reg] = value;
}
bool rsx_state::test(u32 reg, u32 value) const
{
return registers[reg] == value;
}
namespace method_detail
{
template<int Id, int Step, int Count, template<u32> class T, int Index = 0>

View File

@ -189,6 +189,8 @@ namespace rsx
void decode(u32 reg, u32 value);
bool test(u32 reg, u32 value) const;
void reset();
template<typename Archive>