D3D11: Add proper checks for B4G4R4A4 format support. Not yet using the checks.

This commit is contained in:
Henrik Rydgard committed 2017-02-18 01:41:08 +01:00
1 parent 584650a0c2
commit 6a09d45aee
8 files changed
+41 -9

No files matched your search

+5
View File
@@ -511,6 +511,11 @@ void GPU_D3D11::CheckGPUFeatures() {
features |= GPU_SUPPORTS_LARGE_VIEWPORTS;
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;
}
if (draw_->GetDeviceCaps().logicOpSupported) {
// This requires a little bit more code in statemapping, and passing in a device1_ object.
// features |= GPU_SUPPORTS_LOGIC_OP;
+1
View File
@@ -473,6 +473,7 @@ void GPU_DX9::UpdateCmdInfo() {
void GPU_DX9::CheckGPUFeatures() {
u32 features = 0;
features |= GPU_SUPPORTS_4BIT_FORMAT;
features |= GPU_SUPPORTS_BLEND_MINMAX;
features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL;
features |= GPU_PREFER_CPU_DOWNLOAD;
+3
View File
@@ -505,6 +505,9 @@ GPU_GLES::~GPU_GLES() {
// Take the raw GL extension and versioning data and turn into feature flags.
void GPU_GLES::CheckGPUFeatures() {
u32 features = 0;
features |= GPU_SUPPORTS_4BIT_FORMAT;
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)) {
// Don't use this extension to off on sub 3.0 OpenGL versions as it does not seem reliable
+1
View File
@@ -459,6 +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_LARGE_VIEWPORTS = FLAG_BIT(16),
GPU_SUPPORTS_ACCURATE_DEPTH = FLAG_BIT(17),
GPU_SUPPORTS_VAO = FLAG_BIT(18),
+1
View File
@@ -462,6 +462,7 @@ GPU_Vulkan::~GPU_Vulkan() {
void GPU_Vulkan::CheckGPUFeatures() {
gstate_c.featureFlags = 0;
gstate_c.featureFlags |= GPU_SUPPORTS_4BIT_FORMAT;
if (vulkan_->GetFeaturesEnabled().wideLines) {
gstate_c.featureFlags |= GPU_SUPPORTS_WIDE_LINES;
}
+13 -5
View File
@@ -282,10 +282,10 @@ 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::B4G4R4A4_UNORM_PACK16) & FMT_TEXTURE)
if (draw_->GetDataFormatSupport(Draw::DataFormat::A4B4G4R4_UNORM_PACK16) & FMT_TEXTURE)
texFormat = Draw::DataFormat::A4B4G4R4_UNORM_PACK16;
else if (draw_->GetDataFormatSupport(Draw::DataFormat::B4G4R4A4_UNORM_PACK16) & FMT_TEXTURE)
texFormat = Draw::DataFormat::B4G4R4A4_UNORM_PACK16;
else if (draw_->GetDataFormatSupport(Draw::DataFormat::R4G4B4A4_UNORM_PACK16) & FMT_TEXTURE)
texFormat = Draw::DataFormat::R4G4B4A4_UNORM_PACK16;
else
texFormat = Draw::DataFormat::R8G8B8A8_UNORM;
@@ -304,8 +304,7 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
}
}
desc.initData.push_back((uint8_t *)bitmapData32);
}
else {
} else if (texFormat == Draw::DataFormat::B4G4R4A4_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++) {
@@ -314,6 +313,15 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
}
}
desc.initData.push_back((uint8_t *)bitmapData16);
} else {
bitmapData16 = new uint16_t[entry->bmWidth * entry->bmHeight];
for (int y = 0; y < entry->bmHeight; y++) {
for (int x = 0; x < entry->bmWidth; x++) {
uint8_t bAlpha = (uint8_t)((ctx_->pBitmapBits[MAX_TEXT_WIDTH * y + x] & 0xff) >> 4);
bitmapData16[entry->bmWidth * y + x] = (bAlpha << 12) | 0x0fff;
}
}
desc.initData.push_back((uint8_t *)bitmapData16);
}
desc.type = TextureType::LINEAR2D;
+16 -3
View File
@@ -123,6 +123,7 @@ private:
ID3D11Device *device_;
ID3D11DeviceContext *context_;
IDXGISwapChain *swapChain_ = nullptr;
bool b4g4r4a4Supported_ = false;
ID3D11Texture2D *bbRenderTargetTex_ = nullptr;
ID3D11RenderTargetView *bbRenderTargetView_ = nullptr;
@@ -197,6 +198,13 @@ D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *co
caps_.logicOpSupported = true;
}
}
UINT support;
result = device_->CheckFormatSupport(DXGI_FORMAT_B4G4R4A4_UNORM, &support);
if (SUCCEEDED(result)) {
b4g4r4a4Supported_ = true;
}
int width;
int height;
GetRes(hWnd_, width, height);
@@ -362,6 +370,9 @@ 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::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;
case DataFormat::R8G8B8A8_UNORM_SRGB: return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
case DataFormat::B8G8R8A8_UNORM: return DXGI_FORMAT_B8G8R8A8_UNORM;
@@ -1008,10 +1019,12 @@ uint32_t D3D11DrawContext::GetDataFormatSupport(DataFormat fmt) const {
case DataFormat::B8G8R8A8_UNORM:
return FMT_RENDERTARGET | FMT_TEXTURE;
// D3D11 has no support for 4-bit component formats.
case DataFormat::B4G4R4A4_UNORM_PACK16:
case DataFormat::R4G4B4A4_UNORM_PACK16:
// 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:
return 0;
case DataFormat::R8G8B8A8_UNORM:
+1 -1
View File
@@ -409,7 +409,7 @@ void D3D9Texture::SetImageData(int x, int y, int z, int width, int height, int d
break;
case DataFormat::A4B4G4R4_UNORM_PACK16:
// Native
memcpy(dest, source, j * sizeof(uint16_t));
memcpy(dest, source, width * sizeof(uint16_t));
break;
case DataFormat::R8G8B8A8_UNORM: