mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-23 16:19:44 +00:00
Add infrastructure for checking for supported DataFormats
This commit is contained in:
parent
528af8a939
commit
5d6097d33c
@ -4,6 +4,6 @@ xcopy ..\assets\shaders assets\shaders /s /y <d.txt
|
||||
copy ..\assets\langregion.ini assets\langregion.ini
|
||||
copy ..\assets\compat.ini assets\compat.ini
|
||||
copy ..\assets\*.png assets
|
||||
SET NDK=C:\AndroidNDK
|
||||
SET NDK=C:\Android\sdk\ndk-bundle
|
||||
SET NDK_MODULE_PATH=..\ext;..\ext\native\ext
|
||||
%NDK%/ndk-build -j9 %*
|
||||
|
@ -181,13 +181,16 @@ enum class DataFormat : uint8_t {
|
||||
|
||||
R8G8B8A8_UNORM,
|
||||
R8G8B8A8_UNORM_SRGB,
|
||||
B8G8R8A8_UNORM, // D3D style
|
||||
|
||||
R8G8B8A8_SNORM,
|
||||
R8G8B8A8_UINT,
|
||||
R8G8B8A8_SINT,
|
||||
|
||||
R4G4_UNORM,
|
||||
R4G4B4A4_UNORM,
|
||||
A4B4G4R4_UNORM, // This is the one OpenGL ES supports
|
||||
R4G4B4A4_UNORM, // Supported by Vulkan, as is the below
|
||||
B4G4R4A4_UNORM, // This is the one D3D supports
|
||||
|
||||
R16_FLOAT,
|
||||
R16G16_FLOAT,
|
||||
@ -281,6 +284,12 @@ enum class ShaderLanguage {
|
||||
METAL_BYTECODE = 1024,
|
||||
};
|
||||
|
||||
enum FormatSupport {
|
||||
FMT_RENDERTARGET = 1,
|
||||
FMT_TEXTURE = 2,
|
||||
FMT_INPUTLAYOUT = 4,
|
||||
};
|
||||
|
||||
enum InfoField {
|
||||
APINAME,
|
||||
APIVERSION,
|
||||
@ -480,6 +489,7 @@ public:
|
||||
virtual ~DrawContext();
|
||||
|
||||
virtual const DeviceCaps &GetDeviceCaps() const = 0;
|
||||
virtual uint32_t GetDataFormatSupport(DataFormat fmt) const = 0;
|
||||
virtual std::vector<std::string> GetFeatureList() const { return std::vector<std::string>(); }
|
||||
|
||||
virtual uint32_t GetSupportedShaderLanguages() const = 0;
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
uint32_t GetSupportedShaderLanguages() const override {
|
||||
return (uint32_t)ShaderLanguage::HLSL_D3D11 | (uint32_t)ShaderLanguage::HLSL_D3D11_BYTECODE;
|
||||
}
|
||||
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
|
||||
|
||||
InputLayout *CreateInputLayout(const InputLayoutDesc &desc) override;
|
||||
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;
|
||||
@ -360,8 +361,6 @@ class D3D11Texture : public Texture {
|
||||
public:
|
||||
D3D11Texture() {}
|
||||
void SetImageData(int x, int y, int z, int width, int height, int depth, int level, int stride, const uint8_t *data) override;
|
||||
void AutoGenMipmaps() override {}
|
||||
void Finalize() override {}
|
||||
};
|
||||
|
||||
Texture *D3D11DrawContext::CreateTexture(const TextureDesc &desc) {
|
||||
@ -477,6 +476,38 @@ void D3D11DrawContext::DrawUP(const void *vdata, int vertexCount) {
|
||||
ApplyCurrentState();
|
||||
}
|
||||
|
||||
|
||||
uint32_t D3D11DrawContext::GetDataFormatSupport(DataFormat fmt) const {
|
||||
// TODO: Actually do proper checks
|
||||
switch (fmt) {
|
||||
case DataFormat::B8G8R8A8_UNORM:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE;
|
||||
case DataFormat::B4G4R4A4_UNORM:
|
||||
case DataFormat::R4G4B4A4_UNORM:
|
||||
return 0;
|
||||
case DataFormat::A4B4G4R4_UNORM:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE; // native support
|
||||
|
||||
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:
|
||||
return 0;
|
||||
case DataFormat::BC1_RGBA_UNORM_BLOCK:
|
||||
case DataFormat::BC2_UNORM_BLOCK:
|
||||
case DataFormat::BC3_UNORM_BLOCK:
|
||||
return FMT_TEXTURE;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context) {
|
||||
|
@ -518,6 +518,7 @@ public:
|
||||
uint32_t GetSupportedShaderLanguages() const override {
|
||||
return (uint32_t)ShaderLanguage::HLSL_D3D9 | (uint32_t)ShaderLanguage::HLSL_D3D9_BYTECODE;
|
||||
}
|
||||
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
|
||||
|
||||
ShaderModule *CreateShaderModule(ShaderStage stage, ShaderLanguage language, const uint8_t *data, size_t dataSize) override;
|
||||
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;
|
||||
@ -937,4 +938,34 @@ DrawContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapt
|
||||
return new D3D9Context(d3d, d3dEx, adapterId, device, deviceEx);
|
||||
}
|
||||
|
||||
// Only partial implementation!
|
||||
uint32_t D3D9Context::GetDataFormatSupport(DataFormat fmt) const {
|
||||
switch (fmt) {
|
||||
case DataFormat::B8G8R8A8_UNORM:
|
||||
case DataFormat::B4G4R4A4_UNORM: // native support
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE;
|
||||
case DataFormat::A4B4G4R4_UNORM:
|
||||
return FMT_TEXTURE; // emulated support
|
||||
|
||||
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:
|
||||
return 0;
|
||||
case DataFormat::BC1_RGBA_UNORM_BLOCK:
|
||||
case DataFormat::BC2_UNORM_BLOCK:
|
||||
case DataFormat::BC3_UNORM_BLOCK:
|
||||
return FMT_TEXTURE;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Draw
|
@ -503,6 +503,7 @@ public:
|
||||
return (uint32_t)ShaderLanguage::GLSL_ES_200 | (uint32_t)ShaderLanguage::GLSL_410;
|
||||
#endif
|
||||
}
|
||||
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
|
||||
|
||||
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;
|
||||
BlendState *CreateBlendState(const BlendStateDesc &desc) override;
|
||||
@ -1151,4 +1152,34 @@ void OpenGLInputLayout::Unapply() {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t OpenGLContext::GetDataFormatSupport(DataFormat fmt) const {
|
||||
switch (fmt) {
|
||||
case DataFormat::B8G8R8A8_UNORM:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE;
|
||||
case DataFormat::B4G4R4A4_UNORM:
|
||||
case DataFormat::R4G4B4A4_UNORM:
|
||||
return 0;
|
||||
case DataFormat::A4B4G4R4_UNORM:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE; // native support
|
||||
|
||||
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:
|
||||
return 0;
|
||||
case DataFormat::BC1_RGBA_UNORM_BLOCK:
|
||||
case DataFormat::BC2_UNORM_BLOCK:
|
||||
case DataFormat::BC3_UNORM_BLOCK:
|
||||
return FMT_TEXTURE;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Draw
|
@ -354,6 +354,7 @@ public:
|
||||
uint32_t GetSupportedShaderLanguages() const override {
|
||||
return (uint32_t)ShaderLanguage::GLSL_VULKAN | (uint32_t)ShaderLanguage::SPIRV_VULKAN;
|
||||
}
|
||||
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
|
||||
|
||||
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;
|
||||
BlendState *CreateBlendState(const BlendStateDesc &desc) override;
|
||||
@ -1200,4 +1201,35 @@ std::vector<std::string> VKContext::GetFeatureList() const {
|
||||
return features;
|
||||
}
|
||||
|
||||
uint32_t VKContext::GetDataFormatSupport(DataFormat fmt) const {
|
||||
// TODO: Actually do proper checks
|
||||
switch (fmt) {
|
||||
case DataFormat::B8G8R8A8_UNORM:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE;
|
||||
case DataFormat::B4G4R4A4_UNORM:
|
||||
case DataFormat::R4G4B4A4_UNORM:
|
||||
return 0;
|
||||
case DataFormat::A4B4G4R4_UNORM:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE; // native support
|
||||
|
||||
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:
|
||||
return 0;
|
||||
case DataFormat::BC1_RGBA_UNORM_BLOCK:
|
||||
case DataFormat::BC2_UNORM_BLOCK:
|
||||
case DataFormat::BC3_UNORM_BLOCK:
|
||||
return FMT_TEXTURE;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Draw
|
Loading…
Reference in New Issue
Block a user