Permalink
Browse files

gl/vk/dx12: Fix depth reconstruction bug; Fix sampler parameters (#2188)

vulkan: Fix duplicated code bug

fix rebase
1 parent 22b1400 commit 7a9841bb2a1d703fd9269adda9e02f6ac4686de3 @kd-11 kd-11 committed with raven02 Oct 4, 2016
@@ -51,6 +51,9 @@ void D3D12GSRender::load_program()
const u32 texaddr = rsx::get_address(tex.offset(), tex.location());
if (m_rtts.get_texture_from_depth_stencil_if_applicable(texaddr))
{
+ if (m_rtts.get_texture_from_render_target_if_applicable(texaddr))
+ continue;
+
u32 format = tex.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
if (format == CELL_GCM_TEXTURE_A8R8G8B8 || format == CELL_GCM_TEXTURE_D8R8G8B8)
{
@@ -661,6 +661,10 @@ bool GLGSRender::load_program()
const u32 texaddr = rsx::get_address(tex.offset(), tex.location());
if (m_rtts.get_texture_from_depth_stencil_if_applicable(texaddr))
{
+ //Ignore this rtt since we have an aloasing color texture that will be used
+ if (m_rtts.get_texture_from_render_target_if_applicable(texaddr))
+ continue;
+
u32 format = tex.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
if (format == CELL_GCM_TEXTURE_A8R8G8B8 || format == CELL_GCM_TEXTURE_D8R8G8B8)
{
@@ -486,6 +486,7 @@ namespace rsx
const std::array<GLenum, 4>& glRemap = get_swizzle_remap(format);
+ glTexParameteri(m_target, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(m_target, GL_TEXTURE_MAX_LEVEL, tex.get_exact_mipmap_count() - 1);
u8 remap_a = tex.remap() & 0x3;
@@ -502,22 +503,43 @@ namespace rsx
__glcheck glTexParameteri(m_target, GL_TEXTURE_WRAP_T, gl_wrap(tex.wrap_t()));
__glcheck glTexParameteri(m_target, GL_TEXTURE_WRAP_R, gl_wrap(tex.wrap_r()));
- __glcheck glTexParameterf(m_target, GL_TEXTURE_LOD_BIAS, tex.bias());
- __glcheck glTexParameteri(m_target, GL_TEXTURE_MIN_LOD, (tex.min_lod() >> 8));
- __glcheck glTexParameteri(m_target, GL_TEXTURE_MAX_LOD, (tex.max_lod() >> 8));
-
- int min_filter = gl_tex_min_filter(tex.min_filter());
-
- if (min_filter != GL_LINEAR && min_filter != GL_NEAREST)
+ if (tex.get_exact_mipmap_count() <= 1 || m_target == GL_TEXTURE_RECTANGLE)
{
- if (tex.get_exact_mipmap_count() <= 1 || m_target == GL_TEXTURE_RECTANGLE)
+ GLint min_filter = gl_tex_min_filter(tex.min_filter());
+
+ if (min_filter != GL_LINEAR && min_filter != GL_NEAREST)
{
LOG_WARNING(RSX, "Texture %d, target 0x%x, requesting mipmap filtering without any mipmaps set!", m_id, m_target);
- min_filter = GL_LINEAR;
+
+ switch (min_filter)
+ {
+ case GL_NEAREST_MIPMAP_NEAREST:
+ case GL_NEAREST_MIPMAP_LINEAR:
+ min_filter = GL_NEAREST; break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ min_filter = GL_LINEAR; break;
+ default:
+ LOG_ERROR(RSX, "No mipmap fallback defined for rsx_min_filter = 0x%X", (u32)tex.min_filter());
+ min_filter = GL_NEAREST;
+ }
}
+
+ __glcheck glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, min_filter);
+
+ __glcheck glTexParameterf(m_target, GL_TEXTURE_LOD_BIAS, 0.);
+ __glcheck glTexParameteri(m_target, GL_TEXTURE_MIN_LOD, 0);
+ __glcheck glTexParameteri(m_target, GL_TEXTURE_MAX_LOD, 0);
+ }
+ else
+ {
+ __glcheck glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, gl_tex_min_filter(tex.min_filter()));
+
+ __glcheck glTexParameterf(m_target, GL_TEXTURE_LOD_BIAS, tex.bias());
+ __glcheck glTexParameteri(m_target, GL_TEXTURE_MIN_LOD, (tex.min_lod() >> 8));
+ __glcheck glTexParameteri(m_target, GL_TEXTURE_MAX_LOD, (tex.max_lod() >> 8));
}
- __glcheck glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, min_filter);
__glcheck glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, gl_tex_mag_filter(tex.mag_filter()));
__glcheck glTexParameterf(m_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_aniso(tex.max_aniso()));
}
@@ -683,48 +683,27 @@ void VKGSRender::end()
VkFilter min_filter;
VkSamplerMipmapMode mip_mode;
+ float min_lod = 0.f, max_lod = 0.f;
+ float lod_bias = 0.f;
+
std::tie(min_filter, mip_mode) = vk::get_min_filter_and_mip(rsx::method_registers.fragment_textures[i].min_filter());
- m_sampler_to_clean.push_back(std::make_unique<vk::sampler>(
- *m_device,
- vk::vk_wrap_mode(rsx::method_registers.fragment_textures[i].wrap_s()), vk::vk_wrap_mode(rsx::method_registers.fragment_textures[i].wrap_t()), vk::vk_wrap_mode(rsx::method_registers.fragment_textures[i].wrap_r()),
- !!(rsx::method_registers.fragment_textures[i].format() & CELL_GCM_TEXTURE_UN),
- rsx::method_registers.fragment_textures[i].bias(), vk::max_aniso(rsx::method_registers.fragment_textures[i].max_aniso()), rsx::method_registers.fragment_textures[i].min_lod(), rsx::method_registers.fragment_textures[i].max_lod(),
- min_filter, vk::get_mag_filter(rsx::method_registers.fragment_textures[i].mag_filter()), mip_mode, vk::get_border_color(rsx::method_registers.fragment_textures[i].border_color())
- ));
-
- m_program->bind_uniform({ m_sampler_to_clean.back()->value, texture0->value, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "tex" + std::to_string(i), descriptor_sets);
- }
- }
-
- for (int i = 0; i < rsx::limits::fragment_textures_count; ++i)
- {
- if (m_program->has_uniform("tex" + std::to_string(i)))
- {
- if (!rsx::method_registers.fragment_textures[i].enabled())
+ if (rsx::method_registers.fragment_textures[i].get_exact_mipmap_count() > 1)
{
- m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "tex" + std::to_string(i), descriptor_sets);
- continue;
+ min_lod = (float)(rsx::method_registers.fragment_textures[i].min_lod() >> 8);
+ max_lod = (float)(rsx::method_registers.fragment_textures[i].max_lod() >> 8);
+ lod_bias = rsx::method_registers.fragment_textures[i].bias();
}
-
- vk::image_view *texture0 = m_texture_cache.upload_texture(m_command_buffer, rsx::method_registers.fragment_textures[i], m_rtts, m_memory_type_mapping, m_texture_upload_buffer_ring_info, m_texture_upload_buffer_ring_info.heap.get());
-
- if (!texture0)
+ else
{
- 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(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "tex" + std::to_string(i), descriptor_sets);
- continue;
+ mip_mode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
}
-
- VkFilter min_filter;
- VkSamplerMipmapMode mip_mode;
- std::tie(min_filter, mip_mode) = vk::get_min_filter_and_mip(rsx::method_registers.fragment_textures[i].min_filter());
-
+
m_sampler_to_clean.push_back(std::make_unique<vk::sampler>(
*m_device,
vk::vk_wrap_mode(rsx::method_registers.fragment_textures[i].wrap_s()), vk::vk_wrap_mode(rsx::method_registers.fragment_textures[i].wrap_t()), vk::vk_wrap_mode(rsx::method_registers.fragment_textures[i].wrap_r()),
!!(rsx::method_registers.fragment_textures[i].format() & CELL_GCM_TEXTURE_UN),
- rsx::method_registers.fragment_textures[i].bias(), vk::max_aniso(rsx::method_registers.fragment_textures[i].max_aniso()), rsx::method_registers.fragment_textures[i].min_lod(), rsx::method_registers.fragment_textures[i].max_lod(),
+ lod_bias, vk::max_aniso(rsx::method_registers.fragment_textures[i].max_aniso()), min_lod, max_lod,
min_filter, vk::get_mag_filter(rsx::method_registers.fragment_textures[i].mag_filter()), mip_mode, vk::get_border_color(rsx::method_registers.fragment_textures[i].border_color())
));
@@ -983,6 +962,9 @@ bool VKGSRender::load_program()
const u32 texaddr = rsx::get_address(tex.offset(), tex.location());
if (m_rtts.get_texture_from_depth_stencil_if_applicable(texaddr))
{
+ if (m_rtts.get_texture_from_render_target_if_applicable(texaddr))
+ continue;
+
u32 format = tex.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
if (format == CELL_GCM_TEXTURE_A8R8G8B8 || format == CELL_GCM_TEXTURE_D8R8G8B8)
{

0 comments on commit 7a9841b

Please sign in to comment.