mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Assorted texture format cleanup, prep for supporting D3D11 on Win7
This commit is contained in:
parent
b94ad12aea
commit
f24b1495ba
19 changed files with 94 additions and 75 deletions
|
@ -49,6 +49,31 @@
|
|||
#define TEXCACHE_MIN_PRESSURE 16 * 1024 * 1024 // Total in VRAM
|
||||
#define TEXCACHE_SECOND_MIN_PRESSURE 4 * 1024 * 1024
|
||||
|
||||
// Just for reference
|
||||
|
||||
// PSP Color formats:
|
||||
// 565: BBBBBGGGGGGRRRRR
|
||||
// 5551: ABBBBBGGGGGRRRRR
|
||||
// 4444: AAAABBBBGGGGRRRR
|
||||
// 8888: AAAAAAAABBBBBBBBGGGGGGGGRRRRRRRR (Bytes in memory: RGBA)
|
||||
|
||||
// D3D11/9 Color formats:
|
||||
// DXGI_FORMAT_B4G4R4A4/D3DFMT_A4R4G4B4: AAAARRRRGGGGBBBB
|
||||
// DXGI_FORMAT_B5G5R5A1/D3DFMT_A1R5G6B5: ARRRRRGGGGGBBBBB
|
||||
// DXGI_FORMAT_B5G6R6/D3DFMT_R5G6B5: RRRRRGGGGGGBBBBB
|
||||
// DXGI_FORMAT_B8G8R8A8: AAAAAAAARRRRRRRRGGGGGGGGBBBBBBBB (Bytes in memory: BGRA)
|
||||
// These are Data::Format:: A4R4G4B4_PACK16, A1R5G6B5_PACK16, R5G6B5_PACK16, B8G8R8A8.
|
||||
// So these are good matches, just with R/B swapped.
|
||||
|
||||
// OpenGL ES color formats:
|
||||
// GL_UNSIGNED_SHORT_4444: BBBBGGGGRRRRAAAA (4-bit rotation)
|
||||
// GL_UNSIGNED_SHORT_565: BBBBBGGGGGGRRRRR (match)
|
||||
// GL_UNSIGNED_SHORT_1555: BBBBBGGGGGRRRRRA (1-bit rotation)
|
||||
// GL_UNSIGNED_BYTE/RGBA: AAAAAAAABBBBBBBBGGGGGGGGRRRRRRRR (match)
|
||||
// These are Data::Format:: B4G4R4A4_PACK16, B5G6R6_PACK16, B5G5R5A1_PACK16, R8G8B8A8
|
||||
|
||||
// Vulkan color formats:
|
||||
// TODO
|
||||
TextureCacheCommon::TextureCacheCommon(Draw::DrawContext *draw)
|
||||
: draw_(draw),
|
||||
clearCacheNextFrame_(false),
|
||||
|
@ -105,7 +130,7 @@ void TextureCacheCommon::GetSamplingParams(int &minFilt, int &magFilt, bool &sCl
|
|||
sClamp = gstate.isTexCoordClampedS();
|
||||
tClamp = gstate.isTexCoordClampedT();
|
||||
|
||||
bool noMip = (gstate.texlevel & 0xFFFFFF) == 0x000001 || (gstate.texlevel & 0xFFFFFF) == 0x100001 ; // Fix texlevel at 0
|
||||
bool noMip = (gstate.texlevel & 0xFFFFFF) == 0x000001 || (gstate.texlevel & 0xFFFFFF) == 0x100001; // Fix texlevel at 0
|
||||
if (IsFakeMipmapChange())
|
||||
noMip = gstate.getTexLevelMode() == GE_TEXLEVEL_MODE_CONST;
|
||||
|
||||
|
@ -974,7 +999,7 @@ static void ReverseColors(void *dstBuf, const void *srcBuf, GETextureFormat fmt,
|
|||
}
|
||||
}
|
||||
|
||||
void TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETextureFormat format, GEPaletteFormat clutformat, uint32_t texaddr, int level, int bufw, bool reverseColors, bool useBGRA) {
|
||||
void TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETextureFormat format, GEPaletteFormat clutformat, uint32_t texaddr, int level, int bufw, bool reverseColors, bool useBGRA, bool expandTo32bit) {
|
||||
bool swizzled = gstate.isTextureSwizzled();
|
||||
if ((texaddr & 0x00600000) != 0 && Memory::IsVRAMAddress(texaddr)) {
|
||||
// This means it's in a mirror, possibly a swizzled mirror. Let's report.
|
||||
|
|
|
@ -225,7 +225,7 @@ protected:
|
|||
u32 yOffset;
|
||||
};
|
||||
|
||||
void DecodeTextureLevel(u8 *out, int outPitch, GETextureFormat format, GEPaletteFormat clutformat, uint32_t texaddr, int level, int bufw, bool reverseColors, bool useBGRA = false);
|
||||
void DecodeTextureLevel(u8 *out, int outPitch, GETextureFormat format, GEPaletteFormat clutformat, uint32_t texaddr, int level, int bufw, bool reverseColors, bool useBGRA, bool expandTo32bit);
|
||||
void UnswizzleFromMem(u32 *dest, u32 destPitch, const u8 *texptr, u32 bufw, u32 height, u32 bytesPerPixel);
|
||||
void ReadIndexedTex(u8 *out, int outPitch, int level, const u8 *texptr, int bytesPerIndex, int bufw);
|
||||
|
||||
|
|
|
@ -512,8 +512,11 @@ void GPU_D3D11::CheckGPUFeatures() {
|
|||
features |= GPU_SUPPORTS_DUALSOURCE_BLEND;
|
||||
features |= GPU_SUPPORTS_ANY_COPY_IMAGE;
|
||||
|
||||
if (draw_->GetDataFormatSupport(Draw::DataFormat::A4B4G4R4_UNORM_PACK16) & Draw::FMT_TEXTURE) {
|
||||
features |= GPU_SUPPORTS_4BIT_FORMAT;
|
||||
uint32_t fmt4444 = draw_->GetDataFormatSupport(Draw::DataFormat::A4R4G4B4_UNORM_PACK16);
|
||||
uint32_t fmt1555 = draw_->GetDataFormatSupport(Draw::DataFormat::A1R5G5B5_UNORM_PACK16);
|
||||
uint32_t fmt565 = draw_->GetDataFormatSupport(Draw::DataFormat::R5G6B5_UNORM_PACK16);
|
||||
if ((fmt4444 & Draw::FMT_TEXTURE) && (fmt565 & Draw::FMT_TEXTURE) && (fmt1555 & Draw::FMT_TEXTURE)) {
|
||||
features |= GPU_SUPPORTS_16BIT_FORMATS;
|
||||
}
|
||||
|
||||
if (draw_->GetDeviceCaps().logicOpSupported) {
|
||||
|
|
|
@ -146,7 +146,7 @@ void TextureCacheD3D11::InvalidateLastTexture(TexCacheEntry *entry) {
|
|||
}
|
||||
}
|
||||
|
||||
DXGI_FORMAT getClutDestFormatD3D11(GEPaletteFormat format) {
|
||||
DXGI_FORMAT TextureCacheD3D11::GetClutDestFormatD3D11(GEPaletteFormat format) {
|
||||
switch (format) {
|
||||
case GE_CMODE_16BIT_ABGR4444:
|
||||
return DXGI_FORMAT_B4G4R4A4_UNORM;
|
||||
|
@ -427,7 +427,7 @@ void TextureCacheD3D11::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFra
|
|||
const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16);
|
||||
const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor;
|
||||
|
||||
TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormatD3D11(clutFormat), clutTotalColors, clutTotalColors, 1);
|
||||
TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, GetClutDestFormatD3D11(clutFormat), clutTotalColors, clutTotalColors, 1);
|
||||
gstate_c.textureFullAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL;
|
||||
gstate_c.textureSimpleAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE;
|
||||
} else {
|
||||
|
@ -708,7 +708,7 @@ void TextureCacheD3D11::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &
|
|||
decPitch = mapRowPitch;
|
||||
}
|
||||
|
||||
DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false, false);
|
||||
DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false, false, false);
|
||||
|
||||
if (scaleFactor > 1) {
|
||||
scaler.ScaleAlways((u32 *)mapData, pixelData, dstFmt, w, h, scaleFactor);
|
||||
|
|
|
@ -79,6 +79,8 @@ private:
|
|||
void ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffer *framebuffer) override;
|
||||
void BuildTexture(TexCacheEntry *const entry, bool replaceImages) override;
|
||||
|
||||
DXGI_FORMAT GetClutDestFormatD3D11(GEPaletteFormat format);
|
||||
|
||||
ID3D11Device *device_;
|
||||
ID3D11DeviceContext *context_;
|
||||
|
||||
|
|
|
@ -473,11 +473,12 @@ void GPU_DX9::UpdateCmdInfo() {
|
|||
void GPU_DX9::CheckGPUFeatures() {
|
||||
u32 features = 0;
|
||||
|
||||
features |= GPU_SUPPORTS_4BIT_FORMAT;
|
||||
features |= GPU_SUPPORTS_16BIT_FORMATS;
|
||||
features |= GPU_SUPPORTS_BLEND_MINMAX;
|
||||
features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL;
|
||||
features |= GPU_PREFER_CPU_DOWNLOAD;
|
||||
features |= GPU_SUPPORTS_ACCURATE_DEPTH;
|
||||
features |= GPU_SUPPORTS_16BIT_FORMATS;
|
||||
|
||||
D3DCAPS9 caps;
|
||||
ZeroMemory(&caps, sizeof(caps));
|
||||
|
|
|
@ -708,7 +708,7 @@ void TextureCacheDX9::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &re
|
|||
decPitch = w * bpp;
|
||||
}
|
||||
|
||||
DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false);
|
||||
DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false, false, false);
|
||||
|
||||
if (scaleFactor > 1) {
|
||||
scaler.ScaleAlways((u32 *)rect.pBits, pixelData, dstFmt, w, h, scaleFactor);
|
||||
|
|
|
@ -506,7 +506,7 @@ GPU_GLES::~GPU_GLES() {
|
|||
void GPU_GLES::CheckGPUFeatures() {
|
||||
u32 features = 0;
|
||||
|
||||
features |= GPU_SUPPORTS_4BIT_FORMAT;
|
||||
features |= GPU_SUPPORTS_16BIT_FORMATS;
|
||||
|
||||
if (gl_extensions.ARB_blend_func_extended || gl_extensions.EXT_blend_func_extended) {
|
||||
if (gl_extensions.gpuVendor == GPU_VENDOR_INTEL || !gl_extensions.VersionGEThan(3, 0, 0)) {
|
||||
|
|
|
@ -766,7 +766,7 @@ void *TextureCacheGLES::DecodeTextureLevelOld(GETextureFormat format, GEPaletteF
|
|||
}
|
||||
|
||||
tmpTexBufRearrange_.resize(std::max(w, bufw) * h);
|
||||
DecodeTextureLevel((u8 *)tmpTexBufRearrange_.data(), decPitch, format, clutformat, texaddr, level, bufw, true, UseBGRA8888());
|
||||
DecodeTextureLevel((u8 *)tmpTexBufRearrange_.data(), decPitch, format, clutformat, texaddr, level, bufw, true, UseBGRA8888(), false);
|
||||
return tmpTexBufRearrange_.data();
|
||||
}
|
||||
|
||||
|
|
|
@ -459,7 +459,7 @@ enum {
|
|||
GPU_SUPPORTS_INSTANCE_RENDERING = FLAG_BIT(10),
|
||||
GPU_SUPPORTS_VERTEX_TEXTURE_FETCH = FLAG_BIT(11),
|
||||
GPU_SUPPORTS_TEXTURE_FLOAT = FLAG_BIT(12),
|
||||
GPU_SUPPORTS_4BIT_FORMAT = FLAG_BIT(13),
|
||||
GPU_SUPPORTS_16BIT_FORMATS = FLAG_BIT(13),
|
||||
GPU_SUPPORTS_LARGE_VIEWPORTS = FLAG_BIT(16),
|
||||
GPU_SUPPORTS_ACCURATE_DEPTH = FLAG_BIT(17),
|
||||
GPU_SUPPORTS_VAO = FLAG_BIT(18),
|
||||
|
|
|
@ -463,32 +463,34 @@ GPU_Vulkan::~GPU_Vulkan() {
|
|||
}
|
||||
|
||||
void GPU_Vulkan::CheckGPUFeatures() {
|
||||
gstate_c.featureFlags = 0;
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_4BIT_FORMAT;
|
||||
uint32_t features = 0;
|
||||
features |= GPU_SUPPORTS_16BIT_FORMATS;
|
||||
if (vulkan_->GetFeaturesEnabled().wideLines) {
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_WIDE_LINES;
|
||||
features |= GPU_SUPPORTS_WIDE_LINES;
|
||||
}
|
||||
if (vulkan_->GetFeaturesEnabled().dualSrcBlend) {
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_DUALSOURCE_BLEND;
|
||||
features |= GPU_SUPPORTS_DUALSOURCE_BLEND;
|
||||
}
|
||||
if (vulkan_->GetFeaturesEnabled().logicOp) {
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_LOGIC_OP;
|
||||
features |= GPU_SUPPORTS_LOGIC_OP;
|
||||
}
|
||||
if (vulkan_->GetFeaturesEnabled().samplerAnisotropy) {
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_ANISOTROPY;
|
||||
features |= GPU_SUPPORTS_ANISOTROPY;
|
||||
}
|
||||
|
||||
if (PSP_CoreParameter().compat.flags().ClearToRAM) {
|
||||
gstate_c.featureFlags |= GPU_USE_CLEAR_RAM_HACK;
|
||||
features |= GPU_USE_CLEAR_RAM_HACK;
|
||||
}
|
||||
|
||||
// Mandatory features on Vulkan, which may be checked in "centralized" code
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL;
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_FBO;
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_BLEND_MINMAX;
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_ANY_COPY_IMAGE;
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_OES_TEXTURE_NPOT;
|
||||
gstate_c.featureFlags |= GPU_SUPPORTS_LARGE_VIEWPORTS;
|
||||
features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL;
|
||||
features |= GPU_SUPPORTS_FBO;
|
||||
features |= GPU_SUPPORTS_BLEND_MINMAX;
|
||||
features |= GPU_SUPPORTS_ANY_COPY_IMAGE;
|
||||
features |= GPU_SUPPORTS_OES_TEXTURE_NPOT;
|
||||
features |= GPU_SUPPORTS_LARGE_VIEWPORTS;
|
||||
features |= GPU_SUPPORTS_16BIT_FORMATS;
|
||||
gstate_c.featureFlags = features;
|
||||
}
|
||||
|
||||
void GPU_Vulkan::BeginHostFrame() {
|
||||
|
|
|
@ -745,7 +745,7 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt
|
|||
decPitch = w * bpp;
|
||||
}
|
||||
|
||||
DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false);
|
||||
DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false, false, false);
|
||||
gpuStats.numTexturesDecoded++;
|
||||
|
||||
if (scaleFactor > 1) {
|
||||
|
|
|
@ -282,8 +282,8 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
|
|||
|
||||
DataFormat texFormat;
|
||||
// For our purposes these are equivalent, so just choose the supported one. D3D can emulate them.
|
||||
if (draw_->GetDataFormatSupport(Draw::DataFormat::A4B4G4R4_UNORM_PACK16) & FMT_TEXTURE)
|
||||
texFormat = Draw::DataFormat::A4B4G4R4_UNORM_PACK16;
|
||||
if (draw_->GetDataFormatSupport(Draw::DataFormat::A4R4G4B4_UNORM_PACK16) & FMT_TEXTURE)
|
||||
texFormat = Draw::DataFormat::A4R4G4B4_UNORM_PACK16;
|
||||
else if (draw_->GetDataFormatSupport(Draw::DataFormat::B4G4R4A4_UNORM_PACK16) & FMT_TEXTURE)
|
||||
texFormat = Draw::DataFormat::B4G4R4A4_UNORM_PACK16;
|
||||
else
|
||||
|
@ -294,8 +294,7 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
|
|||
TextureDesc desc{};
|
||||
uint32_t *bitmapData32 = nullptr;
|
||||
uint16_t *bitmapData16 = nullptr;
|
||||
if (texFormat == Draw::DataFormat::R8G8B8A8_UNORM) {
|
||||
// We need a full 32-bit format :(
|
||||
if (texFormat == Draw::DataFormat::R8G8B8A8_UNORM || texFormat == Draw::DataFormat::B8G8R8A8_UNORM) {
|
||||
bitmapData32 = new uint32_t[entry->bmWidth * entry->bmHeight];
|
||||
for (int y = 0; y < entry->bmHeight; y++) {
|
||||
for (int x = 0; x < entry->bmWidth; x++) {
|
||||
|
@ -313,7 +312,7 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
|
|||
}
|
||||
}
|
||||
desc.initData.push_back((uint8_t *)bitmapData16);
|
||||
} else {
|
||||
} else if (texFormat == Draw::DataFormat::A4R4G4B4_UNORM_PACK16) {
|
||||
bitmapData16 = new uint16_t[entry->bmWidth * entry->bmHeight];
|
||||
for (int y = 0; y < entry->bmHeight; y++) {
|
||||
for (int x = 0; x < entry->bmWidth; x++) {
|
||||
|
|
|
@ -13,7 +13,7 @@ size_t DataFormatSizeInBytes(DataFormat fmt) {
|
|||
|
||||
case DataFormat::R4G4B4A4_UNORM_PACK16: return 2;
|
||||
case DataFormat::B4G4R4A4_UNORM_PACK16: return 2;
|
||||
case DataFormat::A4B4G4R4_UNORM_PACK16: return 2;
|
||||
case DataFormat::A4R4G4B4_UNORM_PACK16: return 2;
|
||||
case DataFormat::R5G5B5A1_UNORM_PACK16: return 2;
|
||||
case DataFormat::B5G5R5A1_UNORM_PACK16: return 2;
|
||||
case DataFormat::R5G6B5_UNORM_PACK16: return 2;
|
||||
|
|
|
@ -192,14 +192,14 @@ enum class DataFormat : uint8_t {
|
|||
R8G8B8A8_SINT,
|
||||
|
||||
R4G4_UNORM_PACK8,
|
||||
A4B4G4R4_UNORM_PACK16, // This is the one D3D supports
|
||||
B4G4R4A4_UNORM_PACK16, // Supported by Vulkan (guaranteed one), as is the below but not on all cards.
|
||||
R4G4B4A4_UNORM_PACK16, // This is the one OpenGL ES supports
|
||||
A4R4G4B4_UNORM_PACK16, // A4 in the UPPER bit
|
||||
B4G4R4A4_UNORM_PACK16,
|
||||
R4G4B4A4_UNORM_PACK16,
|
||||
R5G6B5_UNORM_PACK16,
|
||||
B5G6R5_UNORM_PACK16,
|
||||
R5G5B5A1_UNORM_PACK16,
|
||||
B5G5R5A1_UNORM_PACK16,
|
||||
A1R5G5B5_UNORM_PACK16,
|
||||
R5G5B5A1_UNORM_PACK16, // A1 in the LOWER bit
|
||||
B5G5R5A1_UNORM_PACK16, // A1 in the LOWER bit
|
||||
A1R5G5B5_UNORM_PACK16, // A1 in the UPPER bit.
|
||||
|
||||
R16_FLOAT,
|
||||
R16G16_FLOAT,
|
||||
|
@ -297,6 +297,7 @@ enum FormatSupport {
|
|||
FMT_RENDERTARGET = 1,
|
||||
FMT_TEXTURE = 2,
|
||||
FMT_INPUTLAYOUT = 4,
|
||||
FMT_DEPTHSTENCIL = 8,
|
||||
};
|
||||
|
||||
enum InfoField {
|
||||
|
|
|
@ -383,7 +383,7 @@ static DXGI_FORMAT dataFormatToD3D11(DataFormat format) {
|
|||
case DataFormat::R32G32_FLOAT: return DXGI_FORMAT_R32G32_FLOAT;
|
||||
case DataFormat::R32G32B32_FLOAT: return DXGI_FORMAT_R32G32B32_FLOAT;
|
||||
case DataFormat::R32G32B32A32_FLOAT: return DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
case DataFormat::A4B4G4R4_UNORM_PACK16: return DXGI_FORMAT_B4G4R4A4_UNORM;
|
||||
case DataFormat::A4R4G4B4_UNORM_PACK16: return DXGI_FORMAT_B4G4R4A4_UNORM;
|
||||
case DataFormat::A1R5G5B5_UNORM_PACK16: return DXGI_FORMAT_B5G5R5A1_UNORM;
|
||||
case DataFormat::R5G6B5_UNORM_PACK16: return DXGI_FORMAT_B5G6R5_UNORM;
|
||||
case DataFormat::R8G8B8A8_UNORM: return DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
|
@ -1023,37 +1023,23 @@ void D3D11DrawContext::DrawUP(const void *vdata, int vertexCount) {
|
|||
}
|
||||
|
||||
uint32_t D3D11DrawContext::GetDataFormatSupport(DataFormat fmt) const {
|
||||
// TODO: Actually do proper checks
|
||||
switch (fmt) {
|
||||
case DataFormat::B8G8R8A8_UNORM:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE;
|
||||
|
||||
// D3D11 has no support for 4-bit component formats, except this one and only on Windows 8.
|
||||
case DataFormat::A4B4G4R4_UNORM_PACK16:
|
||||
return b4g4r4a4Supported_ ? FMT_TEXTURE : 0;
|
||||
|
||||
case DataFormat::R4G4B4A4_UNORM_PACK16:
|
||||
case DataFormat::B4G4R4A4_UNORM_PACK16:
|
||||
DXGI_FORMAT giFmt = dataFormatToD3D11(fmt);
|
||||
if (giFmt == DXGI_FORMAT_UNKNOWN)
|
||||
return 0;
|
||||
|
||||
case DataFormat::R8G8B8A8_UNORM:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE | FMT_INPUTLAYOUT;
|
||||
|
||||
case DataFormat::R32_FLOAT:
|
||||
case DataFormat::R32G32_FLOAT:
|
||||
case DataFormat::R32G32B32_FLOAT:
|
||||
case DataFormat::R32G32B32A32_FLOAT:
|
||||
return FMT_INPUTLAYOUT;
|
||||
|
||||
case DataFormat::R8_UNORM:
|
||||
UINT giSupport = 0;
|
||||
HRESULT result = device_->CheckFormatSupport(giFmt, &giSupport);
|
||||
if (FAILED(result))
|
||||
return 0;
|
||||
case DataFormat::BC1_RGBA_UNORM_BLOCK:
|
||||
case DataFormat::BC2_UNORM_BLOCK:
|
||||
case DataFormat::BC3_UNORM_BLOCK:
|
||||
return FMT_TEXTURE;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
uint32_t support = 0;
|
||||
if (giSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D)
|
||||
support |= FMT_TEXTURE;
|
||||
if (giSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET)
|
||||
support |= FMT_RENDERTARGET;
|
||||
if (giSupport & D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER)
|
||||
support |= FMT_INPUTLAYOUT;
|
||||
if (giSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL)
|
||||
support |= FMT_DEPTHSTENCIL;
|
||||
return support;
|
||||
}
|
||||
|
||||
// A D3D11Framebuffer is a D3D11Framebuffer plus all the textures it owns.
|
||||
|
|
|
@ -122,7 +122,7 @@ D3DFORMAT FormatToD3DFMT(DataFormat fmt) {
|
|||
case DataFormat::R8G8B8A8_UNORM: return D3DFMT_A8R8G8B8;
|
||||
case DataFormat::R4G4B4A4_UNORM_PACK16: return D3DFMT_A4R4G4B4; // emulated
|
||||
case DataFormat::B4G4R4A4_UNORM_PACK16: return D3DFMT_A4R4G4B4; // native
|
||||
case DataFormat::A4B4G4R4_UNORM_PACK16: return D3DFMT_A4R4G4B4; // emulated
|
||||
case DataFormat::A4R4G4B4_UNORM_PACK16: return D3DFMT_A4R4G4B4; // emulated
|
||||
case DataFormat::R5G6B5_UNORM_PACK16: return D3DFMT_R5G6B5;
|
||||
case DataFormat::A1R5G5B5_UNORM_PACK16: return D3DFMT_A1R5G5B5;
|
||||
case DataFormat::D24_S8: return D3DFMT_D24S8;
|
||||
|
@ -407,7 +407,7 @@ void D3D9Texture::SetImageData(int x, int y, int z, int width, int height, int d
|
|||
((uint16_t *)dest)[j] = (color << 12) | (color >> 4);
|
||||
}
|
||||
break;
|
||||
case DataFormat::A4B4G4R4_UNORM_PACK16:
|
||||
case DataFormat::A4R4G4B4_UNORM_PACK16:
|
||||
// Native
|
||||
memcpy(dest, source, width * sizeof(uint16_t));
|
||||
break;
|
||||
|
@ -1162,7 +1162,7 @@ uint32_t D3D9Context::GetDataFormatSupport(DataFormat fmt) const {
|
|||
return FMT_TEXTURE; // emulated support
|
||||
case DataFormat::R5G6B5_UNORM_PACK16:
|
||||
case DataFormat::A1R5G5B5_UNORM_PACK16:
|
||||
case DataFormat::A4B4G4R4_UNORM_PACK16:
|
||||
case DataFormat::A4R4G4B4_UNORM_PACK16:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE; // native support
|
||||
|
||||
case DataFormat::R8G8B8A8_UNORM:
|
||||
|
|
|
@ -743,7 +743,7 @@ void OpenGLTexture::SetImageData(int x, int y, int z, int width, int height, int
|
|||
type = GL_UNSIGNED_SHORT_4_4_4_4;
|
||||
break;
|
||||
#ifndef USING_GLES2
|
||||
case DataFormat::A4B4G4R4_UNORM_PACK16:
|
||||
case DataFormat::A4R4G4B4_UNORM_PACK16:
|
||||
internalFormat = GL_RGBA;
|
||||
format = GL_RGBA;
|
||||
type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
|
||||
|
@ -1657,7 +1657,7 @@ uint32_t OpenGLContext::GetDataFormatSupport(DataFormat fmt) const {
|
|||
return FMT_RENDERTARGET | FMT_TEXTURE;
|
||||
case DataFormat::B4G4R4A4_UNORM_PACK16:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE; // native support
|
||||
case DataFormat::A4B4G4R4_UNORM_PACK16:
|
||||
case DataFormat::A4R4G4B4_UNORM_PACK16:
|
||||
#ifndef USING_GLES2
|
||||
// Can support this if _REV formats are supported.
|
||||
return FMT_TEXTURE;
|
||||
|
|
|
@ -1242,7 +1242,7 @@ uint32_t VKContext::GetDataFormatSupport(DataFormat fmt) const {
|
|||
return FMT_RENDERTARGET | FMT_TEXTURE;
|
||||
case DataFormat::R4G4B4A4_UNORM_PACK16:
|
||||
return 0;
|
||||
case DataFormat::A4B4G4R4_UNORM_PACK16:
|
||||
case DataFormat::A4R4G4B4_UNORM_PACK16:
|
||||
return 0;
|
||||
|
||||
case DataFormat::R8G8B8A8_UNORM:
|
||||
|
|
Loading…
Add table
Reference in a new issue