diff options
Diffstat (limited to 'src/video_core')
-rw-r--r-- | src/video_core/CMakeLists.txt | 15 | ||||
-rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 5 | ||||
-rw-r--r-- | src/video_core/engines/maxwell_3d.h | 20 | ||||
-rw-r--r-- | src/video_core/engines/maxwell_dma.cpp | 37 | ||||
-rw-r--r-- | src/video_core/macro/macro.cpp | 3 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 4 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.cpp | 4 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_state_tracker.cpp | 4 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/fixed_pipeline_state.cpp | 1 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/fixed_pipeline_state.h | 1 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 12 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 2 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 2 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_state_tracker.cpp | 2 | ||||
-rw-r--r-- | src/video_core/shader_environment.cpp | 2 |
15 files changed, 80 insertions, 34 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 106991969..d7f7d336c 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -73,8 +73,6 @@ add_library(video_core STATIC macro/macro_hle.h macro/macro_interpreter.cpp macro/macro_interpreter.h - macro/macro_jit_x64.cpp - macro/macro_jit_x64.h fence_manager.h gpu.cpp gpu.h @@ -245,7 +243,7 @@ add_library(video_core STATIC create_target_directory_groups(video_core) target_link_libraries(video_core PUBLIC common core) -target_link_libraries(video_core PUBLIC glad shader_recompiler xbyak) +target_link_libraries(video_core PUBLIC glad shader_recompiler) if (YUZU_USE_BUNDLED_FFMPEG AND NOT WIN32) add_dependencies(video_core ffmpeg-build) @@ -282,8 +280,19 @@ else() -Wno-sign-conversion ) + + # xbyak + set_source_files_properties(macro/macro_jit_x64.cpp PROPERTIES COMPILE_OPTIONS "-Wno-conversion;-Wno-shadow") endif() if (ARCHITECTURE_x86_64) + target_sources(video_core PRIVATE + macro/macro_jit_x64.cpp + macro/macro_jit_x64.h + ) + target_link_libraries(video_core PUBLIC xbyak) +endif() + +if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) target_link_libraries(video_core PRIVATE dynarmic) endif() diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 4a2f2c1fd..d502d181c 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -249,6 +249,11 @@ void Maxwell3D::ProcessMethodCall(u32 method, u32 argument, u32 nonshadow_argume return; case MAXWELL3D_REG_INDEX(fragment_barrier): return rasterizer->FragmentBarrier(); + case MAXWELL3D_REG_INDEX(invalidate_texture_data_cache): + rasterizer->InvalidateGPUCache(); + return rasterizer->WaitForIdle(); + case MAXWELL3D_REG_INDEX(tiled_cache_barrier): + return rasterizer->TiledCacheBarrier(); } } diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index a948fcb14..34b085388 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -707,7 +707,7 @@ public: case Size::Size_A2_B10_G10_R10: return "2_10_10_10"; case Size::Size_B10_G11_R11: - return "10_11_12"; + return "10_11_11"; default: ASSERT(false); return {}; @@ -2639,7 +2639,7 @@ public: L2CacheControl l2_cache_control; ///< 0x0218 InvalidateShaderCache invalidate_shader_cache; ///< 0x021C INSERT_PADDING_BYTES_NOINIT(0xA8); - SyncInfo sync_info; ///< 0x02C8 + SyncInfo sync_info; ///< 0x02C8 INSERT_PADDING_BYTES_NOINIT(0x4); u32 prim_circular_buffer_throttle; ///< 0x02D0 u32 flush_invalidate_rop_mini_cache; ///< 0x02D4 @@ -2731,7 +2731,11 @@ public: s32 stencil_back_ref; ///< 0x0F54 u32 stencil_back_mask; ///< 0x0F58 u32 stencil_back_func_mask; ///< 0x0F5C - INSERT_PADDING_BYTES_NOINIT(0x24); + INSERT_PADDING_BYTES_NOINIT(0x14); + u32 invalidate_texture_data_cache; ///< 0x0F74 Assumed - Not in official docs. + INSERT_PADDING_BYTES_NOINIT(0x4); + u32 tiled_cache_barrier; ///< 0x0F7C Assumed - Not in official docs. + INSERT_PADDING_BYTES_NOINIT(0x4); VertexStreamSubstitute vertex_stream_substitute; ///< 0x0F84 u32 line_mode_clip_generated_edge_do_not_draw; ///< 0x0F8C u32 color_mask_common; ///< 0x0F90 @@ -2791,7 +2795,8 @@ public: FillViaTriangleMode fill_via_triangle_mode; ///< 0x113C u32 blend_per_format_snorm8_unorm16_snorm16_enabled; ///< 0x1140 u32 flush_pending_writes_sm_gloal_store; ///< 0x1144 - INSERT_PADDING_BYTES_NOINIT(0x18); + u32 conservative_raster_enable; ///< 0x1148 Assumed - Not in official docs. + INSERT_PADDING_BYTES_NOINIT(0x14); std::array<VertexAttribute, NumVertexAttributes> vertex_attrib_format; ///< 0x1160 std::array<MsaaSampleLocation, 4> multisample_sample_locations; ///< 0x11E0 u32 offset_render_target_index_by_viewport_index; ///< 0x11F0 @@ -2970,7 +2975,7 @@ public: CullFace gl_cull_face; ///< 0x1920 Viewport::PixelCenter viewport_pixel_center; ///< 0x1924 INSERT_PADDING_BYTES_NOINIT(0x4); - u32 viewport_scale_offset_enbled; ///< 0x192C + u32 viewport_scale_offset_enabled; ///< 0x192C INSERT_PADDING_BYTES_NOINIT(0xC); ViewportClipControl viewport_clip_control; ///< 0x193C UserClip::Op user_clip_op; ///< 0x1940 @@ -3287,6 +3292,8 @@ ASSERT_REG_POSITION(const_color_rendering, 0x0F40); ASSERT_REG_POSITION(stencil_back_ref, 0x0F54); ASSERT_REG_POSITION(stencil_back_mask, 0x0F58); ASSERT_REG_POSITION(stencil_back_func_mask, 0x0F5C); +ASSERT_REG_POSITION(invalidate_texture_data_cache, 0x0F74); +ASSERT_REG_POSITION(tiled_cache_barrier, 0x0F7C); ASSERT_REG_POSITION(vertex_stream_substitute, 0x0F84); ASSERT_REG_POSITION(line_mode_clip_generated_edge_do_not_draw, 0x0F8C); ASSERT_REG_POSITION(color_mask_common, 0x0F90); @@ -3343,6 +3350,7 @@ ASSERT_REG_POSITION(post_ps_use_pre_ps_coverage, 0x1138); ASSERT_REG_POSITION(fill_via_triangle_mode, 0x113C); ASSERT_REG_POSITION(blend_per_format_snorm8_unorm16_snorm16_enabled, 0x1140); ASSERT_REG_POSITION(flush_pending_writes_sm_gloal_store, 0x1144); +ASSERT_REG_POSITION(conservative_raster_enable, 0x1148); ASSERT_REG_POSITION(vertex_attrib_format, 0x1160); ASSERT_REG_POSITION(multisample_sample_locations, 0x11E0); ASSERT_REG_POSITION(offset_render_target_index_by_viewport_index, 0x11F0); @@ -3482,7 +3490,7 @@ ASSERT_REG_POSITION(gl_cull_test_enabled, 0x1918); ASSERT_REG_POSITION(gl_front_face, 0x191C); ASSERT_REG_POSITION(gl_cull_face, 0x1920); ASSERT_REG_POSITION(viewport_pixel_center, 0x1924); -ASSERT_REG_POSITION(viewport_scale_offset_enbled, 0x192C); +ASSERT_REG_POSITION(viewport_scale_offset_enabled, 0x192C); ASSERT_REG_POSITION(viewport_clip_control, 0x193C); ASSERT_REG_POSITION(user_clip_op, 0x1940); ASSERT_REG_POSITION(render_enable_override, 0x1944); diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index 4eb7a100d..54523a4b2 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp @@ -102,26 +102,29 @@ void MaxwellDMA::Launch() { const bool is_src_pitch = IsPitchKind(static_cast<PTEKind>(src_kind)); const bool is_dst_pitch = IsPitchKind(static_cast<PTEKind>(dst_kind)); if (!is_src_pitch && is_dst_pitch) { - std::vector<u8> tmp_buffer(regs.line_length_in); - std::vector<u8> dst_buffer(regs.line_length_in); - memory_manager.ReadBlockUnsafe(regs.offset_in, tmp_buffer.data(), - regs.line_length_in); - for (u32 offset = 0; offset < regs.line_length_in; ++offset) { - dst_buffer[offset] = - tmp_buffer[convert_linear_2_blocklinear_addr(regs.offset_in + offset) - - regs.offset_in]; + UNIMPLEMENTED_IF(regs.line_length_in % 16 != 0); + UNIMPLEMENTED_IF(regs.offset_in % 16 != 0); + UNIMPLEMENTED_IF(regs.offset_out % 16 != 0); + std::vector<u8> tmp_buffer(16); + for (u32 offset = 0; offset < regs.line_length_in; offset += 16) { + memory_manager.ReadBlockUnsafe( + convert_linear_2_blocklinear_addr(regs.offset_in + offset), + tmp_buffer.data(), tmp_buffer.size()); + memory_manager.WriteBlock(regs.offset_out + offset, tmp_buffer.data(), + tmp_buffer.size()); } - memory_manager.WriteBlock(regs.offset_out, dst_buffer.data(), regs.line_length_in); } else if (is_src_pitch && !is_dst_pitch) { - std::vector<u8> tmp_buffer(regs.line_length_in); - std::vector<u8> dst_buffer(regs.line_length_in); - memory_manager.ReadBlockUnsafe(regs.offset_in, tmp_buffer.data(), - regs.line_length_in); - for (u32 offset = 0; offset < regs.line_length_in; ++offset) { - dst_buffer[convert_linear_2_blocklinear_addr(regs.offset_out + offset) - - regs.offset_out] = tmp_buffer[offset]; + UNIMPLEMENTED_IF(regs.line_length_in % 16 != 0); + UNIMPLEMENTED_IF(regs.offset_in % 16 != 0); + UNIMPLEMENTED_IF(regs.offset_out % 16 != 0); + std::vector<u8> tmp_buffer(16); + for (u32 offset = 0; offset < regs.line_length_in; offset += 16) { + memory_manager.ReadBlockUnsafe(regs.offset_in + offset, tmp_buffer.data(), + tmp_buffer.size()); + memory_manager.WriteBlock( + convert_linear_2_blocklinear_addr(regs.offset_out + offset), + tmp_buffer.data(), tmp_buffer.size()); } - memory_manager.WriteBlock(regs.offset_out, dst_buffer.data(), regs.line_length_in); } else { if (!accelerate.BufferCopy(regs.offset_in, regs.offset_out, regs.line_length_in)) { std::vector<u8> tmp_buffer(regs.line_length_in); diff --git a/src/video_core/macro/macro.cpp b/src/video_core/macro/macro.cpp index f61d5998e..505d81c1e 100644 --- a/src/video_core/macro/macro.cpp +++ b/src/video_core/macro/macro.cpp @@ -16,7 +16,10 @@ #include "video_core/macro/macro.h" #include "video_core/macro/macro_hle.h" #include "video_core/macro/macro_interpreter.h" + +#ifdef ARCHITECTURE_x86_64 #include "video_core/macro/macro_jit_x64.h" +#endif namespace Tegra { diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 72e314d39..d05a5f60b 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -618,7 +618,7 @@ void RasterizerOpenGL::SyncViewport() { } flags[Dirty::Viewport0 + index] = false; - if (!regs.viewport_scale_offset_enbled) { + if (!regs.viewport_scale_offset_enabled) { const auto x = static_cast<GLfloat>(regs.surface_clip.x); const auto y = static_cast<GLfloat>(regs.surface_clip.y); const auto width = static_cast<GLfloat>(regs.surface_clip.width); @@ -770,7 +770,7 @@ void RasterizerOpenGL::SyncStencilTestState() { if (regs.stencil_two_side_enable) { glStencilFuncSeparate(GL_BACK, MaxwellToGL::ComparisonOp(regs.stencil_back_op.func), - regs.stencil_back_ref, regs.stencil_back_mask); + regs.stencil_back_ref, regs.stencil_back_func_mask); glStencilOpSeparate(GL_BACK, MaxwellToGL::StencilOp(regs.stencil_back_op.fail), MaxwellToGL::StencilOp(regs.stencil_back_op.zfail), MaxwellToGL::StencilOp(regs.stencil_back_op.zpass)); diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 977709518..3fe04a115 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp @@ -76,7 +76,8 @@ Shader::RuntimeInfo MakeRuntimeInfo(const GraphicsPipelineKey& key, } break; case Shader::Stage::TessellationEval: - info.tess_clockwise = key.tessellation_clockwise != 0; + // Flip the face, as OpenGL's drawing is flipped. + info.tess_clockwise = key.tessellation_clockwise == 0; info.tess_primitive = [&key] { switch (key.tessellation_primitive) { case Maxwell::Tessellation::DomainType::Isolines: @@ -218,6 +219,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo .support_float16 = false, .support_int64 = device.HasShaderInt64(), .needs_demote_reorder = device.IsAmd(), + .support_snorm_render_buffer = false, } { if (use_asynchronous_shaders) { workers = CreateWorkers(); diff --git a/src/video_core/renderer_opengl/gl_state_tracker.cpp b/src/video_core/renderer_opengl/gl_state_tracker.cpp index a359f96f1..d53b422ca 100644 --- a/src/video_core/renderer_opengl/gl_state_tracker.cpp +++ b/src/video_core/renderer_opengl/gl_state_tracker.cpp @@ -70,8 +70,8 @@ void SetupDirtyViewports(Tables& tables) { FillBlock(tables[1], OFF(viewport_transform), NUM(viewport_transform), Viewports); FillBlock(tables[1], OFF(viewports), NUM(viewports), Viewports); - tables[0][OFF(viewport_scale_offset_enbled)] = ViewportTransform; - tables[1][OFF(viewport_scale_offset_enbled)] = Viewports; + tables[0][OFF(viewport_scale_offset_enabled)] = ViewportTransform; + tables[1][OFF(viewport_scale_offset_enabled)] = Viewports; } void SetupDirtyScissors(Tables& tables) { diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp index f85ed8e5b..98cc26679 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp @@ -90,6 +90,7 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, depth_format.Assign(static_cast<u32>(regs.zeta.format)); y_negate.Assign(regs.window_origin.mode != Maxwell::WindowOrigin::Mode::UpperLeft ? 1 : 0); provoking_vertex_last.Assign(regs.provoking_vertex == Maxwell::ProvokingVertex::Last ? 1 : 0); + conservative_raster_enable.Assign(regs.conservative_raster_enable != 0 ? 1 : 0); smooth_lines.Assign(regs.line_anti_alias_enable != 0 ? 1 : 0); for (size_t i = 0; i < regs.rt.size(); ++i) { diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.h b/src/video_core/renderer_vulkan/fixed_pipeline_state.h index 43441209c..1afdef329 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.h +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.h @@ -193,6 +193,7 @@ struct FixedPipelineState { BitField<6, 5, u32> depth_format; BitField<11, 1, u32> y_negate; BitField<12, 1, u32> provoking_vertex_last; + BitField<13, 1, u32> conservative_raster_enable; BitField<14, 1, u32> smooth_lines; }; std::array<u8, Maxwell::NumRenderTargets> color_formats; diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 1aa116cea..ef75c126c 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -680,6 +680,15 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { .lineStippleFactor = 0, .lineStipplePattern = 0, }; + VkPipelineRasterizationConservativeStateCreateInfoEXT conservative_raster{ + .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT, + .pNext = nullptr, + .flags = 0, + .conservativeRasterizationMode = key.state.conservative_raster_enable != 0 + ? VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT + : VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT, + .extraPrimitiveOverestimationSize = 0.0f, + }; VkPipelineRasterizationProvokingVertexStateCreateInfoEXT provoking_vertex{ .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT, .pNext = nullptr, @@ -690,6 +699,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { if (IsLine(input_assembly_topology) && device.IsExtLineRasterizationSupported()) { line_state.pNext = std::exchange(rasterization_ci.pNext, &line_state); } + if (device.IsExtConservativeRasterizationSupported()) { + conservative_raster.pNext = std::exchange(rasterization_ci.pNext, &conservative_raster); + } if (device.IsExtProvokingVertexSupported()) { provoking_vertex.pNext = std::exchange(rasterization_ci.pNext, &provoking_vertex); } diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index b42e5be1e..d4b0a542a 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -166,6 +166,7 @@ Shader::RuntimeInfo MakeRuntimeInfo(std::span<const Shader::IR::Program> program } break; case Shader::Stage::TessellationEval: + info.tess_clockwise = key.state.tessellation_clockwise != 0; info.tess_primitive = [&key] { const u32 raw{key.state.tessellation_primitive.Value()}; switch (static_cast<Maxwell::Tessellation::DomainType>(raw)) { @@ -325,6 +326,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device .support_int64 = device.IsShaderInt64Supported(), .needs_demote_reorder = driver_id == VK_DRIVER_ID_AMD_PROPRIETARY_KHR || driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR, + .support_snorm_render_buffer = true, }; } diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index f79fa8313..f69c0c50f 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -683,7 +683,7 @@ void RasterizerVulkan::UpdateViewportsState(Tegra::Engines::Maxwell3D::Regs& reg if (!state_tracker.TouchViewports()) { return; } - if (!regs.viewport_scale_offset_enbled) { + if (!regs.viewport_scale_offset_enabled) { const auto x = static_cast<float>(regs.surface_clip.x); const auto y = static_cast<float>(regs.surface_clip.y); const auto width = static_cast<float>(regs.surface_clip.width); diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.cpp b/src/video_core/renderer_vulkan/vk_state_tracker.cpp index b87c3be66..edb41b171 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.cpp +++ b/src/video_core/renderer_vulkan/vk_state_tracker.cpp @@ -51,7 +51,7 @@ Flags MakeInvalidationFlags() { void SetupDirtyViewports(Tables& tables) { FillBlock(tables[0], OFF(viewport_transform), NUM(viewport_transform), Viewports); FillBlock(tables[0], OFF(viewports), NUM(viewports), Viewports); - tables[0][OFF(viewport_scale_offset_enbled)] = Viewports; + tables[0][OFF(viewport_scale_offset_enabled)] = Viewports; tables[1][OFF(window_origin)] = Viewports; } diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp index 37bb76b72..f24f320b6 100644 --- a/src/video_core/shader_environment.cpp +++ b/src/video_core/shader_environment.cpp @@ -352,7 +352,7 @@ Shader::TexturePixelFormat GraphicsEnvironment::ReadTexturePixelFormat(u32 handl u32 GraphicsEnvironment::ReadViewportTransformState() { const auto& regs{maxwell3d->regs}; - viewport_transform_state = regs.viewport_scale_offset_enbled; + viewport_transform_state = regs.viewport_scale_offset_enabled; return viewport_transform_state; } |