diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index ca44dd7afb..d60c69b75e 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -5,6 +5,27 @@ #include #include "Utilities/GSL.h" +namespace rsx +{ + enum texture_upload_context + { + shader_read = 0, + blit_engine_src = 1, + blit_engine_dst = 2, + framebuffer_storage = 3 + }; + + //Sampled image descriptor + struct sampled_image_descriptor_base + { + texture_upload_context upload_context = texture_upload_context::shader_read; + rsx::texture_dimension_extended image_type = texture_dimension_extended::texture_dimension_2d; + bool is_depth_texture = false; + f32 scale_x = 1.f; + f32 scale_y = 1.f; + }; +} + struct rsx_subresource_layout { gsl::span data; @@ -39,4 +60,4 @@ u8 get_format_block_size_in_bytes(rsx::surface_color_format format); * Get number of bytes occupied by texture in RSX mem */ size_t get_texture_size(const rsx::fragment_texture &texture); -size_t get_texture_size(const rsx::vertex_texture &texture); +size_t get_texture_size(const rsx::vertex_texture &texture); \ No newline at end of file diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index d0099e71d1..59176a8ca5 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -17,30 +17,12 @@ namespace rsx swapped_native_component_order = 2, }; - enum texture_upload_context - { - shader_read = 0, - blit_engine_src = 1, - blit_engine_dst = 2, - framebuffer_storage = 3 - }; - enum texture_sampler_status { status_uninitialized = 0, status_ready = 1 }; - //Sampled image descriptor - struct sampled_image_descriptor_base - { - texture_upload_context upload_context = texture_upload_context::shader_read; - rsx::texture_dimension_extended image_type = texture_dimension_extended::texture_dimension_2d; - bool is_depth_texture = false; - f32 scale_x = 1.f; - f32 scale_y = 1.f; - }; - struct cached_texture_section : public rsx::buffered_section { u16 width; diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index efa4b92763..fe5460255e 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -252,7 +252,7 @@ void GLGSRender::end() *sampler_state = m_gl_texture_cache.upload_texture(unused, rsx::method_registers.fragment_textures[i], m_rtts); if (m_textures_dirty[i]) - m_gl_sampler_states[i].apply(rsx::method_registers.fragment_textures[i]); + m_gl_sampler_states[i].apply(rsx::method_registers.fragment_textures[i], fs_sampler_state[i].get()); } else { diff --git a/rpcs3/Emu/RSX/GL/GLTexture.cpp b/rpcs3/Emu/RSX/GL/GLTexture.cpp index 721c2b5bc8..247073c188 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.cpp +++ b/rpcs3/Emu/RSX/GL/GLTexture.cpp @@ -133,7 +133,7 @@ namespace gl } //Apply sampler state settings - void sampler_state::apply(rsx::fragment_texture& tex) + void sampler_state::apply(rsx::fragment_texture& tex, const rsx::sampled_image_descriptor_base* sampled_image) { const f32 border_color = (f32)tex.border_color() / 255; const f32 border_color_array[] = { border_color, border_color, border_color, border_color }; @@ -143,7 +143,8 @@ namespace gl glSamplerParameteri(samplerHandle, GL_TEXTURE_WRAP_R, wrap_mode(tex.wrap_r())); glSamplerParameterfv(samplerHandle, GL_TEXTURE_BORDER_COLOR, border_color_array); - if (tex.get_exact_mipmap_count() <= 1) + if (sampled_image->upload_context != rsx::texture_upload_context::shader_read || + tex.get_exact_mipmap_count() <= 1) { GLint min_filter = tex_min_filter(tex.min_filter()); diff --git a/rpcs3/Emu/RSX/GL/GLTexture.h b/rpcs3/Emu/RSX/GL/GLTexture.h index 34cdd78c58..c2a0eb203c 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.h +++ b/rpcs3/Emu/RSX/GL/GLTexture.h @@ -52,6 +52,6 @@ namespace gl glBindSampler(index, samplerHandle); } - void apply(rsx::fragment_texture& tex); + void apply(rsx::fragment_texture& tex, const rsx::sampled_image_descriptor_base* sampled_image); }; } diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 79048f445d..2abf0e4e5d 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -1149,7 +1149,8 @@ void VKGSRender::end() std::tie(min_filter, mip_mode) = vk::get_min_filter_and_mip(rsx::method_registers.fragment_textures[i].min_filter()); - if (rsx::method_registers.fragment_textures[i].get_exact_mipmap_count() > 1) + if (sampler_state->upload_context == rsx::texture_upload_context::shader_read && + rsx::method_registers.fragment_textures[i].get_exact_mipmap_count() > 1) { min_lod = (float)(rsx::method_registers.fragment_textures[i].min_lod() >> 8); max_lod = (float)(rsx::method_registers.fragment_textures[i].max_lod() >> 8);