From 4260f68f852a97093429ea61ce2edb2a387404ff Mon Sep 17 00:00:00 2001 From: kd-11 Date: Wed, 8 Jun 2016 12:39:08 +0300 Subject: [PATCH] gl/vk: Fix ub256 and s32k vertex attributes; silence some unnecessary debug errors (#1757) * gl/vk: Sample integer attribs with integer samplers * gl: silence useless DPRINTs where behaviour has already proven correct --- rpcs3/Emu/RSX/GL/GLVertexProgram.cpp | 27 ++++++++++++++++++++++----- rpcs3/Emu/RSX/GL/gl_texture_cache.h | 10 ---------- rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp | 8 ++++---- rpcs3/Emu/RSX/VK/VKVertexProgram.cpp | 25 ++++++++++++++++++++----- 4 files changed, 46 insertions(+), 24 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp index f24f3e5771..94be8b220b 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp @@ -66,7 +66,20 @@ void GLVertexDecompilerThread::insertInputs(std::stringstream & OS, const std::v for (const ParamItem &PI : PT.items) { if (PI.name == std::get<1>(item)) - OS << "layout(location=" << location++ << ")" << " uniform samplerBuffer" << " " << PI.name << "_buffer;" << std::endl; + { + bool is_int = false; + for (auto &attrib : rsx_vertex_program.rsx_vertex_inputs) + { + if (attrib.location == std::get<0>(item)) + { + if (attrib.int_type) is_int = true; + break; + } + } + + std::string samplerType = is_int ? "isamplerBuffer" : "samplerBuffer"; + OS << "layout(location=" << location++ << ")" << " uniform " << samplerType << " " << PI.name << "_buffer;" << std::endl; + } } } } @@ -134,9 +147,13 @@ void add_input(std::stringstream & OS, const ParamItem &PI, const std::vectorlocked && region->block_sz != size) { - LOG_NOTICE(RSX, "Unlocking RTT since size has changed!"); unlock_memory_region((u32)region->data_addr, region->block_sz); - LOG_NOTICE(RSX, "Locking down RTT after size change!"); region->block_sz = size; lock_memory_region((u32)region->data_addr, region->block_sz); region->locked = true; @@ -517,7 +509,6 @@ namespace gl if (tex.protected_block_start <= address && tex.protected_block_sz >(address - tex.protected_block_start)) { - LOG_NOTICE(RSX, "Texture object is dirty! %d", tex.gl_id); unlock_gl_object(tex); invalidate_rtts_in_range((u32)tex.data_addr, tex.block_sz); @@ -541,7 +532,6 @@ namespace gl u32 offset = address - rtt_aligned_base; if (offset >= rtt_block_sz) continue; - LOG_NOTICE(RSX, "Dirty non-texture RTT FOUND! addr=0x%X", rtt.data_addr); rtt.is_dirty = true; unlock_memory_region(rtt_aligned_base, rtt_block_sz); diff --git a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp index 0713ea9cc8..77d6cfb849 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp @@ -41,10 +41,10 @@ namespace vk * Set up buffer fetches to only work on 4-component access. This is hardware dependant so we use 4-component access to avoid branching based on IHV implementation * AMD GCN 1.0 for example does not support RGB32 formats for texel buffers */ - const VkFormat vec1_types[] = { VK_FORMAT_R16_UNORM, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R8_UNORM, VK_FORMAT_R16_SINT, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R8_UNORM }; - const VkFormat vec2_types[] = { VK_FORMAT_R16G16_UNORM, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R16G16_SINT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R8G8_UNORM }; - const VkFormat vec3_types[] = { VK_FORMAT_R16G16B16A16_UNORM, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM }; //VEC3 COMPONENTS NOT SUPPORTED! - const VkFormat vec4_types[] = { VK_FORMAT_R16G16B16A16_UNORM, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM }; + const VkFormat vec1_types[] = { VK_FORMAT_R16_UNORM, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R8_UNORM, VK_FORMAT_R16_SINT, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R8_UINT }; + const VkFormat vec2_types[] = { VK_FORMAT_R16G16_UNORM, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R16G16_SINT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R8G8_UINT }; + const VkFormat vec3_types[] = { VK_FORMAT_R16G16B16A16_UNORM, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UINT }; //VEC3 COMPONENTS NOT SUPPORTED! + const VkFormat vec4_types[] = { VK_FORMAT_R16G16B16A16_UNORM, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UINT }; const VkFormat* vec_selectors[] = { 0, vec1_types, vec2_types, vec3_types, vec4_types }; diff --git a/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp b/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp index 8f1523b7df..0d92043266 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp @@ -82,8 +82,19 @@ void VKVertexDecompilerThread::insertInputs(std::stringstream & OS, const std::v in.type = vk::glsl::input_type_texel_buffer; this->inputs.push_back(in); + + bool is_int = false; + for (auto &attrib : rsx_vertex_program.rsx_vertex_inputs) + { + if (attrib.location == std::get<0>(item)) + { + if (attrib.int_type) is_int = true; + break; + } + } - OS << "layout(set = 0, binding=" << 3 + location++ << ")" << " uniform samplerBuffer" << " " << PI.name << "_buffer;" << std::endl; + std::string samplerType = is_int ? "isamplerBuffer" : "samplerBuffer"; + OS << "layout(set = 0, binding=" << 3 + location++ << ")" << " uniform " << samplerType << " " << PI.name << "_buffer;" << std::endl; } } } @@ -171,9 +182,13 @@ namespace vk if (real_input.location != PI.location) continue; + std::string vecType = " vec4 "; + if (real_input.int_type) + vecType = " ivec4 "; + if (!real_input.is_array) { - OS << " vec4 " << PI.name << " = texelFetch(" << PI.name << "_buffer, 0);" << std::endl; + OS << vecType << PI.name << " = texelFetch(" << PI.name << "_buffer, 0);" << std::endl; return; } @@ -181,15 +196,15 @@ namespace vk { if (real_input.is_modulo) { - OS << " vec4 " << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexIndex %" << real_input.frequency << ");" << std::endl; + OS << vecType << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexIndex %" << real_input.frequency << ");" << std::endl; return; } - OS << " vec4 " << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexIndex /" << real_input.frequency << ");" << std::endl; + OS << vecType << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexIndex /" << real_input.frequency << ");" << std::endl; return; } - OS << " vec4 " << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexIndex).rgba;" << std::endl; + OS << vecType << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexIndex).rgba;" << std::endl; return; }