Skip to content

Commit 095fef5

Browse files
committed
GPUDevice: Extract enums to own file
Further reduction of indirect includes.
1 parent 9370642 commit 095fef5

File tree

12 files changed

+127
-116
lines changed

12 files changed

+127
-116
lines changed

src/core/spu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "common/bitutils.h"
2121
#include "common/error.h"
2222
#include "common/fifo_queue.h"
23+
#include "common/gsvector.h"
2324
#include "common/log.h"
2425
#include "common/path.h"
2526

src/util/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ add_library(util
3232
gpu_shader_cache.h
3333
gpu_texture.cpp
3434
gpu_texture.h
35+
gpu_types.h
3536
http_downloader.cpp
3637
http_downloader.h
3738
image.cpp

src/util/gpu_device.h

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,6 @@ class Image;
3333
#define ENABLE_GPU_OBJECT_NAMES
3434
#endif
3535

36-
enum class RenderAPI : u8
37-
{
38-
None,
39-
D3D11,
40-
D3D12,
41-
Vulkan,
42-
OpenGL,
43-
OpenGLES,
44-
Metal
45-
};
46-
47-
enum class GPUVSyncMode : u8
48-
{
49-
Disabled,
50-
FIFO,
51-
Mailbox,
52-
Count
53-
};
54-
5536
class GPUSampler
5637
{
5738
public:
@@ -117,59 +98,6 @@ class GPUSampler
11798
static Config GetLinearConfig();
11899
};
119100

120-
enum class GPUShaderStage : u8
121-
{
122-
Vertex,
123-
Fragment,
124-
Geometry,
125-
Compute,
126-
127-
MaxCount
128-
};
129-
130-
enum class GPUShaderLanguage : u8
131-
{
132-
None,
133-
HLSL,
134-
GLSL,
135-
GLSLES,
136-
GLSLVK,
137-
MSL,
138-
SPV,
139-
Count
140-
};
141-
142-
enum class GPUDriverType : u16
143-
{
144-
MobileFlag = 0x100,
145-
SoftwareFlag = 0x200,
146-
147-
Unknown = 0,
148-
AMDProprietary = 1,
149-
AMDMesa = 2,
150-
IntelProprietary = 3,
151-
IntelMesa = 4,
152-
NVIDIAProprietary = 5,
153-
NVIDIAMesa = 6,
154-
AppleProprietary = 7,
155-
AppleMesa = 8,
156-
DozenMesa = 9,
157-
158-
ImaginationProprietary = MobileFlag | 1,
159-
ImaginationMesa = MobileFlag | 2,
160-
ARMProprietary = MobileFlag | 3,
161-
ARMMesa = MobileFlag | 4,
162-
QualcommProprietary = MobileFlag | 5,
163-
QualcommMesa = MobileFlag | 6,
164-
BroadcomProprietary = MobileFlag | 7,
165-
BroadcomMesa = MobileFlag | 8,
166-
167-
LLVMPipe = SoftwareFlag | 1,
168-
SwiftShader = SoftwareFlag | 2,
169-
WARP = SoftwareFlag | 3,
170-
};
171-
IMPLEMENT_ENUM_CLASS_BITWISE_OPERATORS(GPUDriverType);
172-
173101
class GPUShader
174102
{
175103
public:

src/util/gpu_texture.h

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
1+
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
22
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
33

44
#pragma once
55

6+
#include "gpu_types.h"
7+
68
#include "common/gsvector.h"
79
#include "common/small_string.h"
8-
#include "common/types.h"
910

1011
#include "fmt/format.h"
1112

@@ -18,42 +19,6 @@ class Error;
1819

1920
enum class ImageFormat : u8;
2021

21-
enum class GPUTextureFormat : u8
22-
{
23-
Unknown,
24-
RGBA8,
25-
BGRA8,
26-
RGB565,
27-
RGB5A1,
28-
A1BGR5,
29-
R8,
30-
D16,
31-
D24S8,
32-
D32F,
33-
D32FS8,
34-
R16,
35-
R16I,
36-
R16U,
37-
R16F,
38-
R32I,
39-
R32U,
40-
R32F,
41-
RG8,
42-
RG16,
43-
RG16F,
44-
RG32F,
45-
RGBA16,
46-
RGBA16F,
47-
RGBA32F,
48-
RGB10A2,
49-
SRGBA8,
50-
BC1, ///< BC1, aka DXT1 compressed texture
51-
BC2, ///< BC2, aka DXT2/3 compressed texture
52-
BC3, ///< BC3, aka DXT4/5 compressed texture
53-
BC7, ///< BC7, aka BPTC compressed texture
54-
MaxCount,
55-
};
56-
5722
class GPUTexture
5823
{
5924
public:

src/util/gpu_types.h

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
2+
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
3+
4+
#pragma once
5+
6+
#include "common/types.h"
7+
8+
enum class RenderAPI : u8
9+
{
10+
None,
11+
D3D11,
12+
D3D12,
13+
Vulkan,
14+
OpenGL,
15+
OpenGLES,
16+
Metal
17+
};
18+
19+
enum class GPUVSyncMode : u8
20+
{
21+
Disabled,
22+
FIFO,
23+
Mailbox,
24+
Count
25+
};
26+
27+
enum class GPUTextureFormat : u8
28+
{
29+
Unknown,
30+
RGBA8,
31+
BGRA8,
32+
RGB565,
33+
RGB5A1,
34+
A1BGR5,
35+
R8,
36+
D16,
37+
D24S8,
38+
D32F,
39+
D32FS8,
40+
R16,
41+
R16I,
42+
R16U,
43+
R16F,
44+
R32I,
45+
R32U,
46+
R32F,
47+
RG8,
48+
RG16,
49+
RG16F,
50+
RG32F,
51+
RGBA16,
52+
RGBA16F,
53+
RGBA32F,
54+
RGB10A2,
55+
SRGBA8,
56+
BC1, ///< BC1, aka DXT1 compressed texture
57+
BC2, ///< BC2, aka DXT2/3 compressed texture
58+
BC3, ///< BC3, aka DXT4/5 compressed texture
59+
BC7, ///< BC7, aka BPTC compressed texture
60+
MaxCount,
61+
};
62+
63+
enum class GPUShaderStage : u8
64+
{
65+
Vertex,
66+
Fragment,
67+
Geometry,
68+
Compute,
69+
70+
MaxCount
71+
};
72+
73+
enum class GPUShaderLanguage : u8
74+
{
75+
None,
76+
HLSL,
77+
GLSL,
78+
GLSLES,
79+
GLSLVK,
80+
MSL,
81+
SPV,
82+
Count
83+
};
84+
85+
enum class GPUDriverType : u16
86+
{
87+
MobileFlag = 0x100,
88+
SoftwareFlag = 0x200,
89+
90+
Unknown = 0,
91+
AMDProprietary = 1,
92+
AMDMesa = 2,
93+
IntelProprietary = 3,
94+
IntelMesa = 4,
95+
NVIDIAProprietary = 5,
96+
NVIDIAMesa = 6,
97+
AppleProprietary = 7,
98+
AppleMesa = 8,
99+
DozenMesa = 9,
100+
101+
ImaginationProprietary = MobileFlag | 1,
102+
ImaginationMesa = MobileFlag | 2,
103+
ARMProprietary = MobileFlag | 3,
104+
ARMMesa = MobileFlag | 4,
105+
QualcommProprietary = MobileFlag | 5,
106+
QualcommMesa = MobileFlag | 6,
107+
BroadcomProprietary = MobileFlag | 7,
108+
BroadcomMesa = MobileFlag | 8,
109+
110+
LLVMPipe = SoftwareFlag | 1,
111+
SwiftShader = SoftwareFlag | 2,
112+
WARP = SoftwareFlag | 3,
113+
};

src/util/media_capture.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
#pragma once
55

6-
#include "gpu_texture.h"
7-
86
#include <ctime>
97
#include <memory>
108
#include <string>
119
#include <string_view>
1210
#include <vector>
1311

12+
enum class GPUTextureFormat : u8;
13+
1414
class Error;
1515
class GPUTexture;
1616

src/util/opengl_device.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ bool OpenGLDevice::CheckFeatures(CreateFlags create_flags)
489489

490490
// Mobile drivers prefer textures to not be updated mid-frame.
491491
m_features.prefer_unused_textures =
492-
is_gles || ((m_driver_type & GPUDriverType::MobileFlag) == GPUDriverType::MobileFlag);
492+
is_gles || ((static_cast<u16>(m_driver_type) & static_cast<u16>(GPUDriverType::MobileFlag)) ==
493+
static_cast<u16>(GPUDriverType::MobileFlag));
493494

494495
if (m_driver_type == GPUDriverType::IntelProprietary)
495496
{

src/util/postprocessing_shader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#pragma once
55

66
#include "gpu_device.h"
7-
#include "gpu_texture.h"
87
#include "postprocessing.h"
98

109
#include "common/gsvector.h"

src/util/util.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<ClInclude Include="dyn_shaderc.h" />
99
<ClInclude Include="dyn_spirv_cross.h" />
1010
<ClInclude Include="elf_file.h" />
11+
<ClInclude Include="gpu_types.h" />
1112
<ClInclude Include="image.h" />
1213
<ClInclude Include="imgui_animated.h" />
1314
<ClInclude Include="audio_stream.h" />

src/util/util.vcxproj.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<ClInclude Include="translation.h" />
8282
<ClInclude Include="core_audio_stream.h" />
8383
<ClInclude Include="vulkan_headers.h" />
84+
<ClInclude Include="gpu_types.h" />
8485
</ItemGroup>
8586
<ItemGroup>
8687
<ClCompile Include="state_wrapper.cpp" />

0 commit comments

Comments
 (0)