From d9c91acc7311dfaa9789bb78354b6e14e30cf62c Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Thu, 17 Nov 2022 18:04:39 +0100 Subject: [PATCH] early-access version 3122 --- README.md | 2 +- .../backend/glasm/emit_glasm.cpp | 1 + .../backend/glasm/emit_glasm_context_get_set.cpp | 3 +++ .../backend/glsl/emit_glsl_context_get_set.cpp | 3 +++ .../backend/spirv/emit_spirv_context_get_set.cpp | 2 ++ .../backend/spirv/spirv_emit_context.cpp | 4 ++++ src/video_core/engines/maxwell_3d.cpp | 6 +++--- src/video_core/engines/maxwell_3d.h | 6 +++--- src/video_core/macro/macro_hle.cpp | 16 +++++++++++++++- src/video_core/rasterizer_interface.h | 2 +- src/video_core/renderer_opengl/gl_rasterizer.cpp | 2 +- src/video_core/renderer_opengl/gl_rasterizer.h | 2 +- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 4 ++-- src/video_core/renderer_vulkan/vk_rasterizer.h | 2 +- 14 files changed, 41 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index efa809b92..3f8d97f90 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3121. +This is the source code for early-access 3122. ## Legal Notice diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp index b82cc8f69..b1b1e5bac 100755 --- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp @@ -320,6 +320,7 @@ void SetupOptions(const IR::Program& program, const Profile& profile, } if (stage == Stage::Fragment) { header += "OPTION ARB_draw_buffers;"; + header += "OPTION ARB_fragment_layer_viewport;"; } } diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp index 62cf57077..785035216 100755 --- a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp @@ -104,6 +104,9 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal case IR::Attribute::PrimitiveId: ctx.Add("MOV.F {}.x,primitive.id;", inst); break; + case IR::Attribute::Layer: + ctx.Add("MOV.F {}.x,fragment.layer;", inst); + break; case IR::Attribute::PositionX: case IR::Attribute::PositionY: case IR::Attribute::PositionZ: diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp index 90fffe0cd..f8f228a69 100755 --- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp @@ -205,6 +205,9 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, case IR::Attribute::PrimitiveId: ctx.AddF32("{}=itof(gl_PrimitiveID);", inst); break; + case IR::Attribute::Layer: + ctx.AddF32("{}=itof(gl_Layer);", inst); + break; case IR::Attribute::PositionX: case IR::Attribute::PositionY: case IR::Attribute::PositionZ: diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index c74c78dfd..84af590e8 100755 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -315,6 +315,8 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { switch (attr) { case IR::Attribute::PrimitiveId: return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.primitive_id)); + case IR::Attribute::Layer: + return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.layer)); case IR::Attribute::PositionX: case IR::Attribute::PositionY: case IR::Attribute::PositionZ: diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 237029d47..fc03737be 100755 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -1359,6 +1359,10 @@ void EmitContext::DefineInputs(const IR::Program& program) { if (loads[IR::Attribute::PrimitiveId]) { primitive_id = DefineInput(*this, U32[1], false, spv::BuiltIn::PrimitiveId); } + if (loads[IR::Attribute::Layer]) { + AddCapability(spv::Capability::Geometry); + layer = DefineInput(*this, U32[1], false, spv::BuiltIn::Layer); + } if (loads.AnyComponent(IR::Attribute::PositionX)) { const bool is_fragment{stage != Stage::Fragment}; const spv::BuiltIn built_in{is_fragment ? spv::BuiltIn::Position : spv::BuiltIn::FragCoord}; diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index ed1625208..3a60abb08 100755 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -232,7 +232,7 @@ void Maxwell3D::ProcessMethodCall(u32 method, u32 argument, u32 nonshadow_argume use_topology_override = true; return; case MAXWELL3D_REG_INDEX(clear_surface): - return ProcessClearBuffers(); + return ProcessClearBuffers(1); case MAXWELL3D_REG_INDEX(report_semaphore.query): return ProcessQueryGet(); case MAXWELL3D_REG_INDEX(render_enable.mode): @@ -596,8 +596,8 @@ u32 Maxwell3D::GetRegisterValue(u32 method) const { return regs.reg_array[method]; } -void Maxwell3D::ProcessClearBuffers() { - rasterizer->Clear(); +void Maxwell3D::ProcessClearBuffers(u32 layer_count) { + rasterizer->Clear(layer_count); } void Maxwell3D::ProcessDraw(u32 instance_count) { diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index f1cd23eb5..13a5e370c 100755 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -3086,6 +3086,9 @@ public: std::vector inline_index_draw_indexes; + /// Handles a write to the CLEAR_BUFFERS register. + void ProcessClearBuffers(u32 layer_count); + private: void InitializeRegisterDefaults(); @@ -3120,9 +3123,6 @@ private: /// Handles firmware blob 4 void ProcessFirmwareCall4(); - /// Handles a write to the CLEAR_BUFFERS register. - void ProcessClearBuffers(); - /// Handles a write to the QUERY_GET register. void ProcessQueryGet(); diff --git a/src/video_core/macro/macro_hle.cpp b/src/video_core/macro/macro_hle.cpp index 9692ea0d6..bb9311eab 100755 --- a/src/video_core/macro/macro_hle.cpp +++ b/src/video_core/macro/macro_hle.cpp @@ -126,11 +126,25 @@ void HLE_3F5E74B9C9A50164(Engines::Maxwell3D& maxwell3d, const std::vector& } } -constexpr std::array, 4> hle_funcs{{ +// Multi-layer Clear +void HLE_EAD26C3E2109B06B(Engines::Maxwell3D& maxwell3d, const std::vector& parameters) { + ASSERT(parameters.size() == 1); + + const Engines::Maxwell3D::Regs::ClearSurface clear_params{parameters[0]}; + const u32 rt_index = clear_params.RT; + const u32 num_layers = maxwell3d.regs.rt[rt_index].depth; + ASSERT(clear_params.layer == 0); + + maxwell3d.regs.clear_surface.raw = clear_params.raw; + maxwell3d.ProcessClearBuffers(num_layers); +} + +constexpr std::array, 5> hle_funcs{{ {0x771BB18C62444DA0, &HLE_771BB18C62444DA0}, {0x0D61FC9FAAC9FCAD, &HLE_0D61FC9FAAC9FCAD}, {0x0217920100488FF7, &HLE_0217920100488FF7}, {0x3F5E74B9C9A50164, &HLE_3F5E74B9C9A50164}, + {0xEAD26C3E2109B06B, &HLE_EAD26C3E2109B06B}, }}; class HLEMacroImpl final : public CachedMacro { diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index f63007329..742fc6ade 100755 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h @@ -43,7 +43,7 @@ public: virtual void Draw(bool is_indexed, u32 instance_count) = 0; /// Clear the current framebuffer - virtual void Clear() = 0; + virtual void Clear(u32 layer_count) = 0; /// Dispatches a compute shader invocation virtual void DispatchCompute() = 0; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 2cb13c1a8..2d90317a0 100755 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -136,7 +136,7 @@ void RasterizerOpenGL::LoadDiskResources(u64 title_id, std::stop_token stop_load shader_cache.LoadDiskResources(title_id, stop_loading, callback); } -void RasterizerOpenGL::Clear() { +void RasterizerOpenGL::Clear(u32 layer_count) { MICROPROFILE_SCOPE(OpenGL_Clears); if (!maxwell3d->ShouldExecute()) { return; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index e5dcff804..5b5579a44 100755 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -69,7 +69,7 @@ public: ~RasterizerOpenGL() override; void Draw(bool is_indexed, u32 instance_count) override; - void Clear() override; + void Clear(u32 layer_count) override; void DispatchCompute() override; void ResetCounter(VideoCore::QueryType type) override; void Query(GPUVAddr gpu_addr, VideoCore::QueryType type, std::optional timestamp) override; diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index a8f86d9de..a969a3fea 100755 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -213,7 +213,7 @@ void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) { EndTransformFeedback(); } -void RasterizerVulkan::Clear() { +void RasterizerVulkan::Clear(u32 layer_count) { MICROPROFILE_SCOPE(Vulkan_Clearing); if (!maxwell3d->ShouldExecute()) { @@ -256,7 +256,7 @@ void RasterizerVulkan::Clear() { .rect = regs.clear_control.use_scissor ? GetScissorState(regs, 0, up_scale, down_shift) : default_scissor, .baseArrayLayer = regs.clear_surface.layer, - .layerCount = 1, + .layerCount = layer_count, }; if (clear_rect.rect.extent.width == 0 || clear_rect.rect.extent.height == 0) { return; diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index 855be3905..cc3766aae 100755 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h @@ -65,7 +65,7 @@ public: ~RasterizerVulkan() override; void Draw(bool is_indexed, u32 instance_count) override; - void Clear() override; + void Clear(u32 layer_count) override; void DispatchCompute() override; void ResetCounter(VideoCore::QueryType type) override; void Query(GPUVAddr gpu_addr, VideoCore::QueryType type, std::optional timestamp) override;