early-access version 3340
This commit is contained in:
parent
4dedbd0502
commit
8a069e9a9a
12 changed files with 236 additions and 48 deletions
|
@ -1,7 +1,7 @@
|
|||
yuzu emulator early access
|
||||
=============
|
||||
|
||||
This is the source code for early-access 3339.
|
||||
This is the source code for early-access 3340.
|
||||
|
||||
## Legal Notice
|
||||
|
||||
|
|
|
@ -279,6 +279,8 @@ void SetupOptions(const IR::Program& program, const Profile& profile,
|
|||
header += "OPTION NV_internal;"
|
||||
"OPTION NV_shader_storage_buffer;"
|
||||
"OPTION NV_gpu_program_fp64;";
|
||||
// TODO: Enable only when MS is used
|
||||
header += "OPTION NV_texture_multisample;";
|
||||
if (info.uses_int64_bit_atomics) {
|
||||
header += "OPTION NV_shader_atomic_int64;";
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ std::string Image(EmitContext& ctx, IR::TextureInstInfo info,
|
|||
}
|
||||
}
|
||||
|
||||
std::string_view TextureType(IR::TextureInstInfo info) {
|
||||
std::string_view TextureType(IR::TextureInstInfo info, bool is_ms = false) {
|
||||
if (info.is_depth) {
|
||||
switch (info.type) {
|
||||
case TextureType::Color1D:
|
||||
|
@ -88,9 +88,9 @@ std::string_view TextureType(IR::TextureInstInfo info) {
|
|||
return "ARRAY1D";
|
||||
case TextureType::Color2D:
|
||||
case TextureType::Color2DRect:
|
||||
return "2D";
|
||||
return is_ms ? "2DMS" : "2D";
|
||||
case TextureType::ColorArray2D:
|
||||
return "ARRAY2D";
|
||||
return is_ms ? "ARRAY2DMS" : "ARRAY2D";
|
||||
case TextureType::Color3D:
|
||||
return "3D";
|
||||
case TextureType::ColorCube:
|
||||
|
@ -510,15 +510,16 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
|||
const IR::Value& coord, const IR::Value& offset, ScalarS32 lod, ScalarS32 ms) {
|
||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||
const auto sparse_inst{PrepareSparse(inst)};
|
||||
const bool is_multisample{ms.type != Type::Void};
|
||||
const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""};
|
||||
const std::string_view type{TextureType(info)};
|
||||
const std::string_view type{TextureType(info, is_multisample)};
|
||||
const std::string texture{Texture(ctx, info, index)};
|
||||
const std::string offset_vec{Offset(ctx, offset)};
|
||||
const auto [coord_vec, coord_alloc]{Coord(ctx, coord)};
|
||||
const Register ret{ctx.reg_alloc.Define(inst)};
|
||||
if (info.type == TextureType::Buffer) {
|
||||
ctx.Add("TXF.F{} {},{},{},{}{};", sparse_mod, ret, coord_vec, texture, type, offset_vec);
|
||||
} else if (ms.type != Type::Void) {
|
||||
} else if (is_multisample) {
|
||||
ctx.Add("MOV.S {}.w,{};"
|
||||
"TXFMS.F{} {},{},{},{}{};",
|
||||
coord_vec, ms, sparse_mod, ret, coord_vec, texture, type, offset_vec);
|
||||
|
|
|
@ -61,8 +61,7 @@ std::string OutputDecorator(Stage stage, u32 size) {
|
|||
}
|
||||
}
|
||||
|
||||
std::string_view SamplerType(TextureType type, bool is_depth) {
|
||||
if (is_depth) {
|
||||
std::string_view DepthSamplerType(TextureType type) {
|
||||
switch (type) {
|
||||
case TextureType::Color1D:
|
||||
return "sampler1DShadow";
|
||||
|
@ -80,6 +79,11 @@ std::string_view SamplerType(TextureType type, bool is_depth) {
|
|||
throw NotImplementedException("Texture type: {}", type);
|
||||
}
|
||||
}
|
||||
|
||||
std::string_view ColorSamplerType(TextureType type, bool is_multisample = false) {
|
||||
if (is_multisample) {
|
||||
ASSERT(type == TextureType::Color2D || type == TextureType::ColorArray2D);
|
||||
}
|
||||
switch (type) {
|
||||
case TextureType::Color1D:
|
||||
return "sampler1D";
|
||||
|
@ -87,9 +91,9 @@ std::string_view SamplerType(TextureType type, bool is_depth) {
|
|||
return "sampler1DArray";
|
||||
case TextureType::Color2D:
|
||||
case TextureType::Color2DRect:
|
||||
return "sampler2D";
|
||||
return is_multisample ? "sampler2DMS" : "sampler2D";
|
||||
case TextureType::ColorArray2D:
|
||||
return "sampler2DArray";
|
||||
return is_multisample ? "sampler2DMSArray" : "sampler2DArray";
|
||||
case TextureType::Color3D:
|
||||
return "sampler3D";
|
||||
case TextureType::ColorCube:
|
||||
|
@ -677,7 +681,7 @@ void EmitContext::SetupTextures(Bindings& bindings) {
|
|||
texture_buffers.reserve(info.texture_buffer_descriptors.size());
|
||||
for (const auto& desc : info.texture_buffer_descriptors) {
|
||||
texture_buffers.push_back({bindings.texture, desc.count});
|
||||
const auto sampler_type{SamplerType(TextureType::Buffer, false)};
|
||||
const auto sampler_type{ColorSamplerType(TextureType::Buffer)};
|
||||
const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""};
|
||||
header += fmt::format("layout(binding={}) uniform {} tex{}{};", bindings.texture,
|
||||
sampler_type, bindings.texture, array_decorator);
|
||||
|
@ -686,7 +690,8 @@ void EmitContext::SetupTextures(Bindings& bindings) {
|
|||
textures.reserve(info.texture_descriptors.size());
|
||||
for (const auto& desc : info.texture_descriptors) {
|
||||
textures.push_back({bindings.texture, desc.count});
|
||||
const auto sampler_type{SamplerType(desc.type, desc.is_depth)};
|
||||
const auto sampler_type{desc.is_depth ? DepthSamplerType(desc.type)
|
||||
: ColorSamplerType(desc.type, desc.is_multisample)};
|
||||
const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""};
|
||||
header += fmt::format("layout(binding={}) uniform {} tex{}{};", bindings.texture,
|
||||
sampler_type, bindings.texture, array_decorator);
|
||||
|
|
|
@ -45,6 +45,8 @@ set(SHADER_FILES
|
|||
smaa_neighborhood_blending.vert
|
||||
smaa_neighborhood_blending.frag
|
||||
vulkan_blit_depth_stencil.frag
|
||||
vulkan_color_clear.frag
|
||||
vulkan_color_clear.vert
|
||||
vulkan_fidelityfx_fsr_easu_fp16.comp
|
||||
vulkan_fidelityfx_fsr_easu_fp32.comp
|
||||
vulkan_fidelityfx_fsr_rcas_fp16.comp
|
||||
|
|
14
src/video_core/host_shaders/vulkan_color_clear.frag
Executable file
14
src/video_core/host_shaders/vulkan_color_clear.frag
Executable file
|
@ -0,0 +1,14 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#version 460 core
|
||||
|
||||
layout (push_constant) uniform PushConstants {
|
||||
vec4 clear_color;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main() {
|
||||
color = clear_color;
|
||||
}
|
10
src/video_core/host_shaders/vulkan_color_clear.vert
Executable file
10
src/video_core/host_shaders/vulkan_color_clear.vert
Executable file
|
@ -0,0 +1,10 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#version 460 core
|
||||
|
||||
void main() {
|
||||
float x = float((gl_VertexIndex & 1) << 2);
|
||||
float y = float((gl_VertexIndex & 2) << 1);
|
||||
gl_Position = vec4(x - 1.0, y - 1.0, 0.0, 1.0);
|
||||
}
|
|
@ -12,6 +12,8 @@
|
|||
#include "video_core/host_shaders/convert_s8d24_to_abgr8_frag_spv.h"
|
||||
#include "video_core/host_shaders/full_screen_triangle_vert_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_blit_depth_stencil_frag_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_color_clear_frag_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_color_clear_vert_spv.h"
|
||||
#include "video_core/renderer_vulkan/blit_image.h"
|
||||
#include "video_core/renderer_vulkan/maxwell_to_vk.h"
|
||||
#include "video_core/renderer_vulkan/vk_scheduler.h"
|
||||
|
@ -69,10 +71,11 @@ constexpr VkDescriptorSetLayoutCreateInfo TWO_TEXTURES_DESCRIPTOR_SET_LAYOUT_CRE
|
|||
.bindingCount = static_cast<u32>(TWO_TEXTURES_DESCRIPTOR_SET_LAYOUT_BINDINGS.size()),
|
||||
.pBindings = TWO_TEXTURES_DESCRIPTOR_SET_LAYOUT_BINDINGS.data(),
|
||||
};
|
||||
constexpr VkPushConstantRange PUSH_CONSTANT_RANGE{
|
||||
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
|
||||
template <VkShaderStageFlags stageFlags, size_t size>
|
||||
inline constexpr VkPushConstantRange PUSH_CONSTANT_RANGE{
|
||||
.stageFlags = stageFlags,
|
||||
.offset = 0,
|
||||
.size = sizeof(PushConstants),
|
||||
.size = static_cast<u32>(size),
|
||||
};
|
||||
constexpr VkPipelineVertexInputStateCreateInfo PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||
|
@ -125,10 +128,8 @@ constexpr VkPipelineMultisampleStateCreateInfo PIPELINE_MULTISAMPLE_STATE_CREATE
|
|||
.alphaToCoverageEnable = VK_FALSE,
|
||||
.alphaToOneEnable = VK_FALSE,
|
||||
};
|
||||
constexpr std::array DYNAMIC_STATES{
|
||||
VK_DYNAMIC_STATE_VIEWPORT,
|
||||
VK_DYNAMIC_STATE_SCISSOR,
|
||||
};
|
||||
constexpr std::array DYNAMIC_STATES{VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR,
|
||||
VK_DYNAMIC_STATE_BLEND_CONSTANTS};
|
||||
constexpr VkPipelineDynamicStateCreateInfo PIPELINE_DYNAMIC_STATE_CREATE_INFO{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
|
@ -205,15 +206,15 @@ inline constexpr VkSamplerCreateInfo SAMPLER_CREATE_INFO{
|
|||
};
|
||||
|
||||
constexpr VkPipelineLayoutCreateInfo PipelineLayoutCreateInfo(
|
||||
const VkDescriptorSetLayout* set_layout) {
|
||||
const VkDescriptorSetLayout* set_layout, vk::Span<VkPushConstantRange> push_constants) {
|
||||
return VkPipelineLayoutCreateInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.setLayoutCount = 1,
|
||||
.setLayoutCount = (set_layout != nullptr ? 1u : 0u),
|
||||
.pSetLayouts = set_layout,
|
||||
.pushConstantRangeCount = 1,
|
||||
.pPushConstantRanges = &PUSH_CONSTANT_RANGE,
|
||||
.pushConstantRangeCount = push_constants.size(),
|
||||
.pPushConstantRanges = push_constants.data(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -302,8 +303,7 @@ void UpdateTwoTexturesDescriptorSet(const Device& device, VkDescriptorSet descri
|
|||
device.GetLogical().UpdateDescriptorSets(write_descriptor_sets, nullptr);
|
||||
}
|
||||
|
||||
void BindBlitState(vk::CommandBuffer cmdbuf, VkPipelineLayout layout, const Region2D& dst_region,
|
||||
const Region2D& src_region, const Extent3D& src_size = {1, 1, 1}) {
|
||||
void BindBlitState(vk::CommandBuffer cmdbuf, const Region2D& dst_region) {
|
||||
const VkOffset2D offset{
|
||||
.x = std::min(dst_region.start.x, dst_region.end.x),
|
||||
.y = std::min(dst_region.start.y, dst_region.end.y),
|
||||
|
@ -325,6 +325,13 @@ void BindBlitState(vk::CommandBuffer cmdbuf, VkPipelineLayout layout, const Regi
|
|||
.offset = offset,
|
||||
.extent = extent,
|
||||
};
|
||||
cmdbuf.SetViewport(0, viewport);
|
||||
cmdbuf.SetScissor(0, scissor);
|
||||
}
|
||||
|
||||
void BindBlitState(vk::CommandBuffer cmdbuf, VkPipelineLayout layout, const Region2D& dst_region,
|
||||
const Region2D& src_region, const Extent3D& src_size = {1, 1, 1}) {
|
||||
BindBlitState(cmdbuf, dst_region);
|
||||
const float scale_x = static_cast<float>(src_region.end.x - src_region.start.x) /
|
||||
static_cast<float>(src_size.width);
|
||||
const float scale_y = static_cast<float>(src_region.end.y - src_region.start.y) /
|
||||
|
@ -335,8 +342,6 @@ void BindBlitState(vk::CommandBuffer cmdbuf, VkPipelineLayout layout, const Regi
|
|||
static_cast<float>(src_region.start.y) /
|
||||
static_cast<float>(src_size.height)},
|
||||
};
|
||||
cmdbuf.SetViewport(0, viewport);
|
||||
cmdbuf.SetScissor(0, scissor);
|
||||
cmdbuf.PushConstants(layout, VK_SHADER_STAGE_VERTEX_BIT, push_constants);
|
||||
}
|
||||
|
||||
|
@ -408,13 +413,20 @@ BlitImageHelper::BlitImageHelper(const Device& device_, Scheduler& scheduler_,
|
|||
descriptor_pool.Allocator(*one_texture_set_layout, TEXTURE_DESCRIPTOR_BANK_INFO<1>)},
|
||||
two_textures_descriptor_allocator{
|
||||
descriptor_pool.Allocator(*two_textures_set_layout, TEXTURE_DESCRIPTOR_BANK_INFO<2>)},
|
||||
one_texture_pipeline_layout(device.GetLogical().CreatePipelineLayout(
|
||||
PipelineLayoutCreateInfo(one_texture_set_layout.address()))),
|
||||
two_textures_pipeline_layout(device.GetLogical().CreatePipelineLayout(
|
||||
PipelineLayoutCreateInfo(two_textures_set_layout.address()))),
|
||||
one_texture_pipeline_layout(device.GetLogical().CreatePipelineLayout(PipelineLayoutCreateInfo(
|
||||
one_texture_set_layout.address(),
|
||||
PUSH_CONSTANT_RANGE<VK_SHADER_STAGE_VERTEX_BIT, sizeof(PushConstants)>))),
|
||||
two_textures_pipeline_layout(
|
||||
device.GetLogical().CreatePipelineLayout(PipelineLayoutCreateInfo(
|
||||
two_textures_set_layout.address(),
|
||||
PUSH_CONSTANT_RANGE<VK_SHADER_STAGE_VERTEX_BIT, sizeof(PushConstants)>))),
|
||||
clear_color_pipeline_layout(device.GetLogical().CreatePipelineLayout(PipelineLayoutCreateInfo(
|
||||
nullptr, PUSH_CONSTANT_RANGE<VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(float) * 4>))),
|
||||
full_screen_vert(BuildShader(device, FULL_SCREEN_TRIANGLE_VERT_SPV)),
|
||||
blit_color_to_color_frag(BuildShader(device, BLIT_COLOR_FLOAT_FRAG_SPV)),
|
||||
blit_depth_stencil_frag(BuildShader(device, VULKAN_BLIT_DEPTH_STENCIL_FRAG_SPV)),
|
||||
clear_color_vert(BuildShader(device, VULKAN_COLOR_CLEAR_VERT_SPV)),
|
||||
clear_color_frag(BuildShader(device, VULKAN_COLOR_CLEAR_FRAG_SPV)),
|
||||
convert_depth_to_float_frag(BuildShader(device, CONVERT_DEPTH_TO_FLOAT_FRAG_SPV)),
|
||||
convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)),
|
||||
convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)),
|
||||
|
@ -553,6 +565,30 @@ void BlitImageHelper::ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer,
|
|||
ConvertDepthStencil(*convert_s8d24_to_abgr8_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ClearColor(const Framebuffer* dst_framebuffer, u8 color_mask,
|
||||
const std::array<f32, 4>& clear_color,
|
||||
const Region2D& dst_region) {
|
||||
const BlitImagePipelineKey key{
|
||||
.renderpass = dst_framebuffer->RenderPass(),
|
||||
.operation = Tegra::Engines::Fermi2D::Operation::BlendPremult,
|
||||
};
|
||||
const VkPipeline pipeline = FindOrEmplaceClearColorPipeline(key);
|
||||
const VkPipelineLayout layout = *clear_color_pipeline_layout;
|
||||
scheduler.RequestRenderpass(dst_framebuffer);
|
||||
scheduler.Record(
|
||||
[pipeline, layout, color_mask, clear_color, dst_region](vk::CommandBuffer cmdbuf) {
|
||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||
const std::array blend_color = {
|
||||
(color_mask & 0x1) ? 1.0f : 0.0f, (color_mask & 0x2) ? 1.0f : 0.0f,
|
||||
(color_mask & 0x4) ? 1.0f : 0.0f, (color_mask & 0x8) ? 1.0f : 0.0f};
|
||||
cmdbuf.SetBlendConstants(blend_color.data());
|
||||
BindBlitState(cmdbuf, dst_region);
|
||||
cmdbuf.PushConstants(layout, VK_SHADER_STAGE_FRAGMENT_BIT, clear_color);
|
||||
cmdbuf.Draw(3, 1, 0, 0);
|
||||
});
|
||||
scheduler.InvalidateState();
|
||||
}
|
||||
|
||||
void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view) {
|
||||
const VkPipelineLayout layout = *one_texture_pipeline_layout;
|
||||
|
@ -728,6 +764,58 @@ VkPipeline BlitImageHelper::FindOrEmplaceDepthStencilPipeline(const BlitImagePip
|
|||
return *blit_depth_stencil_pipelines.back();
|
||||
}
|
||||
|
||||
VkPipeline BlitImageHelper::FindOrEmplaceClearColorPipeline(const BlitImagePipelineKey& key) {
|
||||
const auto it = std::ranges::find(clear_color_keys, key);
|
||||
if (it != clear_color_keys.end()) {
|
||||
return *clear_color_pipelines[std::distance(clear_color_keys.begin(), it)];
|
||||
}
|
||||
clear_color_keys.push_back(key);
|
||||
const std::array stages = MakeStages(*clear_color_vert, *clear_color_frag);
|
||||
const VkPipelineColorBlendAttachmentState color_blend_attachment_state{
|
||||
.blendEnable = VK_TRUE,
|
||||
.srcColorBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR,
|
||||
.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
|
||||
.colorBlendOp = VK_BLEND_OP_ADD,
|
||||
.srcAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_ALPHA,
|
||||
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA,
|
||||
.alphaBlendOp = VK_BLEND_OP_ADD,
|
||||
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
|
||||
};
|
||||
const VkPipelineColorBlendStateCreateInfo color_blend_state_generic_create_info{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.logicOpEnable = VK_FALSE,
|
||||
.logicOp = VK_LOGIC_OP_CLEAR,
|
||||
.attachmentCount = 1,
|
||||
.pAttachments = &color_blend_attachment_state,
|
||||
.blendConstants = {0.0f, 0.0f, 0.0f, 0.0f},
|
||||
};
|
||||
clear_color_pipelines.push_back(device.GetLogical().CreateGraphicsPipeline({
|
||||
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.stageCount = static_cast<u32>(stages.size()),
|
||||
.pStages = stages.data(),
|
||||
.pVertexInputState = &PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||
.pInputAssemblyState = &PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
|
||||
.pTessellationState = nullptr,
|
||||
.pViewportState = &PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
||||
.pRasterizationState = &PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
|
||||
.pMultisampleState = &PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
|
||||
.pDepthStencilState = &PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
|
||||
.pColorBlendState = &color_blend_state_generic_create_info,
|
||||
.pDynamicState = &PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
||||
.layout = *clear_color_pipeline_layout,
|
||||
.renderPass = key.renderpass,
|
||||
.subpass = 0,
|
||||
.basePipelineHandle = VK_NULL_HANDLE,
|
||||
.basePipelineIndex = 0,
|
||||
}));
|
||||
return *clear_color_pipelines.back();
|
||||
}
|
||||
|
||||
void BlitImageHelper::ConvertPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass,
|
||||
bool is_target_depth) {
|
||||
if (pipeline) {
|
||||
|
|
|
@ -61,6 +61,9 @@ public:
|
|||
|
||||
void ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view);
|
||||
|
||||
void ClearColor(const Framebuffer* dst_framebuffer, u8 color_mask,
|
||||
const std::array<f32, 4>& clear_color, const Region2D& dst_region);
|
||||
|
||||
private:
|
||||
void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view);
|
||||
|
@ -72,6 +75,8 @@ private:
|
|||
|
||||
[[nodiscard]] VkPipeline FindOrEmplaceDepthStencilPipeline(const BlitImagePipelineKey& key);
|
||||
|
||||
[[nodiscard]] VkPipeline FindOrEmplaceClearColorPipeline(const BlitImagePipelineKey& key);
|
||||
|
||||
void ConvertPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass, bool is_target_depth);
|
||||
|
||||
void ConvertDepthToColorPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass);
|
||||
|
@ -97,9 +102,12 @@ private:
|
|||
DescriptorAllocator two_textures_descriptor_allocator;
|
||||
vk::PipelineLayout one_texture_pipeline_layout;
|
||||
vk::PipelineLayout two_textures_pipeline_layout;
|
||||
vk::PipelineLayout clear_color_pipeline_layout;
|
||||
vk::ShaderModule full_screen_vert;
|
||||
vk::ShaderModule blit_color_to_color_frag;
|
||||
vk::ShaderModule blit_depth_stencil_frag;
|
||||
vk::ShaderModule clear_color_vert;
|
||||
vk::ShaderModule clear_color_frag;
|
||||
vk::ShaderModule convert_depth_to_float_frag;
|
||||
vk::ShaderModule convert_float_to_depth_frag;
|
||||
vk::ShaderModule convert_abgr8_to_d24s8_frag;
|
||||
|
@ -112,6 +120,8 @@ private:
|
|||
std::vector<vk::Pipeline> blit_color_pipelines;
|
||||
std::vector<BlitImagePipelineKey> blit_depth_stencil_keys;
|
||||
std::vector<vk::Pipeline> blit_depth_stencil_pipelines;
|
||||
std::vector<BlitImagePipelineKey> clear_color_keys;
|
||||
std::vector<vk::Pipeline> clear_color_pipelines;
|
||||
vk::Pipeline convert_d32_to_r32_pipeline;
|
||||
vk::Pipeline convert_r32_to_d32_pipeline;
|
||||
vk::Pipeline convert_d16_to_r16_pipeline;
|
||||
|
|
|
@ -394,7 +394,15 @@ void RasterizerVulkan::Clear(u32 layer_count) {
|
|||
cmdbuf.ClearAttachments(attachment, clear_rect);
|
||||
});
|
||||
} else {
|
||||
UNIMPLEMENTED_MSG("Unimplemented Clear only the specified channel");
|
||||
u8 color_mask = static_cast<u8>(regs.clear_surface.R | regs.clear_surface.G << 1 |
|
||||
regs.clear_surface.B << 2 | regs.clear_surface.A << 3);
|
||||
Region2D dst_region = {
|
||||
Offset2D{.x = clear_rect.rect.offset.x, .y = clear_rect.rect.offset.y},
|
||||
Offset2D{.x = clear_rect.rect.offset.x +
|
||||
static_cast<s32>(clear_rect.rect.extent.width),
|
||||
.y = clear_rect.rect.offset.y +
|
||||
static_cast<s32>(clear_rect.rect.extent.height)}};
|
||||
blit_image.ClearColor(framebuffer, color_mask, regs.clear_color, dst_region);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,10 @@ ImageInfo::ImageInfo(const TICEntry& config) noexcept {
|
|||
ASSERT_MSG(false, "Invalid texture_type={}", static_cast<int>(config.texture_type.Value()));
|
||||
break;
|
||||
}
|
||||
if (num_samples > 1) {
|
||||
size.width *= NumSamplesX(config.msaa_mode);
|
||||
size.height *= NumSamplesY(config.msaa_mode);
|
||||
}
|
||||
if (type != ImageType::Linear) {
|
||||
// FIXME: Call this without passing *this
|
||||
layer_stride = CalculateLayerStride(*this);
|
||||
|
|
|
@ -51,4 +51,48 @@ namespace VideoCommon {
|
|||
return 1;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline int NumSamplesX(Tegra::Texture::MsaaMode msaa_mode) {
|
||||
using Tegra::Texture::MsaaMode;
|
||||
switch (msaa_mode) {
|
||||
case MsaaMode::Msaa1x1:
|
||||
return 1;
|
||||
case MsaaMode::Msaa2x1:
|
||||
case MsaaMode::Msaa2x1_D3D:
|
||||
case MsaaMode::Msaa2x2:
|
||||
case MsaaMode::Msaa2x2_VC4:
|
||||
case MsaaMode::Msaa2x2_VC12:
|
||||
return 2;
|
||||
case MsaaMode::Msaa4x2:
|
||||
case MsaaMode::Msaa4x2_D3D:
|
||||
case MsaaMode::Msaa4x2_VC8:
|
||||
case MsaaMode::Msaa4x2_VC24:
|
||||
case MsaaMode::Msaa4x4:
|
||||
return 4;
|
||||
}
|
||||
ASSERT_MSG(false, "Invalid MSAA mode={}", static_cast<int>(msaa_mode));
|
||||
return 1;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline int NumSamplesY(Tegra::Texture::MsaaMode msaa_mode) {
|
||||
using Tegra::Texture::MsaaMode;
|
||||
switch (msaa_mode) {
|
||||
case MsaaMode::Msaa1x1:
|
||||
case MsaaMode::Msaa2x1:
|
||||
case MsaaMode::Msaa2x1_D3D:
|
||||
return 1;
|
||||
case MsaaMode::Msaa2x2:
|
||||
case MsaaMode::Msaa2x2_VC4:
|
||||
case MsaaMode::Msaa2x2_VC12:
|
||||
case MsaaMode::Msaa4x2:
|
||||
case MsaaMode::Msaa4x2_D3D:
|
||||
case MsaaMode::Msaa4x2_VC8:
|
||||
case MsaaMode::Msaa4x2_VC24:
|
||||
return 2;
|
||||
case MsaaMode::Msaa4x4:
|
||||
return 4;
|
||||
}
|
||||
ASSERT_MSG(false, "Invalid MSAA mode={}", static_cast<int>(msaa_mode));
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // namespace VideoCommon
|
||||
|
|
Loading…
Reference in a new issue