diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 6a4876aca..7423d3e6b 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -30,7 +30,6 @@ add_library(video_core STATIC rasterizer_cache/rasterizer_cache.cpp rasterizer_cache/rasterizer_cache.h rasterizer_cache/surface_base.h - rasterizer_cache/types.h rasterizer_cache/utils.cpp rasterizer_cache/utils.h rasterizer_cache/surface_params.cpp diff --git a/src/video_core/rasterizer_cache/morton_swizzle.h b/src/video_core/rasterizer_cache/morton_swizzle.h index 9fd372176..ab5077aff 100644 --- a/src/video_core/rasterizer_cache/morton_swizzle.h +++ b/src/video_core/rasterizer_cache/morton_swizzle.h @@ -270,4 +270,4 @@ static constexpr std::array SWIZZLE_TABLE = { MortonCopy // 17 }; -} // namespace OpenGL +} // namespace VideoCore diff --git a/src/video_core/rasterizer_cache/pixel_format.h b/src/video_core/rasterizer_cache/pixel_format.h index b8ee07753..b6b69995d 100644 --- a/src/video_core/rasterizer_cache/pixel_format.h +++ b/src/video_core/rasterizer_cache/pixel_format.h @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #pragma once + #include #include "core/hw/gpu.h" #include "video_core/regs_framebuffer.h" @@ -193,4 +194,4 @@ constexpr u32 GetBytesPerPixel(PixelFormat format) { return GetFormatBpp(format) / 8; } -} // namespace OpenGL +} // namespace VideoCore diff --git a/src/video_core/rasterizer_cache/surface_base.h b/src/video_core/rasterizer_cache/surface_base.h index ad1dd4d29..c06094168 100644 --- a/src/video_core/rasterizer_cache/surface_base.h +++ b/src/video_core/rasterizer_cache/surface_base.h @@ -3,11 +3,11 @@ // Refer to the license.txt file included. #pragma once + #include #include "common/alignment.h" #include "common/assert.h" #include "video_core/rasterizer_cache/surface_params.h" -#include "video_core/rasterizer_cache/utils.h" namespace VideoCore { @@ -208,4 +208,4 @@ void SurfaceBase::UnlinkAllWatcher() { watcher_count = 0; } -} // namespace OpenGL +} // namespace VideoCore diff --git a/src/video_core/rasterizer_cache/surface_params.cpp b/src/video_core/rasterizer_cache/surface_params.cpp index 165b60146..50c73125c 100644 --- a/src/video_core/rasterizer_cache/surface_params.cpp +++ b/src/video_core/rasterizer_cache/surface_params.cpp @@ -132,4 +132,4 @@ bool SurfaceParams::CanTexCopy(const SurfaceParams& texcopy_params) const { return FromInterval(texcopy_params.GetInterval()).GetInterval() == texcopy_params.GetInterval(); } -} // namespace OpenGL +} // namespace VideoCore diff --git a/src/video_core/rasterizer_cache/surface_params.h b/src/video_core/rasterizer_cache/surface_params.h index 4276f3cf4..15a73881a 100644 --- a/src/video_core/rasterizer_cache/surface_params.h +++ b/src/video_core/rasterizer_cache/surface_params.h @@ -99,4 +99,4 @@ public: SurfaceType type = SurfaceType::Invalid; }; -} // namespace OpenGL +} // namespace VideoCore diff --git a/src/video_core/rasterizer_cache/types.h b/src/video_core/rasterizer_cache/types.h deleted file mode 100644 index 669ce2ddf..000000000 --- a/src/video_core/rasterizer_cache/types.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once -#include "common/common_types.h" -#include "common/math_util.h" -#include "common/vector_math.h" - -namespace VideoCore { - -using Rect2D = Common::Rectangle; - -struct Offset { - constexpr auto operator<=>(const Offset&) const noexcept = default; - - u32 x = 0; - u32 y = 0; -}; - -struct Extent { - constexpr auto operator<=>(const Extent&) const noexcept = default; - - u32 width = 1; - u32 height = 1; -}; - -union ClearValue { - Common::Vec4f color; - struct { - float depth; - u8 stencil; - }; -}; - -struct TextureClear { - u32 texture_level; - Rect2D texture_rect; -}; - -struct TextureCopy { - u32 src_level; - u32 dst_level; - u32 src_layer; - u32 dst_layer; - Offset src_offset; - Offset dst_offset; - Extent extent; -}; - -struct TextureBlit { - u32 src_level; - u32 dst_level; - u32 src_layer; - u32 dst_layer; - Rect2D src_rect; - Rect2D dst_rect; -}; - -struct BufferTextureCopy { - u32 buffer_offset; - u32 buffer_size; - Rect2D texture_rect; - u32 texture_level; -}; - -struct BufferCopy { - u32 src_offset; - u32 dst_offset; - u32 size; -}; - -} // namespace OpenGL diff --git a/src/video_core/rasterizer_cache/utils.cpp b/src/video_core/rasterizer_cache/utils.cpp index 28c8965b1..3b4a6b654 100644 --- a/src/video_core/rasterizer_cache/utils.cpp +++ b/src/video_core/rasterizer_cache/utils.cpp @@ -2,7 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#pragma once #include "common/assert.h" #include "video_core/texture/texture_decode.h" #include "video_core/rasterizer_cache/morton_swizzle.h" @@ -11,6 +10,43 @@ namespace VideoCore { +ClearValue MakeClearValue(SurfaceType type, PixelFormat format, const u8* fill_data) { + ClearValue result{}; + switch (type) { + case SurfaceType::Color: + case SurfaceType::Texture: + case SurfaceType::Fill: { + Pica::Texture::TextureInfo tex_info{}; + tex_info.format = static_cast(format); + const auto color = Pica::Texture::LookupTexture(fill_data, 0, 0, tex_info); + result.color = color / 255.f; + break; + } + case SurfaceType::Depth: { + u32 depth_uint = 0; + if (format == PixelFormat::D16) { + std::memcpy(&depth_uint, fill_data, 2); + result.depth = depth_uint / 65535.0f; // 2^16 - 1 + } else if (format == PixelFormat::D24) { + std::memcpy(&depth_uint, fill_data, 3); + result.depth = depth_uint / 16777215.0f; // 2^24 - 1 + } + break; + } + case SurfaceType::DepthStencil: { + u32 clear_value_uint; + std::memcpy(&clear_value_uint, fill_data, sizeof(u32)); + result.depth = (clear_value_uint & 0xFFFFFF) / 16777215.0f; // 2^24 - 1 + result.stencil = (clear_value_uint >> 24); + break; + } + default: + UNREACHABLE_MSG("Invalid surface type!"); + } + + return result; +} + void SwizzleTexture(const SurfaceParams& swizzle_info, PAddr start_addr, PAddr end_addr, std::span source_linear, std::span dest_tiled) { const u32 func_index = static_cast(swizzle_info.pixel_format); @@ -29,43 +65,4 @@ void UnswizzleTexture(const SurfaceParams& unswizzle_info, PAddr start_addr, PAd dest_linear, source_tiled); } -ClearValue MakeClearValue(SurfaceType type, PixelFormat format, const u8* fill_data) { - ClearValue result{}; - switch (type) { - case SurfaceType::Color: - case SurfaceType::Texture: - case SurfaceType::Fill: { - Pica::Texture::TextureInfo tex_info{}; - tex_info.format = static_cast(format); - - Common::Vec4 color = Pica::Texture::LookupTexture(fill_data, 0, 0, tex_info); - result.color = color / 255.f; - break; - } - case SurfaceType::Depth: { - u32 depth_uint = 0; - if (format == PixelFormat::D16) { - std::memcpy(&depth_uint, fill_data, 2); - result.depth = depth_uint / 65535.0f; // 2^16 - 1 - } else if (format == PixelFormat::D24) { - std::memcpy(&depth_uint, fill_data, 3); - result.depth = depth_uint / 16777215.0f; // 2^24 - 1 - } - break; - } - case SurfaceType::DepthStencil: { - u32 clear_value_uint; - std::memcpy(&clear_value_uint, fill_data, sizeof(u32)); - - result.depth = (clear_value_uint & 0xFFFFFF) / 16777215.0f; // 2^24 - 1 - result.stencil = (clear_value_uint >> 24); - break; - } - default: - UNREACHABLE_MSG("Invalid surface type!"); - } - - return result; -} - } // namespace VideoCore diff --git a/src/video_core/rasterizer_cache/utils.h b/src/video_core/rasterizer_cache/utils.h index 64ee0d62f..58bab1eee 100644 --- a/src/video_core/rasterizer_cache/utils.h +++ b/src/video_core/rasterizer_cache/utils.h @@ -3,13 +3,77 @@ // Refer to the license.txt file included. #pragma once + #include #include "common/hash.h" +#include "common/math_util.h" +#include "common/vector_math.h" #include "video_core/rasterizer_cache/pixel_format.h" -#include "video_core/rasterizer_cache/types.h" namespace VideoCore { +class SurfaceParams; +using Rect2D = Common::Rectangle; + +struct Offset { + constexpr auto operator<=>(const Offset&) const noexcept = default; + + u32 x = 0; + u32 y = 0; +}; + +struct Extent { + constexpr auto operator<=>(const Extent&) const noexcept = default; + + u32 width = 1; + u32 height = 1; +}; + +union ClearValue { + Common::Vec4f color; + struct { + float depth; + u8 stencil; + }; +}; + +struct TextureClear { + u32 texture_level; + Rect2D texture_rect; +}; + +struct TextureCopy { + u32 src_level; + u32 dst_level; + u32 src_layer; + u32 dst_layer; + Offset src_offset; + Offset dst_offset; + Extent extent; +}; + +struct TextureBlit { + u32 src_level; + u32 dst_level; + u32 src_layer; + u32 dst_layer; + Rect2D src_rect; + Rect2D dst_rect; +}; + +struct BufferTextureCopy { + u32 buffer_offset; + u32 buffer_size; + Rect2D texture_rect; + u32 texture_level; +}; + +struct BufferCopy { + u32 src_offset; + u32 dst_offset; + u32 size; +}; + struct HostTextureTag { PixelFormat format{}; u32 width = 0; @@ -40,8 +104,6 @@ struct TextureCubeConfig { } }; -class SurfaceParams; - [[nodiscard]] ClearValue MakeClearValue(SurfaceType type, PixelFormat format, const u8* fill_data); /** diff --git a/src/video_core/regs_texturing.h b/src/video_core/regs_texturing.h index 3954e13b4..1c831947e 100644 --- a/src/video_core/regs_texturing.h +++ b/src/video_core/regs_texturing.h @@ -5,7 +5,6 @@ #pragma once #include - #include "common/assert.h" #include "common/bit_field.h" #include "common/common_funcs.h" diff --git a/src/video_core/renderer_opengl/gl_texture_runtime.h b/src/video_core/renderer_opengl/gl_texture_runtime.h index b96efe187..d57b2659c 100644 --- a/src/video_core/renderer_opengl/gl_texture_runtime.h +++ b/src/video_core/renderer_opengl/gl_texture_runtime.h @@ -7,7 +7,6 @@ #include #include "video_core/rasterizer_cache/rasterizer_cache.h" #include "video_core/rasterizer_cache/surface_base.h" -#include "video_core/rasterizer_cache/types.h" #include "video_core/renderer_opengl/gl_resource_manager.h" #include "video_core/renderer_opengl/texture_filters/texture_filterer.h" #include "video_core/renderer_opengl/texture_downloader_es.h" diff --git a/src/video_core/renderer_vulkan/vk_texture_runtime.h b/src/video_core/renderer_vulkan/vk_texture_runtime.h index 60bcb9a09..13bf49716 100644 --- a/src/video_core/renderer_vulkan/vk_texture_runtime.h +++ b/src/video_core/renderer_vulkan/vk_texture_runtime.h @@ -8,7 +8,6 @@ #include #include "video_core/rasterizer_cache/rasterizer_cache.h" #include "video_core/rasterizer_cache/surface_base.h" -#include "video_core/rasterizer_cache/types.h" #include "video_core/renderer_vulkan/vk_stream_buffer.h" #include "video_core/renderer_vulkan/vk_instance.h" #include "video_core/renderer_vulkan/vk_task_scheduler.h"