diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 339ea8a8d1..4cfb7485e7 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -364,7 +364,7 @@ void write_vertex_array_data_to_buffer(gsl::span raw_dst_span, gsl::s //Sometimes, we get a vertex attribute to be repeated. Just copy the supplied vertices only //TODO: Stop these requests from getting here in the first place! //TODO: Check if it is possible to have a repeating array with more than one attribute instance - const u32 real_count = src_ptr.size_bytes() / attribute_src_stride; + const u32 real_count = (u32)src_ptr.size_bytes() / attribute_src_stride; if (real_count == 1) attribute_src_stride = 0; //Always fetch src[0] //TODO: Determine favourable vertex threshold where vector setup costs become negligible diff --git a/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp b/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp index 4eec853e77..b7caa76b64 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp @@ -106,7 +106,7 @@ std::string compareFunctionImp(COMPARE f, const std::string &Op0, const std::str } } -void insert_d3d12_legacy_function(std::ostream& OS) +void insert_d3d12_legacy_function(std::ostream& OS, bool is_fragment_program) { OS << "float4 lit_legacy(float4 val)"; OS << "{\n"; @@ -121,6 +121,9 @@ void insert_d3d12_legacy_function(std::ostream& OS) OS << " return result;\n"; OS << "}\n\n"; + if (!is_fragment_program) + return; + OS << "uint packSnorm2x16(float2 val)"; OS << "{\n"; OS << " uint high_bits = round(clamp(val.x, -1., 1.) * 32767.);\n"; diff --git a/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.h b/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.h index 7f088418e4..251f1d4742 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.h @@ -6,4 +6,4 @@ std::string getFloatTypeNameImp(size_t elementCount); std::string getFunctionImp(FUNCTION f); std::string compareFunctionImp(COMPARE f, const std::string &Op0, const std::string &Op1); -void insert_d3d12_legacy_function(std::ostream&); +void insert_d3d12_legacy_function(std::ostream&, bool is_fragment_program); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp index 49387e276a..089a25d9ed 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp @@ -196,12 +196,14 @@ namespace case rsx::texture_dimension_extended::texture_dimension_3d: case rsx::texture_dimension_extended::texture_dimension_cubemap: return " " + tex_name + " (" + sampler_name + ", " + coord_name + ".xyz) "; } + + fmt::throw_exception("Invalid texture dimension %d" HERE, (u32)prog.get_texture_dimension(index)); } } void D3D12FragmentDecompiler::insertMainStart(std::stringstream & OS) { - insert_d3d12_legacy_function(OS); + insert_d3d12_legacy_function(OS, true); const std::set output_value = { diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp index 4d3651872e..ca919feceb 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp @@ -119,6 +119,9 @@ void D3D12GSRender::load_program() case D3D12_BLEND_INV_BLEND_FACTOR: return D3D12_BLEND_ZERO; } + + LOG_ERROR(RSX, "No suitable conversion defined for blend factor 0x%X" HERE, (u32)in); + return in; }; d3d_sfactor_rgb = flatten_d3d12_factor(d3d_sfactor_rgb); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.cpp b/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.cpp index c3f8d1517e..3080d881c8 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.cpp @@ -170,7 +170,7 @@ namespace void D3D12VertexProgramDecompiler::insertMainStart(std::stringstream & OS) { - insert_d3d12_legacy_function(OS); + insert_d3d12_legacy_function(OS, false); OS << "PixelInput main(uint vertex_id : SV_VertexID)" << std::endl; OS << "{" << std::endl; @@ -203,11 +203,11 @@ void D3D12VertexProgramDecompiler::insertMainEnd(std::stringstream & OS) { OS << " PixelInput Out = (PixelInput)0;" << std::endl; - bool insert_front_diffuse = (rsx_vertex_program.output_mask & 1); - bool insert_front_specular = (rsx_vertex_program.output_mask & 2); + bool insert_front_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTDIFFUSE) != 0; + bool insert_front_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTSPECULAR) != 0; - bool insert_back_diffuse = (rsx_vertex_program.output_mask & 4); - bool insert_back_specular = (rsx_vertex_program.output_mask & 8); + bool insert_back_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_BACKDIFFUSE) != 0; + bool insert_back_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_BACKSPECULAR) != 0; // Declare inside main function for (auto &i : reg_table) diff --git a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp index 6f22b3f266..770ab69c2c 100644 --- a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp @@ -105,7 +105,7 @@ std::string compareFunctionImpl(COMPARE f, const std::string &Op0, const std::st fmt::throw_exception("Unknown compare function" HERE); } -void insert_glsl_legacy_function(std::ostream& OS) +void insert_glsl_legacy_function(std::ostream& OS, gl::glsl::program_domain domain) { OS << "vec4 lit_legacy(vec4 val)"; OS << "{\n"; @@ -120,6 +120,9 @@ void insert_glsl_legacy_function(std::ostream& OS) OS << " return result;\n"; OS << "}\n\n"; + if (domain != gl::glsl::program_domain::glsl_fragment_program) + return; + //NOTE: We lose precision if we just store depth value into 8-bit textures i.e (depth, 0, 0) //NOTE2: After testing with GOW, the w component is either the original depth or wraps around to the x component //Since component.r == depth_value with some precision loss, just use the precise depth value for now (further testing needed) diff --git a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.h b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.h index e2a11f6cb6..2359a45fb5 100644 --- a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.h +++ b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.h @@ -1,9 +1,10 @@ #pragma once #include "../Common/ShaderParam.h" +#include "GLHelpers.h" #include std::string getFloatTypeNameImpl(size_t elementCount); std::string getFunctionImpl(FUNCTION f); std::string compareFunctionImpl(COMPARE f, const std::string &Op0, const std::string &Op1); -void insert_glsl_legacy_function(std::ostream& OS); +void insert_glsl_legacy_function(std::ostream& OS, gl::glsl::program_domain domain); diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp index 81c4bc9d6b..984f282525 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp @@ -214,12 +214,14 @@ namespace case rsx::texture_dimension_extended::texture_dimension_3d: case rsx::texture_dimension_extended::texture_dimension_cubemap: return "texture(" + tex_name + ", (" + coord_name + ".xyz * " + tex_name + "_coord_scale))"; } + + fmt::throw_exception("Invalid texture dimension %d" HERE, (u32)prog.get_texture_dimension(index)); } } void GLFragmentDecompilerThread::insertMainStart(std::stringstream & OS) { - insert_glsl_legacy_function(OS); + insert_glsl_legacy_function(OS, gl::glsl::glsl_fragment_program); const std::set output_values = { diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 9ded069d54..75430c4be3 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -774,7 +774,7 @@ bool GLGSRender::load_program() u32 vertex_constants_offset; u32 fragment_constants_offset; - const u32 fragment_constants_size = m_prog_buffer.get_fragment_constants_buffer_size(fragment_program); + const u32 fragment_constants_size = (const u32)m_prog_buffer.get_fragment_constants_buffer_size(fragment_program); const u32 fragment_buffer_size = fragment_constants_size + (17 * 4 * sizeof(float)); if (manually_flush_ring_buffers) diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.h b/rpcs3/Emu/RSX/GL/GLGSRender.h index 8d40ac7aba..1b9283194b 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.h +++ b/rpcs3/Emu/RSX/GL/GLGSRender.h @@ -52,10 +52,10 @@ private: std::unique_ptr m_index_ring_buffer; u32 m_draw_calls = 0; - u32 m_begin_time = 0; - u32 m_draw_time = 0; - u32 m_vertex_upload_time = 0; - u32 m_textures_upload_time = 0; + s64 m_begin_time = 0; + s64 m_draw_time = 0; + s64 m_vertex_upload_time = 0; + s64 m_textures_upload_time = 0; //Compare to see if transform matrix have changed size_t m_transform_buffer_hash = 0; diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.h b/rpcs3/Emu/RSX/GL/GLHelpers.h index e260eba34f..edf2348e57 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.h +++ b/rpcs3/Emu/RSX/GL/GLHelpers.h @@ -783,8 +783,8 @@ namespace gl { protected: - GLsizeiptr m_data_loc = 0; - GLsizeiptr m_limit = 0; + u32 m_data_loc = 0; + u32 m_limit = 0; void *m_memory_mapping = nullptr; fence m_fence; @@ -807,7 +807,7 @@ namespace gl verify(HERE), m_memory_mapping != nullptr; m_data_loc = 0; - m_limit = size; + m_limit = ::narrow(size); } void create(target target_, GLsizeiptr size, const void* data_ = nullptr) @@ -818,7 +818,7 @@ namespace gl virtual std::pair alloc_from_heap(u32 alloc_size, u16 alignment) { - u32 offset = (u32)m_data_loc; + u32 offset = m_data_loc; if (m_data_loc) offset = align(offset, alignment); if ((offset + alloc_size) > m_limit) @@ -854,7 +854,7 @@ namespace gl m_id = 0; } - virtual void reserve_storage_on_heap(u32 alloc_size) {} + virtual void reserve_storage_on_heap(u32 /*alloc_size*/) {} virtual void unmap() {} @@ -873,8 +873,8 @@ namespace gl class legacy_ring_buffer : public ring_buffer { - u64 m_mapped_bytes = 0; - u64 m_mapping_offset = 0; + u32 m_mapped_bytes = 0; + u32 m_mapping_offset = 0; public: @@ -888,7 +888,7 @@ namespace gl m_memory_mapping = nullptr; m_data_loc = 0; - m_limit = size; + m_limit = ::narrow(size); } void create(target target_, GLsizeiptr size, const void* data_ = nullptr) @@ -1990,6 +1990,12 @@ namespace gl namespace glsl { + enum program_domain + { + glsl_vertex_program = 0, + glsl_fragment_program = 1 + }; + class compilation_exception : public exception { public: diff --git a/rpcs3/Emu/RSX/GL/GLProgramBuffer.h b/rpcs3/Emu/RSX/GL/GLProgramBuffer.h index 058130e815..9f9eec53ad 100644 --- a/rpcs3/Emu/RSX/GL/GLProgramBuffer.h +++ b/rpcs3/Emu/RSX/GL/GLProgramBuffer.h @@ -11,21 +11,21 @@ struct GLTraits using pipeline_properties = void*; static - void recompile_fragment_program(const RSXFragmentProgram &RSXFP, fragment_program_type& fragmentProgramData, size_t ID) + void recompile_fragment_program(const RSXFragmentProgram &RSXFP, fragment_program_type& fragmentProgramData, size_t /*ID*/) { fragmentProgramData.Decompile(RSXFP); fragmentProgramData.Compile(); } static - void recompile_vertex_program(const RSXVertexProgram &RSXVP, vertex_program_type& vertexProgramData, size_t ID) + void recompile_vertex_program(const RSXVertexProgram &RSXVP, vertex_program_type& vertexProgramData, size_t /*ID*/) { vertexProgramData.Decompile(RSXVP); vertexProgramData.Compile(); } static - pipeline_storage_type build_pipeline(const vertex_program_type &vertexProgramData, const fragment_program_type &fragmentProgramData, const pipeline_properties &pipelineProperties) + pipeline_storage_type build_pipeline(const vertex_program_type &vertexProgramData, const fragment_program_type &fragmentProgramData, const pipeline_properties&) { pipeline_storage_type result; __glcheck result.create() diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.h b/rpcs3/Emu/RSX/GL/GLRenderTargets.h index 1877e8c8d8..885a2759e4 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.h +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.h @@ -160,7 +160,7 @@ struct gl_render_target_traits static std::unique_ptr create_new_surface( - u32 address, + u32 /*address*/, rsx::surface_color_format surface_color_format, size_t width, size_t height @@ -172,7 +172,7 @@ struct gl_render_target_traits auto internal_fmt = rsx::internals::sized_internal_format(surface_color_format); result->recreate(gl::texture::target::texture2D); - result->set_native_pitch(width * format.channel_count * format.channel_size); + result->set_native_pitch((u16)width * format.channel_count * format.channel_size); result->set_compatible_format(internal_fmt); __glcheck result->config() @@ -192,7 +192,7 @@ struct gl_render_target_traits static std::unique_ptr create_new_surface( - u32 address, + u32 /*address*/, rsx::surface_depth_format surface_depth_format, size_t width, size_t height @@ -228,21 +228,21 @@ struct gl_render_target_traits static void prepare_rtt_for_drawing(void *, gl::render_target*) {} static void prepare_rtt_for_sampling(void *, gl::render_target*) {} - static void prepare_ds_for_drawing(void *, gl::render_target *ds) {} + static void prepare_ds_for_drawing(void *, gl::render_target*) {} static void prepare_ds_for_sampling(void *, gl::render_target*) {} - static void invalidate_rtt_surface_contents(void *, gl::render_target *ds) {} + static void invalidate_rtt_surface_contents(void *, gl::render_target*) {} static void invalidate_depth_surface_contents(void *, gl::render_target *ds) { ds->set_cleared(false); } static - bool rtt_has_format_width_height(const std::unique_ptr &rtt, rsx::surface_color_format surface_color_format, size_t width, size_t height) + bool rtt_has_format_width_height(const std::unique_ptr &rtt, rsx::surface_color_format, size_t width, size_t height) { // TODO: check format return rtt->width() == width && rtt->height() == height; } static - bool ds_has_format_width_height(const std::unique_ptr &rtt, rsx::surface_depth_format surface_depth_stencil_format, size_t width, size_t height) + bool ds_has_format_width_height(const std::unique_ptr &rtt, rsx::surface_depth_format, size_t width, size_t height) { // TODO: check format return rtt->width() == width && rtt->height() == height; @@ -268,7 +268,7 @@ struct gl_render_target_traits return result; } - static std::vector issue_stencil_download_command(gl::render_target* depth_stencil_buffer, size_t width, size_t height) + static std::vector issue_stencil_download_command(gl::render_target*, size_t width, size_t height) { std::vector result(width * height * 4); return result; @@ -357,7 +357,7 @@ private: return false; } - bool fits(gl::render_target *src, std::pair &dims, u16 x_offset, u16 y_offset, u16 width, u16 height) const + bool fits(gl::render_target*, std::pair &dims, u16 x_offset, u16 y_offset, u16 width, u16 height) const { if ((x_offset + width) > dims.first) return false; if ((y_offset + height) > dims.second) return false; @@ -369,7 +369,6 @@ public: surface_subresource get_surface_subresource_if_applicable(u32 texaddr, u16 requested_width, u16 requested_height, u16 requested_pitch, bool scale_to_fit =false, bool crop=false) { gl::render_target *surface = nullptr; - bool is_subslice = false; u16 x_offset = 0; u16 y_offset = 0; @@ -388,7 +387,7 @@ public: if (scale_to_fit) { f32 pitch_scaling = (f32)requested_pitch / surface->get_native_pitch(); - requested_width /= pitch_scaling; + requested_width = (u16)((f32)requested_width / pitch_scaling); } if (fits(surface, dims, x_offset, y_offset, requested_width, requested_height)) @@ -428,7 +427,7 @@ public: if (scale_to_fit) { f32 pitch_scaling = (f32)requested_pitch / surface->get_native_pitch(); - requested_width /= pitch_scaling; + requested_width = (u16)((f32)requested_width / pitch_scaling); } if (fits(surface, dims, x_offset, y_offset, requested_width, requested_height)) diff --git a/rpcs3/Emu/RSX/GL/GLTextOut.h b/rpcs3/Emu/RSX/GL/GLTextOut.h index 37b8a7884c..e0983f982e 100644 --- a/rpcs3/Emu/RSX/GL/GLTextOut.h +++ b/rpcs3/Emu/RSX/GL/GLTextOut.h @@ -91,7 +91,7 @@ namespace gl GlyphManager glyph_source; auto points = glyph_source.generate_point_map(); - const u32 buffer_size = points.size() * sizeof(GlyphManager::glyph_point); + const size_t buffer_size = points.size() * sizeof(GlyphManager::glyph_point); m_text_buffer.data(buffer_size, points.data()); m_offsets = glyph_source.get_glyph_offsets(); @@ -184,7 +184,7 @@ namespace gl m_vao.bind(); - glMultiDrawArrays(GL_POINTS, offsets.data(), counts.data(), counts.size()); + glMultiDrawArrays(GL_POINTS, (const GLint*)offsets.data(), (const GLsizei*)counts.data(), (GLsizei)counts.size()); glBindVertexArray(old_vao); } diff --git a/rpcs3/Emu/RSX/GL/GLTexture.cpp b/rpcs3/Emu/RSX/GL/GLTexture.cpp index e76c7c109c..7d3bc460b1 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.cpp +++ b/rpcs3/Emu/RSX/GL/GLTexture.cpp @@ -175,7 +175,7 @@ namespace gl } glSamplerParameteri(samplerHandle, GL_TEXTURE_MAG_FILTER, tex_mag_filter(tex.mag_filter())); - glSamplerParameteri(samplerHandle, GL_TEXTURE_MAX_ANISOTROPY_EXT, ::gl::max_aniso(tex.max_aniso())); + glSamplerParameterf(samplerHandle, GL_TEXTURE_MAX_ANISOTROPY_EXT, ::gl::max_aniso(tex.max_aniso())); const u32 texture_format = tex.format() & ~(CELL_GCM_TEXTURE_UN | CELL_GCM_TEXTURE_LN); if (texture_format == CELL_GCM_TEXTURE_DEPTH16 || texture_format == CELL_GCM_TEXTURE_DEPTH24_D8) diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.h b/rpcs3/Emu/RSX/GL/GLTextureCache.h index c54037d760..64f97101b8 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.h +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.h @@ -452,7 +452,7 @@ namespace gl GLGSRender *m_renderer; std::thread::id m_renderer_thread; - cached_texture_section *find_texture_from_dimensions(u64 texaddr, u32 w, u32 h) + cached_texture_section *find_texture_from_dimensions(u32 texaddr, u32 w, u32 h) { std::lock_guard lock(m_section_mutex); @@ -701,7 +701,7 @@ namespace gl */ const f32 internal_scale = (f32)tex_pitch / native_pitch; - const u32 internal_width = tex_width * internal_scale; + const u32 internal_width = (const u32)(tex_width * internal_scale); const surface_subresource rsc = m_rtts.get_surface_subresource_if_applicable(texaddr, internal_width, tex_height, tex_pitch, true); if (rsc.surface) @@ -819,7 +819,7 @@ namespace gl std::lock_guard lock(m_section_mutex); - cached_texture_section &cached = create_texture(gl_texture.id(), texaddr, get_texture_size(tex), tex_width, tex_height); + cached_texture_section &cached = create_texture(gl_texture.id(), texaddr, (const u32)get_texture_size(tex), tex_width, tex_height); cached.protect(utils::protection::ro); cached.set_dirty(false); @@ -1047,8 +1047,8 @@ namespace gl //Offset in x and y for src is 0 (it is already accounted for when getting pixels_src) //Reproject final clip onto source... - const u16 src_w = clip_dimensions.width / scale_x; - const u16 src_h = clip_dimensions.height / scale_y; + const u16 src_w = (const u16)((f32)clip_dimensions.width / scale_x); + const u16 src_h = (const u16)((f32)clip_dimensions.height / scale_y); areai src_area = { 0, 0, src_w, src_h }; areai dst_area = { 0, 0, dst.clip_width, dst.clip_height }; @@ -1184,8 +1184,8 @@ namespace gl { f32 subres_scaling_x = (f32)src.pitch / src_subres.surface->get_native_pitch(); - dst_area.x2 = (src_subres.w * scale_x * subres_scaling_x); - dst_area.y2 = (src_subres.h * scale_y); + dst_area.x2 = (int)(src_subres.w * scale_x * subres_scaling_x); + dst_area.y2 = (int)(src_subres.h * scale_y); } src_area.x2 = src_subres.w; @@ -1209,8 +1209,8 @@ namespace gl if (dst.clip_x || dst.clip_y) { //Reproject clip offsets onto source - const u16 scaled_clip_offset_x = dst.clip_x / scale_x; - const u16 scaled_clip_offset_y = dst.clip_y / scale_y; + const u16 scaled_clip_offset_x = (const u16)((f32)dst.clip_x / scale_x); + const u16 scaled_clip_offset_y = (const u16)((f32)dst.clip_y / scale_y); src_area.x1 += scaled_clip_offset_x; src_area.x2 += scaled_clip_offset_x; diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp index 8045708b7e..49b83eb0d2 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp @@ -136,11 +136,11 @@ static const vertex_reg_info reg_table[] = void GLVertexDecompilerThread::insertOutputs(std::stringstream & OS, const std::vector & outputs) { - bool insert_front_diffuse = (rsx_vertex_program.output_mask & 1); - bool insert_back_diffuse = (rsx_vertex_program.output_mask & 4); + bool insert_front_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTDIFFUSE) != 0; + bool insert_back_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_BACKDIFFUSE) != 0; - bool insert_front_specular = (rsx_vertex_program.output_mask & 2); - bool insert_back_specular = (rsx_vertex_program.output_mask & 8); + bool insert_front_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTSPECULAR) != 0; + bool insert_back_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_BACKSPECULAR) != 0; bool front_back_diffuse = (insert_back_diffuse && insert_front_diffuse); bool front_back_specular = (insert_back_specular && insert_front_specular); @@ -196,6 +196,8 @@ namespace return "vec4(" + value + ", " + value + ", 1., 1.)"; case 3: return "vec4(" + value + ", " + value + ", " + value + ", 1.)"; + default: + LOG_ERROR(RSX, "invalid vector size %d" HERE, vector_size); case 1: case 4: //Expand not required @@ -254,7 +256,7 @@ namespace void GLVertexDecompilerThread::insertMainStart(std::stringstream & OS) { - insert_glsl_legacy_function(OS); + insert_glsl_legacy_function(OS, gl::glsl::glsl_vertex_program); std::string parameters = ""; for (int i = 0; i < 16; ++i) @@ -341,11 +343,11 @@ void GLVertexDecompilerThread::insertMainEnd(std::stringstream & OS) OS << std::endl << " vs_main(" << parameters << ");" << std::endl << std::endl; - bool insert_front_diffuse = (rsx_vertex_program.output_mask & 1); - bool insert_front_specular = (rsx_vertex_program.output_mask & 2); + bool insert_front_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTDIFFUSE) != 0; + bool insert_front_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTSPECULAR) != 0; - bool insert_back_diffuse = (rsx_vertex_program.output_mask & 4); - bool insert_back_specular = (rsx_vertex_program.output_mask & 8); + bool insert_back_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_BACKDIFFUSE) != 0; + bool insert_back_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_BACKSPECULAR) != 0; bool front_back_diffuse = (insert_back_diffuse && insert_front_diffuse); bool front_back_specular = (insert_back_specular && insert_front_specular); diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.h b/rpcs3/Emu/RSX/GL/GLVertexProgram.h index 049a5710e8..29ade83e5f 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.h +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.h @@ -31,7 +31,7 @@ protected: const RSXVertexProgram &rsx_vertex_program; public: - GLVertexDecompilerThread(const RSXVertexProgram &prog, std::string& shader, ParamArray& parr) + GLVertexDecompilerThread(const RSXVertexProgram &prog, std::string& shader, ParamArray&) : VertexProgramDecompiler(prog) , m_shader(shader) , rsx_vertex_program(prog) diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index a6c13e9795..4dff4e7e7f 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -304,7 +304,7 @@ namespace rsx u32 thread::get_push_buffer_index_count() const { - return element_push_buffer.size(); + return (u32)element_push_buffer.size(); } void thread::end() @@ -822,13 +822,9 @@ namespace rsx case rsx::vertex_base_type::s32k: case rsx::vertex_base_type::ub256: return true; - case rsx::vertex_base_type::f: - case rsx::vertex_base_type::cmp: - case rsx::vertex_base_type::sf: - case rsx::vertex_base_type::s1: - case rsx::vertex_base_type::ub: - return false; } + + return false; } } diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index e44fe21faf..ff4fb6cf3a 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -197,10 +197,10 @@ namespace rsx virtual void on_init_rsx() = 0; virtual void on_init_thread() = 0; - virtual bool do_method(u32 cmd, u32 value) { return false; } + virtual bool do_method(u32 /*cmd*/, u32 /*value*/) { return false; } virtual void flip(int buffer) = 0; virtual u64 timestamp() const; - virtual bool on_access_violation(u32 address, bool is_writing) { return false; } + virtual bool on_access_violation(u32 /*address*/, bool /*is_writing*/) { return false; } gsl::span get_raw_index_array(const std::vector >& draw_indexed_clause) const; gsl::span get_raw_vertex_buffer(const rsx::data_array_format_info&, u32 base_offset, const std::vector>& vertex_ranges) const; @@ -291,7 +291,7 @@ namespace rsx virtual std::pair get_programs() const { return std::make_pair("", ""); }; - virtual bool scaled_image_from_memory(blit_src_info& src_info, blit_dst_info& dst_info, bool interpolate){ return false; } + virtual bool scaled_image_from_memory(blit_src_info& /*src_info*/, blit_dst_info& /*dst_info*/, bool /*interpolate*/){ return false; } public: void reset(); diff --git a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp index 40d51be620..cece520e31 100644 --- a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp @@ -104,7 +104,7 @@ namespace vk fmt::throw_exception("Unknown compare function" HERE); } - void insert_glsl_legacy_function(std::ostream& OS) + void insert_glsl_legacy_function(std::ostream& OS, glsl::program_domain domain) { OS << "vec4 lit_legacy(vec4 val)"; OS << "{\n"; @@ -119,6 +119,9 @@ namespace vk OS << " return result;\n"; OS << "}\n\n"; + if (domain == glsl::program_domain::glsl_vertex_program) + return; + //NOTE: After testing with GOW, the w component is either the original depth or wraps around to the x component //Since component.r == depth_value with some precision loss, just use the precise depth value for now (further testing needed) OS << "vec4 decodeLinearDepth(float depth_value)\n"; diff --git a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.h b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.h index 9202cfe5f3..7bf06e183d 100644 --- a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.h +++ b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.h @@ -13,7 +13,7 @@ namespace vk std::string getFloatTypeNameImpl(size_t elementCount); std::string getFunctionImpl(FUNCTION f); std::string compareFunctionImpl(COMPARE f, const std::string &Op0, const std::string &Op1); - void insert_glsl_legacy_function(std::ostream& OS); + void insert_glsl_legacy_function(std::ostream& OS, glsl::program_domain domain); const varying_register_t& get_varying_register(const std::string& name); bool compile_glsl_to_spv(std::string& shader, glsl::program_domain domain, std::vector &spv); diff --git a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp index 7d6a22edb3..41e374a815 100644 --- a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp @@ -229,12 +229,14 @@ namespace vk case rsx::texture_dimension_extended::texture_dimension_3d: case rsx::texture_dimension_extended::texture_dimension_cubemap: return "texture(" + tex_name + ", " + coord_name + ".xyz)"; } + + fmt::throw_exception("Invalid texture dimension %d" HERE, (u32)prog.get_texture_dimension(index)); } } void VKFragmentDecompilerThread::insertMainStart(std::stringstream & OS) { - vk::insert_glsl_legacy_function(OS); + vk::insert_glsl_legacy_function(OS, vk::glsl::program_domain::glsl_fragment_program); const std::set output_values = { diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 1f19333185..d08752ba26 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -926,7 +926,7 @@ void VKGSRender::end() *m_device, VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_REPEAT, !!(rsx::method_registers.vertex_textures[i].format() & CELL_GCM_TEXTURE_UN), - 0, 1.f, rsx::method_registers.vertex_textures[i].min_lod(), rsx::method_registers.vertex_textures[i].max_lod(), + 0.f, 1.f, (f32)rsx::method_registers.vertex_textures[i].min_lod(), (f32)rsx::method_registers.vertex_textures[i].max_lod(), VK_FILTER_NEAREST, VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST, vk::get_border_color(rsx::method_registers.vertex_textures[i].border_color()) )); @@ -1138,7 +1138,7 @@ void VKGSRender::clear_surface(u32 mask) vkCmdBeginRenderPass(*m_current_command_buffer, &rp_begin, VK_SUBPASS_CONTENTS_INLINE); - vkCmdClearAttachments(*m_current_command_buffer, clear_descriptors.size(), clear_descriptors.data(), clear_regions.size(), clear_regions.data()); + vkCmdClearAttachments(*m_current_command_buffer, (u32)clear_descriptors.size(), clear_descriptors.data(), (u32)clear_regions.size(), clear_regions.data()); vkCmdEndRenderPass(*m_current_command_buffer); } diff --git a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h index 6d17620489..b09e636200 100644 --- a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h +++ b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h @@ -74,14 +74,14 @@ struct VKTraits using pipeline_properties = vk::pipeline_props; static - void recompile_fragment_program(const RSXFragmentProgram &RSXFP, fragment_program_type& fragmentProgramData, size_t ID) + void recompile_fragment_program(const RSXFragmentProgram &RSXFP, fragment_program_type& fragmentProgramData, size_t /*ID*/) { fragmentProgramData.Decompile(RSXFP); fragmentProgramData.Compile(); } static - void recompile_vertex_program(const RSXVertexProgram &RSXVP, vertex_program_type& vertexProgramData, size_t ID) + void recompile_vertex_program(const RSXVertexProgram &RSXVP, vertex_program_type& vertexProgramData, size_t /*ID*/) { vertexProgramData.Decompile(RSXVP); vertexProgramData.Compile(); diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.h b/rpcs3/Emu/RSX/VK/VKRenderTargets.h index 3961ded043..68f8e5f26c 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.h +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.h @@ -183,17 +183,17 @@ namespace rsx return false; } - static download_buffer_object issue_download_command(surface_type, surface_color_format color_format, size_t width, size_t, ...) + static download_buffer_object issue_download_command(surface_type, surface_color_format, size_t /*width*/, size_t /*height*/, ...) { return nullptr; } - static download_buffer_object issue_depth_download_command(surface_type, surface_depth_format depth_format, size_t width, size_t height, ...) + static download_buffer_object issue_depth_download_command(surface_type, surface_depth_format, size_t /*width*/, size_t /*height*/, ...) { return nullptr; } - static download_buffer_object issue_stencil_download_command(surface_type, surface_depth_format depth_format, size_t width, size_t height, ...) + static download_buffer_object issue_stencil_download_command(surface_type, surface_depth_format, size_t /*width*/, size_t /*height*/, ...) { return nullptr; } diff --git a/rpcs3/Emu/RSX/VK/VKTextureCache.h b/rpcs3/Emu/RSX/VK/VKTextureCache.h index 6a77b8eb05..9c65f99608 100644 --- a/rpcs3/Emu/RSX/VK/VKTextureCache.h +++ b/rpcs3/Emu/RSX/VK/VKTextureCache.h @@ -281,7 +281,7 @@ namespace vk { private: std::vector m_cache; - std::pair texture_cache_range = std::make_pair(0xFFFFFFFF, 0); + std::pair texture_cache_range = std::make_pair(0xFFFFFFFF, 0); std::vector > m_temporary_image_view; std::vector> m_dirty_textures; @@ -390,7 +390,7 @@ namespace vk return { final_mapping[1], final_mapping[2], final_mapping[3], final_mapping[0] }; } - VkComponentMapping get_component_map(rsx::vertex_texture &tex, u32 gcm_format) + VkComponentMapping get_component_map(rsx::vertex_texture&, u32 gcm_format) { auto mapping = vk::get_component_mapping(gcm_format); return { mapping[1], mapping[2], mapping[3], mapping[0] }; diff --git a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp index 5feebfb09b..045a6d9187 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp @@ -287,7 +287,7 @@ namespace size_t data_size = rsx::get_vertex_type_size_on_host(vertex_register.type, vertex_register.attribute_size); const VkFormat format = vk::get_suitable_vk_format(vertex_register.type, vertex_register.attribute_size); - u32 offset_in_attrib_buffer = 0; + size_t offset_in_attrib_buffer = 0; if (vk::requires_component_expansion(vertex_register.type, vertex_register.attribute_size)) { @@ -316,7 +316,7 @@ namespace void operator()(const rsx::empty_vertex_array& vbo) { - u32 offset_in_attrib_buffer = m_attrib_ring_info.alloc<256>(32); + size_t offset_in_attrib_buffer = m_attrib_ring_info.alloc<256>(32); void *dst = m_attrib_ring_info.map(offset_in_attrib_buffer, 32); memset(dst, 0, 32); m_attrib_ring_info.unmap(); @@ -494,7 +494,7 @@ namespace const VkFormat format = vk::get_suitable_vk_format(vertex_info.type(), vertex_info.size()); - u32 offset_in_attrib_buffer = m_attrib_ring_info.alloc<256>(data_size); + size_t offset_in_attrib_buffer = m_attrib_ring_info.alloc<256>(data_size); u8* src = reinterpret_cast( rsx::method_registers.current_draw_clause.inline_vertex_array.data()); u8* dst = diff --git a/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp b/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp index 8526bd1886..cecc019a22 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp @@ -173,11 +173,11 @@ static const vertex_reg_info reg_table[] = void VKVertexDecompilerThread::insertOutputs(std::stringstream & OS, const std::vector & outputs) { - bool insert_front_diffuse = (rsx_vertex_program.output_mask & 1); - bool insert_back_diffuse = (rsx_vertex_program.output_mask & 4); + bool insert_front_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTDIFFUSE) != 0; + bool insert_back_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_BACKDIFFUSE) != 0; - bool insert_front_specular = (rsx_vertex_program.output_mask & 2); - bool insert_back_specular = (rsx_vertex_program.output_mask & 8); + bool insert_front_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTSPECULAR) != 0; + bool insert_back_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_BACKSPECULAR) != 0; for (auto &i : reg_table) { @@ -241,7 +241,7 @@ namespace vk void VKVertexDecompilerThread::insertMainStart(std::stringstream & OS) { - vk::insert_glsl_legacy_function(OS); + vk::insert_glsl_legacy_function(OS, vk::glsl::program_domain::glsl_vertex_program); std::string parameters = ""; for (int i = 0; i < 16; ++i) @@ -317,11 +317,11 @@ void VKVertexDecompilerThread::insertMainEnd(std::stringstream & OS) OS << std::endl << " vs_main(" << parameters << ");" << std::endl << std::endl; - bool insert_front_diffuse = (rsx_vertex_program.output_mask & 1); - bool insert_front_specular = (rsx_vertex_program.output_mask & 2); + bool insert_front_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTDIFFUSE) != 0; + bool insert_front_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTSPECULAR) != 0; - bool insert_back_diffuse = (rsx_vertex_program.output_mask & 4); - bool insert_back_specular = (rsx_vertex_program.output_mask & 8); + bool insert_back_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_BACKDIFFUSE) != 0; + bool insert_back_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_BACKSPECULAR) != 0; for (auto &i : reg_table) { diff --git a/rpcs3/Emu/RSX/VK/VKVertexProgram.h b/rpcs3/Emu/RSX/VK/VKVertexProgram.h index 00e1399d38..4e09a3fd85 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexProgram.h +++ b/rpcs3/Emu/RSX/VK/VKVertexProgram.h @@ -25,7 +25,7 @@ protected: const RSXVertexProgram &rsx_vertex_program; public: - VKVertexDecompilerThread(const RSXVertexProgram &prog, std::string& shader, ParamArray& parr, class VKVertexProgram &dst) + VKVertexDecompilerThread(const RSXVertexProgram &prog, std::string& shader, ParamArray&, class VKVertexProgram &dst) : VertexProgramDecompiler(prog) , m_shader(shader) , rsx_vertex_program(prog) diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index b7a94b94b0..6a3bc8343f 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -609,8 +609,8 @@ namespace rsx src_info.height = in_h; src_info.pitch = in_pitch; src_info.slice_h = slice_h; - src_info.offset_x = in_x; - src_info.offset_y = in_y; + src_info.offset_x = (u16)in_x; + src_info.offset_y = (u16)in_y; src_info.pixels = pixels_src; src_info.rsx_address = get_address(src_offset, src_dma);