early-access version 3911
This commit is contained in:
@@ -19,6 +19,7 @@ set(SHADER_FILES
|
||||
block_linear_unswizzle_2d.comp
|
||||
block_linear_unswizzle_3d.comp
|
||||
convert_abgr8_to_d24s8.frag
|
||||
convert_d32f_to_abgr8.frag
|
||||
convert_d24s8_to_abgr8.frag
|
||||
convert_depth_to_float.frag
|
||||
convert_float_to_depth.frag
|
||||
|
||||
14
src/video_core/host_shaders/convert_d32f_to_abgr8.frag
Executable file
14
src/video_core/host_shaders/convert_d32f_to_abgr8.frag
Executable file
@@ -0,0 +1,14 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#version 450
|
||||
|
||||
layout(binding = 0) uniform sampler2D depth_tex;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main() {
|
||||
ivec2 coord = ivec2(gl_FragCoord.xy);
|
||||
float depth = textureLod(depth_tex, coord, 0).r;
|
||||
color = vec4(depth, depth*depth, sqrt(depth), 1.0); // Convert depth to color
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "video_core/host_shaders/blit_color_float_frag_spv.h"
|
||||
#include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h"
|
||||
#include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h"
|
||||
#include "video_core/host_shaders/convert_d32f_to_abgr8_frag_spv.h"
|
||||
#include "video_core/host_shaders/convert_depth_to_float_frag_spv.h"
|
||||
#include "video_core/host_shaders/convert_float_to_depth_frag_spv.h"
|
||||
#include "video_core/host_shaders/convert_s8d24_to_abgr8_frag_spv.h"
|
||||
@@ -433,6 +434,7 @@ BlitImageHelper::BlitImageHelper(const Device& device_, Scheduler& scheduler_,
|
||||
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)),
|
||||
convert_d32f_to_abgr8_frag(BuildShader(device, CONVERT_D32F_TO_ABGR8_FRAG_SPV)),
|
||||
convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)),
|
||||
convert_s8d24_to_abgr8_frag(BuildShader(device, CONVERT_S8D24_TO_ABGR8_FRAG_SPV)),
|
||||
linear_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_LINEAR>)),
|
||||
@@ -558,6 +560,13 @@ void BlitImageHelper::ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer,
|
||||
Convert(*convert_abgr8_to_d24s8_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ConvertD32FToABGR8(const Framebuffer* dst_framebuffer,
|
||||
ImageView& src_image_view) {
|
||||
ConvertPipelineColorTargetEx(convert_d32f_to_abgr8_pipeline, dst_framebuffer->RenderPass(),
|
||||
convert_d32f_to_abgr8_frag);
|
||||
ConvertDepthStencil(*convert_d32f_to_abgr8_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer,
|
||||
ImageView& src_image_view) {
|
||||
ConvertPipelineColorTargetEx(convert_d24s8_to_abgr8_pipeline, dst_framebuffer->RenderPass(),
|
||||
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
|
||||
void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
||||
|
||||
void ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view);
|
||||
|
||||
void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view);
|
||||
|
||||
void ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view);
|
||||
@@ -128,6 +130,7 @@ private:
|
||||
vk::ShaderModule convert_depth_to_float_frag;
|
||||
vk::ShaderModule convert_float_to_depth_frag;
|
||||
vk::ShaderModule convert_abgr8_to_d24s8_frag;
|
||||
vk::ShaderModule convert_d32f_to_abgr8_frag;
|
||||
vk::ShaderModule convert_d24s8_to_abgr8_frag;
|
||||
vk::ShaderModule convert_s8d24_to_abgr8_frag;
|
||||
vk::Sampler linear_sampler;
|
||||
@@ -146,6 +149,7 @@ private:
|
||||
vk::Pipeline convert_d16_to_r16_pipeline;
|
||||
vk::Pipeline convert_r16_to_d16_pipeline;
|
||||
vk::Pipeline convert_abgr8_to_d24s8_pipeline;
|
||||
vk::Pipeline convert_d32f_to_abgr8_pipeline;
|
||||
vk::Pipeline convert_d24s8_to_abgr8_pipeline;
|
||||
vk::Pipeline convert_s8d24_to_abgr8_pipeline;
|
||||
};
|
||||
|
||||
@@ -1200,6 +1200,9 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im
|
||||
if (src_view.format == PixelFormat::D24_UNORM_S8_UINT) {
|
||||
return blit_image_helper.ConvertS8D24ToABGR8(dst, src_view);
|
||||
}
|
||||
if (src_view.format == PixelFormat::D32_FLOAT) {
|
||||
return blit_image_helper.ConvertD32FToABGR8(dst, src_view);
|
||||
}
|
||||
break;
|
||||
case PixelFormat::R32_FLOAT:
|
||||
if (src_view.format == PixelFormat::D32_FLOAT) {
|
||||
|
||||
@@ -68,6 +68,7 @@ struct LevelInfo {
|
||||
Extent2D tile_size;
|
||||
u32 bpp_log2;
|
||||
u32 tile_width_spacing;
|
||||
u32 num_levels;
|
||||
};
|
||||
|
||||
[[nodiscard]] constexpr u32 AdjustTileSize(u32 shift, u32 unit_factor, u32 dimension) {
|
||||
@@ -118,11 +119,11 @@ template <u32 GOB_EXTENT>
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Extent3D AdjustMipBlockSize(Extent3D num_tiles, Extent3D block_size,
|
||||
u32 level) {
|
||||
u32 level, u32 num_levels) {
|
||||
return {
|
||||
.width = AdjustMipBlockSize<GOB_SIZE_X>(num_tiles.width, block_size.width, level),
|
||||
.height = AdjustMipBlockSize<GOB_SIZE_Y>(num_tiles.height, block_size.height, level),
|
||||
.depth = level == 0
|
||||
.depth = level == 0 && num_levels == 1
|
||||
? block_size.depth
|
||||
: AdjustMipBlockSize<GOB_SIZE_Z>(num_tiles.depth, block_size.depth, level),
|
||||
};
|
||||
@@ -166,13 +167,6 @@ template <u32 GOB_EXTENT>
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Extent3D TileShift(const LevelInfo& info, u32 level) {
|
||||
if (level == 0) {
|
||||
return Extent3D{
|
||||
.width = info.block.width,
|
||||
.height = info.block.height,
|
||||
.depth = info.block.depth,
|
||||
};
|
||||
}
|
||||
const Extent3D blocks = NumLevelBlocks(info, level);
|
||||
return Extent3D{
|
||||
.width = AdjustTileSize(info.block.width, GOB_SIZE_X, blocks.width),
|
||||
@@ -257,7 +251,7 @@ template <u32 GOB_EXTENT>
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr LevelInfo MakeLevelInfo(PixelFormat format, Extent3D size, Extent3D block,
|
||||
u32 tile_width_spacing) {
|
||||
u32 tile_width_spacing, u32 num_levels) {
|
||||
const u32 bytes_per_block = BytesPerBlock(format);
|
||||
return {
|
||||
.size =
|
||||
@@ -270,16 +264,18 @@ template <u32 GOB_EXTENT>
|
||||
.tile_size = DefaultBlockSize(format),
|
||||
.bpp_log2 = BytesPerBlockLog2(bytes_per_block),
|
||||
.tile_width_spacing = tile_width_spacing,
|
||||
.num_levels = num_levels,
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr LevelInfo MakeLevelInfo(const ImageInfo& info) {
|
||||
return MakeLevelInfo(info.format, info.size, info.block, info.tile_width_spacing);
|
||||
return MakeLevelInfo(info.format, info.size, info.block, info.tile_width_spacing,
|
||||
info.resources.levels);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr u32 CalculateLevelOffset(PixelFormat format, Extent3D size, Extent3D block,
|
||||
u32 tile_width_spacing, u32 level) {
|
||||
const LevelInfo info = MakeLevelInfo(format, size, block, tile_width_spacing);
|
||||
const LevelInfo info = MakeLevelInfo(format, size, block, tile_width_spacing, level);
|
||||
u32 offset = 0;
|
||||
for (u32 current_level = 0; current_level < level; ++current_level) {
|
||||
offset += CalculateLevelSize(info, current_level);
|
||||
@@ -466,7 +462,7 @@ template <u32 GOB_EXTENT>
|
||||
};
|
||||
const u32 bpp_log2 = BytesPerBlockLog2(info.format);
|
||||
const u32 alignment = StrideAlignment(num_tiles, info.block, bpp_log2, info.tile_width_spacing);
|
||||
const Extent3D mip_block = AdjustMipBlockSize(num_tiles, info.block, 0);
|
||||
const Extent3D mip_block = AdjustMipBlockSize(num_tiles, info.block, 0, info.resources.levels);
|
||||
return Extent3D{
|
||||
.width = Common::AlignUpLog2(num_tiles.width, alignment),
|
||||
.height = Common::AlignUpLog2(num_tiles.height, GOB_SIZE_Y_SHIFT + mip_block.height),
|
||||
@@ -533,7 +529,8 @@ void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr
|
||||
UNIMPLEMENTED_IF(copy.image_extent != level_size);
|
||||
|
||||
const Extent3D num_tiles = AdjustTileSize(level_size, tile_size);
|
||||
const Extent3D block = AdjustMipBlockSize(num_tiles, level_info.block, level);
|
||||
const Extent3D block =
|
||||
AdjustMipBlockSize(num_tiles, level_info.block, level, level_info.num_levels);
|
||||
|
||||
size_t host_offset = copy.buffer_offset;
|
||||
|
||||
@@ -698,7 +695,7 @@ u32 CalculateLevelStrideAlignment(const ImageInfo& info, u32 level) {
|
||||
const Extent2D tile_size = DefaultBlockSize(info.format);
|
||||
const Extent3D level_size = AdjustMipSize(info.size, level);
|
||||
const Extent3D num_tiles = AdjustTileSize(level_size, tile_size);
|
||||
const Extent3D block = AdjustMipBlockSize(num_tiles, info.block, level);
|
||||
const Extent3D block = AdjustMipBlockSize(num_tiles, info.block, level, info.resources.levels);
|
||||
const u32 bpp_log2 = BytesPerBlockLog2(info.format);
|
||||
return StrideAlignment(num_tiles, block, bpp_log2, info.tile_width_spacing);
|
||||
}
|
||||
@@ -887,7 +884,8 @@ boost::container::small_vector<BufferImageCopy, 16> UnswizzleImage(Tegra::Memory
|
||||
.image_extent = level_size,
|
||||
};
|
||||
const Extent3D num_tiles = AdjustTileSize(level_size, tile_size);
|
||||
const Extent3D block = AdjustMipBlockSize(num_tiles, level_info.block, level);
|
||||
const Extent3D block =
|
||||
AdjustMipBlockSize(num_tiles, info.block, level, level_info.num_levels);
|
||||
const u32 stride_alignment = StrideAlignment(num_tiles, info.block, gob, bpp_log2);
|
||||
size_t guest_layer_offset = 0;
|
||||
|
||||
@@ -1041,7 +1039,7 @@ Extent3D MipBlockSize(const ImageInfo& info, u32 level) {
|
||||
const Extent2D tile_size = DefaultBlockSize(info.format);
|
||||
const Extent3D level_size = AdjustMipSize(info.size, level);
|
||||
const Extent3D num_tiles = AdjustTileSize(level_size, tile_size);
|
||||
return AdjustMipBlockSize(num_tiles, level_info.block, level);
|
||||
return AdjustMipBlockSize(num_tiles, level_info.block, level, level_info.num_levels);
|
||||
}
|
||||
|
||||
boost::container::small_vector<SwizzleParameters, 16> FullUploadSwizzles(const ImageInfo& info) {
|
||||
@@ -1063,7 +1061,8 @@ boost::container::small_vector<SwizzleParameters, 16> FullUploadSwizzles(const I
|
||||
for (s32 level = 0; level < num_levels; ++level) {
|
||||
const Extent3D level_size = AdjustMipSize(size, level);
|
||||
const Extent3D num_tiles = AdjustTileSize(level_size, tile_size);
|
||||
const Extent3D block = AdjustMipBlockSize(num_tiles, level_info.block, level);
|
||||
const Extent3D block =
|
||||
AdjustMipBlockSize(num_tiles, info.block, level, level_info.num_levels);
|
||||
params[level] = SwizzleParameters{
|
||||
.num_tiles = num_tiles,
|
||||
.block = block,
|
||||
@@ -1292,11 +1291,11 @@ u32 MapSizeBytes(const ImageBase& image) {
|
||||
}
|
||||
}
|
||||
|
||||
static_assert(CalculateLevelSize(LevelInfo{{1920, 1080, 1}, {0, 2, 0}, {1, 1}, 2, 0}, 0) ==
|
||||
static_assert(CalculateLevelSize(LevelInfo{{1920, 1080, 1}, {0, 2, 0}, {1, 1}, 2, 0, 1}, 0) ==
|
||||
0x7f8000);
|
||||
static_assert(CalculateLevelSize(LevelInfo{{32, 32, 1}, {0, 0, 4}, {1, 1}, 4, 0}, 0) == 0x40000);
|
||||
static_assert(CalculateLevelSize(LevelInfo{{32, 32, 1}, {0, 0, 4}, {1, 1}, 4, 0, 1}, 0) == 0x4000);
|
||||
|
||||
static_assert(CalculateLevelSize(LevelInfo{{128, 8, 1}, {0, 4, 0}, {1, 1}, 4, 0}, 0) == 0x40000);
|
||||
static_assert(CalculateLevelSize(LevelInfo{{128, 8, 1}, {0, 4, 0}, {1, 1}, 4, 0, 1}, 0) == 0x4000);
|
||||
|
||||
static_assert(CalculateLevelOffset(PixelFormat::R8_SINT, {1920, 1080, 1}, {0, 2, 0}, 0, 7) ==
|
||||
0x2afc00);
|
||||
|
||||
Reference in New Issue
Block a user