@@ -9,7 +9,12 @@ template <>
99struct ShaderTypeTraits <SVS>
1010{
1111 typedef CResourceManager::map_VS MapType;
12- typedef ID3DVertexShader DXIface;
12+
13+ #ifdef USE_OGL
14+ using HWShaderType = GLuint;
15+ #else
16+ using HWShaderType = ID3DVertexShader*;
17+ #endif
1318
1419 static inline const char * GetShaderExt () { return " .vs" ; }
1520 static inline const char * GetCompilationTarget ()
@@ -37,10 +42,12 @@ struct ShaderTypeTraits<SVS>
3742 }
3843 }
3944
40- static inline DXIface* CreateHWShader (DWORD const * buffer, size_t size)
45+ static inline HWShaderType CreateHWShader (DWORD const * buffer, size_t size)
4146 {
42- DXIface* vs = 0 ;
43- #ifdef USE_DX11
47+ HWShaderType vs = 0 ;
48+ #ifdef USE_OGL
49+ vs = glCreateShader (GL_VERTEX_SHADER);
50+ #elif defined(USE_DX11)
4451 R_CHK (HW.pDevice ->CreateVertexShader (buffer, size, 0 , &vs));
4552#elif defined(USE_DX10)
4653 R_CHK (HW.pDevice ->CreateVertexShader (buffer, size, &vs));
@@ -57,7 +64,12 @@ template <>
5764struct ShaderTypeTraits <SPS>
5865{
5966 typedef CResourceManager::map_PS MapType;
60- typedef ID3DPixelShader DXIface;
67+
68+ #ifdef USE_OGL
69+ using HWShaderType = GLuint;
70+ #else
71+ using HWShaderType = ID3DPixelShader*;
72+ #endif
6173
6274 static inline const char * GetShaderExt () { return " .ps" ; }
6375 static inline const char * GetCompilationTarget ()
@@ -94,10 +106,12 @@ struct ShaderTypeTraits<SPS>
94106 }
95107 }
96108
97- static inline DXIface* CreateHWShader (DWORD const * buffer, size_t size)
109+ static inline HWShaderType CreateHWShader (DWORD const * buffer, size_t size)
98110 {
99- DXIface* ps = 0 ;
100- #ifdef USE_DX11
111+ HWShaderType ps = 0 ;
112+ #ifdef USE_OGL
113+ ps = glCreateShader (GL_FRAGMENT_SHADER);
114+ #elif defined(USE_DX11)
101115 R_CHK (HW.pDevice ->CreatePixelShader (buffer, size, 0 , &ps));
102116#elif defined(USE_DX10)
103117 R_CHK (HW.pDevice ->CreatePixelShader (buffer, size, &ps));
@@ -110,18 +124,24 @@ struct ShaderTypeTraits<SPS>
110124 static inline u32 GetShaderDest () { return RC_dest_pixel; }
111125};
112126
113- #if defined(USE_DX10) || defined(USE_DX11)
127+ #if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
114128template <>
115129struct ShaderTypeTraits <SGS>
116130{
117131 typedef CResourceManager::map_GS MapType;
118- typedef ID3DGeometryShader DXIface;
132+
133+ #ifdef USE_OGL
134+ using HWShaderType = GLuint;
135+ #else
136+ using HWShaderType = ID3DGeometryShader*;
137+ #endif
138+
119139
120140 static inline const char * GetShaderExt () { return " .gs" ; }
121141 static inline const char * GetCompilationTarget ()
122142 {
123143#ifdef USE_DX10
124- if (HW.pDevice1 == 0 )
144+ if (HW.pDevice1 == nullptr )
125145 return D3D10GetGeometryShaderProfile (HW.pDevice );
126146 else
127147 return " gs_4_1" ;
@@ -144,27 +164,34 @@ struct ShaderTypeTraits<SGS>
144164 entry = " main" ;
145165 }
146166
147- static inline DXIface* CreateHWShader (DWORD const * buffer, size_t size)
167+ static inline HWShaderType CreateHWShader (DWORD const * buffer, size_t size)
148168 {
149- DXIface* gs = 0 ;
150- #ifdef USE_DX11
169+ HWShaderType gs = 0 ;
170+ #ifdef USE_OGL
171+ gs = glCreateShader (GL_GEOMETRY_SHADER);
172+ #elif defined(USE_DX11)
151173 R_CHK (HW.pDevice ->CreateGeometryShader (buffer, size, 0 , &gs));
152174#else
153175 R_CHK (HW.pDevice ->CreateGeometryShader (buffer, size, &gs));
154- #endif
176+ #endif
155177 return gs;
156178 }
157179
158180 static inline u32 GetShaderDest () { return RC_dest_geometry; }
159181};
160182#endif
161183
162- #ifdef USE_DX11
184+ #if defined( USE_DX11) || defined(USE_OGL)
163185template <>
164186struct ShaderTypeTraits <SHS>
165187{
166188 typedef CResourceManager::map_HS MapType;
167- typedef ID3D11HullShader DXIface;
189+
190+ #ifdef USE_OGL
191+ using HWShaderType = GLuint;
192+ #else
193+ using HWShaderType = ID3D11HullShader*;
194+ #endif
168195
169196 static inline const char * GetShaderExt () { return " .hs" ; }
170197 static inline const char * GetCompilationTarget () { return " hs_5_0" ; }
@@ -175,10 +202,14 @@ struct ShaderTypeTraits<SHS>
175202 entry = " main" ;
176203 }
177204
178- static inline DXIface* CreateHWShader (DWORD const * buffer, size_t size)
205+ static inline HWShaderType CreateHWShader (DWORD const * buffer, size_t size)
179206 {
180- DXIface* hs = 0 ;
207+ HWShaderType hs = 0 ;
208+ #ifdef USE_OGL
209+ hs = glCreateShader (GL_TESS_CONTROL_SHADER);
210+ #else
181211 R_CHK (HW.pDevice ->CreateHullShader (buffer, size, NULL , &hs));
212+ #endif
182213 return hs;
183214 }
184215
@@ -189,7 +220,12 @@ template <>
189220struct ShaderTypeTraits <SDS>
190221{
191222 typedef CResourceManager::map_DS MapType;
192- typedef ID3D11DomainShader DXIface;
223+
224+ #ifdef USE_OGL
225+ using HWShaderType = GLuint;
226+ #else
227+ using HWShaderType = ID3D11DomainShader*;
228+ #endif
193229
194230 static inline const char * GetShaderExt () { return " .ds" ; }
195231 static inline const char * GetCompilationTarget () { return " ds_5_0" ; }
@@ -200,10 +236,14 @@ struct ShaderTypeTraits<SDS>
200236 entry = " main" ;
201237 }
202238
203- static inline DXIface* CreateHWShader (DWORD const * buffer, size_t size)
239+ static inline HWShaderType CreateHWShader (DWORD const * buffer, size_t size)
204240 {
205- DXIface* hs = 0 ;
241+ HWShaderType hs = 0 ;
242+ #ifdef USE_OGL
243+ hs = glCreateShader (GL_TESS_EVALUATION_SHADER);
244+ #else
206245 R_CHK (HW.pDevice ->CreateDomainShader (buffer, size, NULL , &hs));
246+ #endif
207247 return hs;
208248 }
209249
@@ -214,7 +254,12 @@ template <>
214254struct ShaderTypeTraits <SCS>
215255{
216256 typedef CResourceManager::map_CS MapType;
217- typedef ID3D11ComputeShader DXIface;
257+
258+ #ifdef USE_OGL
259+ using HWShaderType = GLuint;
260+ #else
261+ using HWShaderType = ID3D11ComputeShader*;
262+ #endif
218263
219264 static inline const char * GetShaderExt () { return " .cs" ; }
220265 static inline const char * GetCompilationTarget () { return " cs_5_0" ; }
@@ -225,10 +270,15 @@ struct ShaderTypeTraits<SCS>
225270 entry = " main" ;
226271 }
227272
228- static inline DXIface* CreateHWShader (DWORD const * buffer, size_t size)
273+ static inline HWShaderType CreateHWShader (DWORD const * buffer, size_t size)
229274 {
230- DXIface* cs = 0 ;
275+ HWShaderType cs = 0 ;
276+
277+ #ifdef USE_OGL
278+ cs = glCreateShader (GL_COMPUTE_SHADER);
279+ #else
231280 R_CHK (HW.pDevice ->CreateComputeShader (buffer, size, NULL , &cs));
281+ #endif
232282 return cs;
233283 }
234284
@@ -248,15 +298,15 @@ inline CResourceManager::map_VS& CResourceManager::GetShaderMap()
248298 return m_vs;
249299}
250300
251- #if defined(USE_DX10) || defined(USE_DX11)
301+ #if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
252302template <>
253303inline CResourceManager::map_GS& CResourceManager::GetShaderMap ()
254304{
255305 return m_gs;
256306}
257307#endif
258308
259- #if defined(USE_DX11)
309+ #if defined(USE_DX11) || defined(USE_OGL)
260310template <>
261311inline CResourceManager::map_DS& CResourceManager::GetShaderMap ()
262312{
0 commit comments