GPUDevice: Extract enums to own file

Further reduction of indirect includes.
This commit is contained in:
Stenzek
2025-12-23 19:51:58 +10:00
parent 9370642434
commit 095fef524d
12 changed files with 127 additions and 116 deletions

View File

@@ -20,6 +20,7 @@
#include "common/bitutils.h"
#include "common/error.h"
#include "common/fifo_queue.h"
#include "common/gsvector.h"
#include "common/log.h"
#include "common/path.h"

View File

@@ -32,6 +32,7 @@ add_library(util
gpu_shader_cache.h
gpu_texture.cpp
gpu_texture.h
gpu_types.h
http_downloader.cpp
http_downloader.h
image.cpp

View File

@@ -33,25 +33,6 @@ class Image;
#define ENABLE_GPU_OBJECT_NAMES
#endif
enum class RenderAPI : u8
{
None,
D3D11,
D3D12,
Vulkan,
OpenGL,
OpenGLES,
Metal
};
enum class GPUVSyncMode : u8
{
Disabled,
FIFO,
Mailbox,
Count
};
class GPUSampler
{
public:
@@ -117,59 +98,6 @@ public:
static Config GetLinearConfig();
};
enum class GPUShaderStage : u8
{
Vertex,
Fragment,
Geometry,
Compute,
MaxCount
};
enum class GPUShaderLanguage : u8
{
None,
HLSL,
GLSL,
GLSLES,
GLSLVK,
MSL,
SPV,
Count
};
enum class GPUDriverType : u16
{
MobileFlag = 0x100,
SoftwareFlag = 0x200,
Unknown = 0,
AMDProprietary = 1,
AMDMesa = 2,
IntelProprietary = 3,
IntelMesa = 4,
NVIDIAProprietary = 5,
NVIDIAMesa = 6,
AppleProprietary = 7,
AppleMesa = 8,
DozenMesa = 9,
ImaginationProprietary = MobileFlag | 1,
ImaginationMesa = MobileFlag | 2,
ARMProprietary = MobileFlag | 3,
ARMMesa = MobileFlag | 4,
QualcommProprietary = MobileFlag | 5,
QualcommMesa = MobileFlag | 6,
BroadcomProprietary = MobileFlag | 7,
BroadcomMesa = MobileFlag | 8,
LLVMPipe = SoftwareFlag | 1,
SwiftShader = SoftwareFlag | 2,
WARP = SoftwareFlag | 3,
};
IMPLEMENT_ENUM_CLASS_BITWISE_OPERATORS(GPUDriverType);
class GPUShader
{
public:

View File

@@ -1,11 +1,12 @@
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
#pragma once
#include "gpu_types.h"
#include "common/gsvector.h"
#include "common/small_string.h"
#include "common/types.h"
#include "fmt/format.h"
@@ -18,42 +19,6 @@ class Error;
enum class ImageFormat : u8;
enum class GPUTextureFormat : u8
{
Unknown,
RGBA8,
BGRA8,
RGB565,
RGB5A1,
A1BGR5,
R8,
D16,
D24S8,
D32F,
D32FS8,
R16,
R16I,
R16U,
R16F,
R32I,
R32U,
R32F,
RG8,
RG16,
RG16F,
RG32F,
RGBA16,
RGBA16F,
RGBA32F,
RGB10A2,
SRGBA8,
BC1, ///< BC1, aka DXT1 compressed texture
BC2, ///< BC2, aka DXT2/3 compressed texture
BC3, ///< BC3, aka DXT4/5 compressed texture
BC7, ///< BC7, aka BPTC compressed texture
MaxCount,
};
class GPUTexture
{
public:

113
src/util/gpu_types.h Normal file
View File

@@ -0,0 +1,113 @@
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
#pragma once
#include "common/types.h"
enum class RenderAPI : u8
{
None,
D3D11,
D3D12,
Vulkan,
OpenGL,
OpenGLES,
Metal
};
enum class GPUVSyncMode : u8
{
Disabled,
FIFO,
Mailbox,
Count
};
enum class GPUTextureFormat : u8
{
Unknown,
RGBA8,
BGRA8,
RGB565,
RGB5A1,
A1BGR5,
R8,
D16,
D24S8,
D32F,
D32FS8,
R16,
R16I,
R16U,
R16F,
R32I,
R32U,
R32F,
RG8,
RG16,
RG16F,
RG32F,
RGBA16,
RGBA16F,
RGBA32F,
RGB10A2,
SRGBA8,
BC1, ///< BC1, aka DXT1 compressed texture
BC2, ///< BC2, aka DXT2/3 compressed texture
BC3, ///< BC3, aka DXT4/5 compressed texture
BC7, ///< BC7, aka BPTC compressed texture
MaxCount,
};
enum class GPUShaderStage : u8
{
Vertex,
Fragment,
Geometry,
Compute,
MaxCount
};
enum class GPUShaderLanguage : u8
{
None,
HLSL,
GLSL,
GLSLES,
GLSLVK,
MSL,
SPV,
Count
};
enum class GPUDriverType : u16
{
MobileFlag = 0x100,
SoftwareFlag = 0x200,
Unknown = 0,
AMDProprietary = 1,
AMDMesa = 2,
IntelProprietary = 3,
IntelMesa = 4,
NVIDIAProprietary = 5,
NVIDIAMesa = 6,
AppleProprietary = 7,
AppleMesa = 8,
DozenMesa = 9,
ImaginationProprietary = MobileFlag | 1,
ImaginationMesa = MobileFlag | 2,
ARMProprietary = MobileFlag | 3,
ARMMesa = MobileFlag | 4,
QualcommProprietary = MobileFlag | 5,
QualcommMesa = MobileFlag | 6,
BroadcomProprietary = MobileFlag | 7,
BroadcomMesa = MobileFlag | 8,
LLVMPipe = SoftwareFlag | 1,
SwiftShader = SoftwareFlag | 2,
WARP = SoftwareFlag | 3,
};

View File

@@ -3,14 +3,14 @@
#pragma once
#include "gpu_texture.h"
#include <ctime>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
enum class GPUTextureFormat : u8;
class Error;
class GPUTexture;

View File

@@ -489,7 +489,8 @@ bool OpenGLDevice::CheckFeatures(CreateFlags create_flags)
// Mobile drivers prefer textures to not be updated mid-frame.
m_features.prefer_unused_textures =
is_gles || ((m_driver_type & GPUDriverType::MobileFlag) == GPUDriverType::MobileFlag);
is_gles || ((static_cast<u16>(m_driver_type) & static_cast<u16>(GPUDriverType::MobileFlag)) ==
static_cast<u16>(GPUDriverType::MobileFlag));
if (m_driver_type == GPUDriverType::IntelProprietary)
{

View File

@@ -4,7 +4,6 @@
#pragma once
#include "gpu_device.h"
#include "gpu_texture.h"
#include "postprocessing.h"
#include "common/gsvector.h"

View File

@@ -8,6 +8,7 @@
<ClInclude Include="dyn_shaderc.h" />
<ClInclude Include="dyn_spirv_cross.h" />
<ClInclude Include="elf_file.h" />
<ClInclude Include="gpu_types.h" />
<ClInclude Include="image.h" />
<ClInclude Include="imgui_animated.h" />
<ClInclude Include="audio_stream.h" />

View File

@@ -81,6 +81,7 @@
<ClInclude Include="translation.h" />
<ClInclude Include="core_audio_stream.h" />
<ClInclude Include="vulkan_headers.h" />
<ClInclude Include="gpu_types.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="state_wrapper.cpp" />

View File

@@ -761,7 +761,8 @@ bool VulkanLoader::IsSuitableDefaultRenderer(WindowInfoType window_type)
INFO_LOG("Using Vulkan GPU '{}' for automatic renderer check.", ainfo.name);
// Any software rendering (LLVMpipe, SwiftShader).
if ((ainfo.driver_type & GPUDriverType::SoftwareFlag) == GPUDriverType::SoftwareFlag)
if ((static_cast<u16>(ainfo.driver_type) & static_cast<u16>(GPUDriverType::SoftwareFlag)) ==
static_cast<u32>(GPUDriverType::SoftwareFlag))
{
INFO_LOG("Not using Vulkan for software renderer.");
return false;

View File

@@ -2,7 +2,7 @@
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
#include "window_info.h"
#include "gpu_texture.h"
#include "gpu_types.h"
#include "common/assert.h"
#include "common/error.h"