From 3cfa233b63dfcd734be2dd0ae4bd0d3e98109df6 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 13 Apr 2024 18:29:52 +0200 Subject: VideoCommon: Use GetSpanForAddress safely in texture decoding Now only VertexLoader remains... But that one might be tricky. --- Source/Core/VideoCommon/TextureDecoder.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoCommon/TextureDecoder.h') diff --git a/Source/Core/VideoCommon/TextureDecoder.h b/Source/Core/VideoCommon/TextureDecoder.h index dcc7513d43..2296c1bfed 100644 --- a/Source/Core/VideoCommon/TextureDecoder.h +++ b/Source/Core/VideoCommon/TextureDecoder.h @@ -3,16 +3,20 @@ #pragma once +#include +#include #include + #include "Common/CommonTypes.h" #include "Common/EnumFormatter.h" +#include "Common/SpanUtils.h" enum { TMEM_SIZE = 1024 * 1024, TMEM_LINE_SIZE = 32, }; -alignas(16) extern u8 texMem[TMEM_SIZE]; +alignas(16) extern std::array s_tex_mem; enum class TextureFormat { @@ -171,6 +175,11 @@ static inline bool CanReinterpretTextureOnGPU(TextureFormat from_format, Texture } } +inline std::span TexDecoder_GetTmemSpan(size_t offset = 0) +{ + return Common::SafeSubspan(std::span(s_tex_mem), offset); +} + int TexDecoder_GetTexelSizeInNibbles(TextureFormat format); int TexDecoder_GetTextureSizeInBytes(int width, int height, TextureFormat format); int TexDecoder_GetBlockWidthInTexels(TextureFormat format); @@ -184,8 +193,10 @@ void TexDecoder_Decode(u8* dst, const u8* src, int width, int height, TextureFor const u8* tlut, TLUTFormat tlutfmt); void TexDecoder_DecodeRGBA8FromTmem(u8* dst, const u8* src_ar, const u8* src_gb, int width, int height); -void TexDecoder_DecodeTexel(u8* dst, const u8* src, int s, int t, int imageWidth, - TextureFormat texformat, const u8* tlut, TLUTFormat tlutfmt); +void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int imageWidth, + TextureFormat texformat, std::span tlut, TLUTFormat tlutfmt); +void TexDecoder_DecodeTexelRGBA8FromTmem(u8* dst, std::span src_ar, + std::span src_gb, int s, int t, int imageWidth); void TexDecoder_DecodeTexelRGBA8FromTmem(u8* dst, const u8* src_ar, const u8* src_gb, int s, int t, int imageWidth); void TexDecoder_DecodeXFB(u8* dst, const u8* src, u32 width, u32 height, u32 stride); -- cgit v1.2.3