rasterizer_cache: Code cleanup
* Merge utils and types to a single header
This commit is contained in:
@ -30,7 +30,6 @@ add_library(video_core STATIC
|
|||||||
rasterizer_cache/rasterizer_cache.cpp
|
rasterizer_cache/rasterizer_cache.cpp
|
||||||
rasterizer_cache/rasterizer_cache.h
|
rasterizer_cache/rasterizer_cache.h
|
||||||
rasterizer_cache/surface_base.h
|
rasterizer_cache/surface_base.h
|
||||||
rasterizer_cache/types.h
|
|
||||||
rasterizer_cache/utils.cpp
|
rasterizer_cache/utils.cpp
|
||||||
rasterizer_cache/utils.h
|
rasterizer_cache/utils.h
|
||||||
rasterizer_cache/surface_params.cpp
|
rasterizer_cache/surface_params.cpp
|
||||||
|
@ -270,4 +270,4 @@ static constexpr std::array<MortonFunc, 18> SWIZZLE_TABLE = {
|
|||||||
MortonCopy<false, PixelFormat::D24S8> // 17
|
MortonCopy<false, PixelFormat::D24S8> // 17
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace VideoCore
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include "core/hw/gpu.h"
|
#include "core/hw/gpu.h"
|
||||||
#include "video_core/regs_framebuffer.h"
|
#include "video_core/regs_framebuffer.h"
|
||||||
@ -193,4 +194,4 @@ constexpr u32 GetBytesPerPixel(PixelFormat format) {
|
|||||||
return GetFormatBpp(format) / 8;
|
return GetFormatBpp(format) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace VideoCore
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "common/alignment.h"
|
#include "common/alignment.h"
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "video_core/rasterizer_cache/surface_params.h"
|
#include "video_core/rasterizer_cache/surface_params.h"
|
||||||
#include "video_core/rasterizer_cache/utils.h"
|
|
||||||
|
|
||||||
namespace VideoCore {
|
namespace VideoCore {
|
||||||
|
|
||||||
@ -208,4 +208,4 @@ void SurfaceBase<S>::UnlinkAllWatcher() {
|
|||||||
watcher_count = 0;
|
watcher_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace VideoCore
|
||||||
|
@ -132,4 +132,4 @@ bool SurfaceParams::CanTexCopy(const SurfaceParams& texcopy_params) const {
|
|||||||
return FromInterval(texcopy_params.GetInterval()).GetInterval() == texcopy_params.GetInterval();
|
return FromInterval(texcopy_params.GetInterval()).GetInterval() == texcopy_params.GetInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace VideoCore
|
||||||
|
@ -99,4 +99,4 @@ public:
|
|||||||
SurfaceType type = SurfaceType::Invalid;
|
SurfaceType type = SurfaceType::Invalid;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace VideoCore
|
||||||
|
@ -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<u32>;
|
|
||||||
|
|
||||||
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
|
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "video_core/texture/texture_decode.h"
|
#include "video_core/texture/texture_decode.h"
|
||||||
#include "video_core/rasterizer_cache/morton_swizzle.h"
|
#include "video_core/rasterizer_cache/morton_swizzle.h"
|
||||||
@ -11,6 +10,43 @@
|
|||||||
|
|
||||||
namespace VideoCore {
|
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<Pica::TexturingRegs::TextureFormat>(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,
|
void SwizzleTexture(const SurfaceParams& swizzle_info, PAddr start_addr, PAddr end_addr,
|
||||||
std::span<std::byte> source_linear, std::span<std::byte> dest_tiled) {
|
std::span<std::byte> source_linear, std::span<std::byte> dest_tiled) {
|
||||||
const u32 func_index = static_cast<u32>(swizzle_info.pixel_format);
|
const u32 func_index = static_cast<u32>(swizzle_info.pixel_format);
|
||||||
@ -29,43 +65,4 @@ void UnswizzleTexture(const SurfaceParams& unswizzle_info, PAddr start_addr, PAd
|
|||||||
dest_linear, source_tiled);
|
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<Pica::TexturingRegs::TextureFormat>(format);
|
|
||||||
|
|
||||||
Common::Vec4<u8> 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
|
} // namespace VideoCore
|
||||||
|
@ -3,13 +3,77 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <span>
|
#include <span>
|
||||||
#include "common/hash.h"
|
#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/pixel_format.h"
|
||||||
#include "video_core/rasterizer_cache/types.h"
|
|
||||||
|
|
||||||
namespace VideoCore {
|
namespace VideoCore {
|
||||||
|
|
||||||
|
class SurfaceParams;
|
||||||
|
using Rect2D = Common::Rectangle<u32>;
|
||||||
|
|
||||||
|
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 {
|
struct HostTextureTag {
|
||||||
PixelFormat format{};
|
PixelFormat format{};
|
||||||
u32 width = 0;
|
u32 width = 0;
|
||||||
@ -40,8 +104,6 @@ struct TextureCubeConfig {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SurfaceParams;
|
|
||||||
|
|
||||||
[[nodiscard]] ClearValue MakeClearValue(SurfaceType type, PixelFormat format, const u8* fill_data);
|
[[nodiscard]] ClearValue MakeClearValue(SurfaceType type, PixelFormat format, const u8* fill_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include "video_core/rasterizer_cache/rasterizer_cache.h"
|
#include "video_core/rasterizer_cache/rasterizer_cache.h"
|
||||||
#include "video_core/rasterizer_cache/surface_base.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/gl_resource_manager.h"
|
||||||
#include "video_core/renderer_opengl/texture_filters/texture_filterer.h"
|
#include "video_core/renderer_opengl/texture_filters/texture_filterer.h"
|
||||||
#include "video_core/renderer_opengl/texture_downloader_es.h"
|
#include "video_core/renderer_opengl/texture_downloader_es.h"
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <vulkan/vulkan_hash.hpp>
|
#include <vulkan/vulkan_hash.hpp>
|
||||||
#include "video_core/rasterizer_cache/rasterizer_cache.h"
|
#include "video_core/rasterizer_cache/rasterizer_cache.h"
|
||||||
#include "video_core/rasterizer_cache/surface_base.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_stream_buffer.h"
|
||||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||||
#include "video_core/renderer_vulkan/vk_task_scheduler.h"
|
#include "video_core/renderer_vulkan/vk_task_scheduler.h"
|
||||||
|
Reference in New Issue
Block a user