diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 39ab036a04..a3588b8192 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -50,12 +50,12 @@ static Thin3DBuffer *idata = nullptr; SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Thin3DContext *_thin3D) : gfxCtx_(gfxCtx), thin3d(_thin3D) { - fbTex = thin3d->CreateTexture(LINEAR2D, RGBA8888, 480, 272, 1, 1); + fbTex = thin3d->CreateTexture(LINEAR2D, T3DDataFormat::R8A8G8B8_UNORM, 480, 272, 1, 1); std::vector components; - components.push_back(Thin3DVertexComponent("Position", SEM_POSITION, FLOATx3, 0)); - components.push_back(Thin3DVertexComponent("TexCoord0", SEM_TEXCOORD0, FLOATx2, 12)); - components.push_back(Thin3DVertexComponent("Color0", SEM_COLOR0, UNORM8x4, 20)); + components.push_back(Thin3DVertexComponent("Position", SEM_POSITION, T3DDataFormat::FLOATx3, 0)); + components.push_back(Thin3DVertexComponent("TexCoord0", SEM_TEXCOORD0, T3DDataFormat::FLOATx2, 12)); + components.push_back(Thin3DVertexComponent("Color0", SEM_COLOR0, T3DDataFormat::UNORM8x4, 20)); Thin3DShader *vshader = thin3d->GetVshaderPreset(VS_TEXTURE_COLOR_2D); vformat = thin3d->CreateVertexFormat(components, 24, vshader); @@ -124,7 +124,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) } thin3d->SetSamplerStates(0, 1, &sampler); thin3d->SetDepthStencilState(depth); - thin3d->SetRenderState(T3DRenderState::CULL_MODE, T3DCullMode::NO_CULL); + thin3d->SetRenderState(T3DRenderState::CULL_MODE, (uint32_t)T3DCullMode::NO_CULL); thin3d->SetScissorEnabled(false); float u0 = 0.0f; diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index d2d7582389..ae3d75fcfc 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -47,6 +47,7 @@ #include "Windows/GPU/WindowsGLContext.h" #include "Windows/GPU/WindowsVulkanContext.h" #include "Windows/GPU/D3D9Context.h" +#include "Windows/GPU/D3D11Context.h" #include "Windows/Debugger/DebuggerShared.h" #include "Windows/Debugger/Debugger_Disasm.h" @@ -113,6 +114,9 @@ bool WindowsHost::InitGraphics(std::string *error_message, GraphicsContext **ctx case GPU_BACKEND_DIRECT3D9: graphicsContext = new D3D9Context(); break; + case GPU_BACKEND_DIRECT3D11: + graphicsContext = new D3D11Context(); + break; case GPU_BACKEND_VULKAN: graphicsContext = new WindowsVulkanContext(); break; diff --git a/ext/native/gfx_es2/draw_buffer.cpp b/ext/native/gfx_es2/draw_buffer.cpp index e50bcaab9e..e38ac1dd21 100644 --- a/ext/native/gfx_es2/draw_buffer.cpp +++ b/ext/native/gfx_es2/draw_buffer.cpp @@ -40,9 +40,9 @@ void DrawBuffer::Init(Thin3DContext *t3d) { inited_ = true; std::vector components; - components.push_back(Thin3DVertexComponent("Position", SEM_POSITION, FLOATx3, 0)); - components.push_back(Thin3DVertexComponent("TexCoord0", SEM_TEXCOORD0, FLOATx2, 12)); - components.push_back(Thin3DVertexComponent("Color0", SEM_COLOR0, UNORM8x4, 20)); + components.push_back(Thin3DVertexComponent("Position", SEM_POSITION, T3DDataFormat::FLOATx3, 0)); + components.push_back(Thin3DVertexComponent("TexCoord0", SEM_TEXCOORD0, T3DDataFormat::FLOATx2, 12)); + components.push_back(Thin3DVertexComponent("Color0", SEM_COLOR0, T3DDataFormat::UNORM8x4, 20)); Thin3DShader *vshader = t3d_->GetVshaderPreset(VS_TEXTURE_COLOR_2D); diff --git a/ext/native/gfx_es2/draw_text.cpp b/ext/native/gfx_es2/draw_text.cpp index a47ad51d16..90bb28278a 100644 --- a/ext/native/gfx_es2/draw_text.cpp +++ b/ext/native/gfx_es2/draw_text.cpp @@ -270,7 +270,7 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float entry->bmWidth = (size.cx + 3) & ~3; entry->bmHeight = (size.cy + 3) & ~3; entry->lastUsedFrame = frameCount_; - entry->texture = thin3d_->CreateTexture(LINEAR2D, RGBA4444, entry->bmWidth, entry->bmHeight, 1, 1); + entry->texture = thin3d_->CreateTexture(LINEAR2D, T3DDataFormat::R4G4B4A4_UNORM, entry->bmWidth, entry->bmHeight, 1, 1); // Convert the bitmap to a gl-compatible array of pixels. uint16_t *bitmapData = new uint16_t[entry->bmWidth * entry->bmHeight]; diff --git a/ext/native/thin3d/thin3d.cpp b/ext/native/thin3d/thin3d.cpp index b8d3285f95..d7a546a7b0 100644 --- a/ext/native/thin3d/thin3d.cpp +++ b/ext/native/thin3d/thin3d.cpp @@ -201,12 +201,12 @@ Thin3DContext::~Thin3DContext() { } } -static T3DImageFormat ZimToT3DFormat(int zim) { +static T3DDataFormat ZimToT3DFormat(int zim) { switch (zim) { - case ZIM_ETC1: return T3DImageFormat::ETC1; - case ZIM_RGBA8888: return T3DImageFormat::RGBA8888; - case ZIM_LUMINANCE: return T3DImageFormat::LUMINANCE; - default: return T3DImageFormat::RGBA8888; + case ZIM_ETC1: return T3DDataFormat::ETC1; + case ZIM_RGBA8888: return T3DDataFormat::R8A8G8B8_UNORM; + case ZIM_LUMINANCE: return T3DDataFormat::LUMINANCE; + default: return T3DDataFormat::R8A8G8B8_UNORM; } } @@ -222,7 +222,7 @@ static T3DImageType DetectImageFileType(const uint8_t *data, size_t size) { } } -static bool LoadTextureLevels(const uint8_t *data, size_t size, T3DImageType type, int width[16], int height[16], int *num_levels, T3DImageFormat *fmt, uint8_t *image[16], int *zim_flags) { +static bool LoadTextureLevels(const uint8_t *data, size_t size, T3DImageType type, int width[16], int height[16], int *num_levels, T3DDataFormat *fmt, uint8_t *image[16], int *zim_flags) { if (type == DETECT) { type = DetectImageFileType(data, size); } @@ -245,7 +245,7 @@ static bool LoadTextureLevels(const uint8_t *data, size_t size, T3DImageType typ case PNG: if (1 == pngLoadPtr((const unsigned char *)data, size, &width[0], &height[0], &image[0], false)) { *num_levels = 1; - *fmt = RGBA8888; + *fmt = T3DDataFormat::R8A8G8B8_UNORM; } break; @@ -255,7 +255,7 @@ static bool LoadTextureLevels(const uint8_t *data, size_t size, T3DImageType typ unsigned char *jpegBuf = jpgd::decompress_jpeg_image_from_memory(data, (int)size, &width[0], &height[0], &actual_components, 4); if (jpegBuf) { *num_levels = 1; - *fmt = RGBA8888; + *fmt = T3DDataFormat::R8A8G8B8_UNORM; image[0] = (uint8_t *)jpegBuf; } } @@ -275,7 +275,7 @@ bool Thin3DTexture::LoadFromFileData(const uint8_t *data, size_t dataSize, T3DIm int num_levels; int zim_flags; - T3DImageFormat fmt; + T3DDataFormat fmt; if (!LoadTextureLevels(data, dataSize, type, width, height, &num_levels, &fmt, image, &zim_flags)) { return false; @@ -331,7 +331,7 @@ Thin3DTexture *Thin3DContext::CreateTextureFromFileData(const uint8_t *data, int int width[16], height[16]; int num_levels = 0; int zim_flags = 0; - T3DImageFormat fmt; + T3DDataFormat fmt; uint8_t *image[16] = { nullptr }; if (!LoadTextureLevels(data, size, type, width, height, &num_levels, &fmt, image, &zim_flags)) { diff --git a/ext/native/thin3d/thin3d.h b/ext/native/thin3d/thin3d.h index f2e37a4861..42d04f2a4a 100644 --- a/ext/native/thin3d/thin3d.h +++ b/ext/native/thin3d/thin3d.h @@ -86,14 +86,6 @@ enum T3DBufferUsage : int { DYNAMIC = 16, }; -enum T3DVertexDataType : uint8_t { - INVALID, - FLOATx2, - FLOATx3, - FLOATx4, - UNORM8x4, -}; - enum T3DSemantic : int { SEM_POSITION, SEM_COLOR0, @@ -160,11 +152,16 @@ enum T3DTextureType : uint8_t { ARRAY2D, }; -enum T3DImageFormat : uint8_t { - IMG_UNKNOWN, +enum class T3DDataFormat : uint8_t { + UNKNOWN, LUMINANCE, - RGBA8888, - RGBA4444, + R8A8G8B8_UNORM, + R4G4B4A4_UNORM, + FLOATx2, + FLOATx3, + FLOATx4, + UNORM8x4, + DXT1, ETC1, // Needs simulation on many platforms D16, @@ -176,7 +173,7 @@ enum T3DRenderState : uint8_t { CULL_MODE, }; -enum T3DCullMode : uint8_t { +enum class T3DCullMode : uint8_t { NO_CULL, CW, CCW, @@ -256,7 +253,7 @@ public: bool LoadFromFile(const std::string &filename, T3DImageType type = T3DImageType::DETECT); bool LoadFromFileData(const uint8_t *data, size_t dataSize, T3DImageType type = T3DImageType::DETECT); - virtual bool Create(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) = 0; + virtual bool Create(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) = 0; virtual void SetImageData(int x, int y, int z, int width, int height, int depth, int level, int stride, const uint8_t *data) = 0; virtual void AutoGenMipmaps() = 0; virtual void Finalize(int zim_flags) = 0; // TODO: Tidy up @@ -270,16 +267,16 @@ protected: }; struct Thin3DVertexComponent { - Thin3DVertexComponent() : name(nullptr), type(T3DVertexDataType::INVALID), semantic(255), offset(255) {} - Thin3DVertexComponent(const char *name, T3DSemantic semantic, T3DVertexDataType dataType, uint8_t offset) { + Thin3DVertexComponent() : name(nullptr), type(T3DDataFormat::UNKNOWN), semantic(255), offset(255) {} + Thin3DVertexComponent(const char *name, T3DSemantic semantic, T3DDataFormat dataType, uint8_t offset) { this->name = name; this->semantic = semantic; this->type = dataType; this->offset = offset; } const char *name; - T3DVertexDataType type; uint8_t semantic; + T3DDataFormat type; uint8_t offset; }; @@ -348,7 +345,7 @@ public: virtual Thin3DVertexFormat *CreateVertexFormat(const std::vector &components, int stride, Thin3DShader *vshader) = 0; virtual Thin3DTexture *CreateTexture() = 0; // To be later filled in by ->LoadFromFile or similar. - virtual Thin3DTexture *CreateTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) = 0; + virtual Thin3DTexture *CreateTexture(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) = 0; // Common Thin3D function, uses CreateTexture Thin3DTexture *CreateTextureFromFile(const char *filename, T3DImageType fileType); diff --git a/ext/native/thin3d/thin3d_d3d9.cpp b/ext/native/thin3d/thin3d_d3d9.cpp index 00a7065313..e3edac15b0 100644 --- a/ext/native/thin3d/thin3d_d3d9.cpp +++ b/ext/native/thin3d/thin3d_d3d9.cpp @@ -267,9 +267,9 @@ class Thin3DDX9Texture : public Thin3DTexture { public: Thin3DDX9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx) : device_(device), deviceEx_(deviceEx), type_(T3DTextureType::UNKNOWN), fmt_(D3DFMT_UNKNOWN), tex_(NULL), volTex_(NULL), cubeTex_(NULL) { } - Thin3DDX9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx, T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels); + Thin3DDX9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx, T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels); ~Thin3DDX9Texture(); - bool Create(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) override; + bool Create(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) override; 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 SetToSampler(LPDIRECT3DDEVICE9 device, int sampler); @@ -285,17 +285,17 @@ private: LPDIRECT3DCUBETEXTURE9 cubeTex_; }; -D3DFORMAT FormatToD3D(T3DImageFormat fmt) { +D3DFORMAT FormatToD3D(T3DDataFormat fmt) { switch (fmt) { - case RGBA8888: return D3DFMT_A8R8G8B8; - case RGBA4444: return D3DFMT_A4R4G4B4; - case D24S8: return D3DFMT_D24S8; - case D16: return D3DFMT_D16; + case T3DDataFormat::R8A8G8B8_UNORM: return D3DFMT_A8R8G8B8; + case T3DDataFormat::R4G4B4A4_UNORM: return D3DFMT_A4R4G4B4; + case T3DDataFormat::D24S8: return D3DFMT_D24S8; + case T3DDataFormat::D16: return D3DFMT_D16; default: return D3DFMT_UNKNOWN; } } -Thin3DDX9Texture::Thin3DDX9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx, T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) +Thin3DDX9Texture::Thin3DDX9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx, T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) : device_(device), deviceEx_(deviceEx), type_(type), tex_(NULL), volTex_(NULL), cubeTex_(NULL) { Create(type, format, width, height, depth, mipLevels); } @@ -312,7 +312,7 @@ Thin3DDX9Texture::~Thin3DDX9Texture() { } } -bool Thin3DDX9Texture::Create(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) { +bool Thin3DDX9Texture::Create(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) { width_ = width; height_ = height; depth_ = depth; @@ -432,7 +432,7 @@ public: Thin3DShaderSet *CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) override; Thin3DVertexFormat *CreateVertexFormat(const std::vector &components, int stride, Thin3DShader *vshader) override; Thin3DTexture *CreateTexture() override; - Thin3DTexture *CreateTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) override; + Thin3DTexture *CreateTexture(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) override; Thin3DShader *CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) override; // Bound state objects. Too cumbersome to add them all as parameters to Draw. @@ -562,7 +562,7 @@ Thin3DTexture *Thin3DDX9Context::CreateTexture() { return tex; } -Thin3DTexture *Thin3DDX9Context::CreateTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) { +Thin3DTexture *Thin3DDX9Context::CreateTexture(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) { Thin3DDX9Texture *tex = new Thin3DDX9Texture(device_, deviceEx_, type, format, width, height, depth, mipLevels); return tex; } @@ -602,12 +602,12 @@ void SemanticToD3D9UsageAndIndex(int semantic, BYTE *usage, BYTE *index) { } } -static int VertexDataTypeToD3DType(T3DVertexDataType type) { +static int VertexDataTypeToD3DType(T3DDataFormat type) { switch (type) { - case T3DVertexDataType::FLOATx2: return D3DDECLTYPE_FLOAT2; - case T3DVertexDataType::FLOATx3: return D3DDECLTYPE_FLOAT3; - case T3DVertexDataType::FLOATx4: return D3DDECLTYPE_FLOAT4; - case T3DVertexDataType::UNORM8x4: return D3DDECLTYPE_UBYTE4N; // D3DCOLOR? + case T3DDataFormat::FLOATx2: return D3DDECLTYPE_FLOAT2; + case T3DDataFormat::FLOATx3: return D3DDECLTYPE_FLOAT3; + case T3DDataFormat::FLOATx4: return D3DDECLTYPE_FLOAT4; + case T3DDataFormat::UNORM8x4: return D3DDECLTYPE_UBYTE4N; // D3DCOLOR? default: return D3DDECLTYPE_UNUSED; } } diff --git a/ext/native/thin3d/thin3d_gl.cpp b/ext/native/thin3d/thin3d_gl.cpp index 7c04edf009..90f5c2d571 100644 --- a/ext/native/thin3d/thin3d_gl.cpp +++ b/ext/native/thin3d/thin3d_gl.cpp @@ -363,7 +363,7 @@ public: Thin3DBuffer *CreateBuffer(size_t size, uint32_t usageFlags) override; Thin3DShaderSet *CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) override; Thin3DVertexFormat *CreateVertexFormat(const std::vector &components, int stride, Thin3DShader *vshader) override; - Thin3DTexture *CreateTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) override; + Thin3DTexture *CreateTexture(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) override; Thin3DTexture *CreateTexture() override; // Bound state objects @@ -516,7 +516,7 @@ public: glGenTextures(1, &tex_); register_gl_resource_holder(this); } - Thin3DGLTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) : tex_(0), target_(TypeToTarget(type)), format_(format), mipLevels_(mipLevels) { + Thin3DGLTexture(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) : tex_(0), target_(TypeToTarget(type)), format_(format), mipLevels_(mipLevels) { generatedMips_ = false; canWrap_ = true; width_ = width; @@ -530,7 +530,7 @@ public: Destroy(); } - bool Create(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) override { + bool Create(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) override { generatedMips_ = false; canWrap_ = true; format_ = format; @@ -589,7 +589,7 @@ private: GLuint tex_; GLuint target_; - T3DImageFormat format_; + T3DDataFormat format_; int mipLevels_; bool generatedMips_; bool canWrap_; @@ -599,7 +599,7 @@ Thin3DTexture *Thin3DGLContext::CreateTexture() { return new Thin3DGLTexture(); } -Thin3DTexture *Thin3DGLContext::CreateTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) { +Thin3DTexture *Thin3DGLContext::CreateTexture(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) { return new Thin3DGLTexture(type, format, width, height, depth, mipLevels); } @@ -618,12 +618,12 @@ void Thin3DGLTexture::SetImageData(int x, int y, int z, int width, int height, i int format; int type; switch (format_) { - case RGBA8888: + case T3DDataFormat::R8A8G8B8_UNORM: internalFormat = GL_RGBA; format = GL_RGBA; type = GL_UNSIGNED_BYTE; break; - case RGBA4444: + case T3DDataFormat::R4G4B4A4_UNORM: internalFormat = GL_RGBA; format = GL_RGBA; type = GL_UNSIGNED_SHORT_4_4_4_4; @@ -966,20 +966,22 @@ void Thin3DGLVertexFormat::Apply(const void *base) { if (b != lastBase_) { for (size_t i = 0; i < components_.size(); i++) { switch (components_[i].type) { - case FLOATx2: + case T3DDataFormat::FLOATx2: glVertexAttribPointer(components_[i].semantic, 2, GL_FLOAT, GL_FALSE, stride_, (void *)(b + (intptr_t)components_[i].offset)); break; - case FLOATx3: + case T3DDataFormat::FLOATx3: glVertexAttribPointer(components_[i].semantic, 3, GL_FLOAT, GL_FALSE, stride_, (void *)(b + (intptr_t)components_[i].offset)); break; - case FLOATx4: + case T3DDataFormat::FLOATx4: glVertexAttribPointer(components_[i].semantic, 4, GL_FLOAT, GL_FALSE, stride_, (void *)(b + (intptr_t)components_[i].offset)); break; - case UNORM8x4: + case T3DDataFormat::UNORM8x4: glVertexAttribPointer(components_[i].semantic, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride_, (void *)(b + (intptr_t)components_[i].offset)); break; - case INVALID: - ELOG("Thin3DGLVertexFormat: Invalid component type applied."); + case T3DDataFormat::UNKNOWN: + default: + ELOG("Thin3DGLVertexFormat: Invalid or unknown component type applied."); + break; } } if (id_ != 0) { diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index e97a08538c..cfcd6c78c8 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -236,12 +236,12 @@ bool Thin3DVKShader::Compile(VulkanContext *vulkan, const char *source) { } -inline VkFormat ConvertVertexDataTypeToVk(T3DVertexDataType type) { +inline VkFormat ConvertVertexDataTypeToVk(T3DDataFormat type) { switch (type) { - case FLOATx2: return VK_FORMAT_R32G32_SFLOAT; - case FLOATx3: return VK_FORMAT_R32G32B32_SFLOAT; - case FLOATx4: return VK_FORMAT_R32G32B32A32_SFLOAT; - case UNORM8x4: return VK_FORMAT_R8G8B8A8_UNORM; + case T3DDataFormat::FLOATx2: return VK_FORMAT_R32G32_SFLOAT; + case T3DDataFormat::FLOATx3: return VK_FORMAT_R32G32B32_SFLOAT; + case T3DDataFormat::FLOATx4: return VK_FORMAT_R32G32B32A32_SFLOAT; + case T3DDataFormat::UNORM8x4: return VK_FORMAT_R8G8B8A8_UNORM; default: return VK_FORMAT_UNDEFINED; } } @@ -361,7 +361,7 @@ public: Thin3DShaderSet *CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) override; Thin3DVertexFormat *CreateVertexFormat(const std::vector &components, int stride, Thin3DShader *vshader) override; Thin3DSamplerState *CreateSamplerState(const T3DSamplerStateDesc &desc) override; - Thin3DTexture *CreateTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) override; + Thin3DTexture *CreateTexture(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) override; Thin3DTexture *CreateTexture() override; // Bound state objects @@ -482,12 +482,12 @@ private: VulkanPushBuffer *push_; }; -VkFormat FormatToVulkan(T3DImageFormat fmt, int *bpp) { +VkFormat FormatToVulkan(T3DDataFormat fmt, int *bpp) { switch (fmt) { - case RGBA8888: *bpp = 32; return VK_FORMAT_R8G8B8A8_UNORM; - case RGBA4444: *bpp = 16; return VK_FORMAT_R4G4B4A4_UNORM_PACK16; - case D24S8: *bpp = 32; return VK_FORMAT_D24_UNORM_S8_UINT; - case D16: *bpp = 16; return VK_FORMAT_D16_UNORM; + case T3DDataFormat::R8A8G8B8_UNORM: *bpp = 32; return VK_FORMAT_R8G8B8A8_UNORM; + case T3DDataFormat::R4G4B4A4_UNORM: *bpp = 16; return VK_FORMAT_R4G4B4A4_UNORM_PACK16; + case T3DDataFormat::D24S8: *bpp = 32; return VK_FORMAT_D24_UNORM_S8_UINT; + case T3DDataFormat::D16: *bpp = 16; return VK_FORMAT_D16_UNORM; default: return VK_FORMAT_UNDEFINED; } } @@ -539,7 +539,7 @@ public: Thin3DVKTexture(VulkanContext *vulkan) : vulkan_(vulkan), vkTex_(nullptr) { } - Thin3DVKTexture(VulkanContext *vulkan, T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) + Thin3DVKTexture(VulkanContext *vulkan, T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) : vulkan_(vulkan), format_(format), mipLevels_(mipLevels) { Create(type, format, width, height, depth, mipLevels); } @@ -548,7 +548,7 @@ public: Destroy(); } - bool Create(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) override { + bool Create(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) override { format_ = format; mipLevels_ = mipLevels; width_ = width; @@ -578,7 +578,7 @@ private: int mipLevels_; - T3DImageFormat format_; + T3DDataFormat format_; }; Thin3DVKContext::Thin3DVKContext(VulkanContext *vulkan) @@ -828,10 +828,10 @@ VkPipeline Thin3DVKContext::GetOrCreatePipeline() { VkPipelineRasterizationStateCreateInfo raster = { VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO }; switch (curCullMode_) { - case NO_CULL: raster.cullMode = VK_CULL_MODE_NONE; break; - case CW: raster.cullMode = VK_CULL_MODE_BACK_BIT; break; + case T3DCullMode::NO_CULL: raster.cullMode = VK_CULL_MODE_NONE; break; + case T3DCullMode::CW: raster.cullMode = VK_CULL_MODE_BACK_BIT; break; default: - case CCW: raster.cullMode = VK_CULL_MODE_FRONT_BIT; break; + case T3DCullMode::CCW: raster.cullMode = VK_CULL_MODE_FRONT_BIT; break; } raster.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; raster.polygonMode = VK_POLYGON_MODE_FILL; @@ -933,7 +933,7 @@ Thin3DTexture *Thin3DVKContext::CreateTexture() { return new Thin3DVKTexture(vulkan_); } -Thin3DTexture *Thin3DVKContext::CreateTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) { +Thin3DTexture *Thin3DVKContext::CreateTexture(T3DTextureType type, T3DDataFormat format, int width, int height, int depth, int mipLevels) { return new Thin3DVKTexture(vulkan_, type, format, width, height, depth, mipLevels); } diff --git a/ext/native/ui/ui_context.cpp b/ext/native/ui/ui_context.cpp index decc0a149e..32ab495faa 100644 --- a/ext/native/ui/ui_context.cpp +++ b/ext/native/ui/ui_context.cpp @@ -42,7 +42,7 @@ void UIContext::Begin() { thin3d_->SetBlendState(blend_); thin3d_->SetSamplerStates(0, 1, &sampler_); thin3d_->SetDepthStencilState(depth_); - thin3d_->SetRenderState(T3DRenderState::CULL_MODE, T3DCullMode::NO_CULL); + thin3d_->SetRenderState(T3DRenderState::CULL_MODE, (uint32_t)T3DCullMode::NO_CULL); thin3d_->SetTexture(0, uitexture_); thin3d_->SetScissorEnabled(false); UIBegin(uishader_); @@ -51,7 +51,7 @@ void UIContext::Begin() { void UIContext::BeginNoTex() { thin3d_->SetBlendState(blend_); thin3d_->SetSamplerStates(0, 1, &sampler_); - thin3d_->SetRenderState(T3DRenderState::CULL_MODE, T3DCullMode::NO_CULL); + thin3d_->SetRenderState(T3DRenderState::CULL_MODE, (uint32_t)T3DCullMode::NO_CULL); UIBegin(uishadernotex_); }