Skip to content

Commit 10f5662

Browse files
committed
xrRender_GL: prepare for SPIR-V
1 parent f37143d commit 10f5662

File tree

8 files changed

+157
-12
lines changed

8 files changed

+157
-12
lines changed

src/Layers/xrRender/HW.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class CHW
7171
GLuint pCFB;
7272

7373
CHWCaps Caps;
74+
TBuiltInResource resources;
7475

7576
HWND m_hWnd;
7677
HDC m_hDC;
@@ -128,6 +129,9 @@ class CHW
128129
#if !defined(_MAYA_EXPORT) && !defined(USE_OGL)
129130
stats_manager stats_manager;
130131
#endif
132+
#ifdef USE_OGL
133+
void InitResources(TBuiltInResource& Resources);
134+
#endif
131135
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
132136
void UpdateViews();
133137
#endif

src/Layers/xrRender/SH_Atomic.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,39 @@ struct ECORE_API SGS : public xr_resource_named
6868
typedef resptr_core<SGS, resptr_base<SGS>> ref_gs;
6969
#endif // USE_DX10
7070

71-
#ifdef USE_DX11
71+
#if defined(USE_DX11) || defined(USE_OGL)
7272

7373
struct ECORE_API SHS : public xr_resource_named
7474
{
75+
#ifdef USE_OGL
76+
GLuint sh;
77+
#else
7578
ID3D11HullShader* sh;
79+
#endif
7680
R_constant_table constants;
7781
~SHS();
7882
};
7983
typedef resptr_core<SHS, resptr_base<SHS>> ref_hs;
8084

8185
struct ECORE_API SDS : public xr_resource_named
8286
{
87+
#ifdef USE_OGL
88+
GLuint sh;
89+
#else
8390
ID3D11DomainShader* sh;
91+
#endif
8492
R_constant_table constants;
8593
~SDS();
8694
};
8795
typedef resptr_core<SDS, resptr_base<SDS>> ref_ds;
8896

8997
struct ECORE_API SCS : public xr_resource_named
9098
{
99+
#ifdef USE_OGL
100+
GLuint sh;
101+
#else
91102
ID3D11ComputeShader* sh;
103+
#endif
92104
R_constant_table constants;
93105
~SCS();
94106
};

src/Layers/xrRender/Shader.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#include "r_constants.h"
1010
#include "xrCore/xr_resource.h"
1111

12-
#include "sh_atomic.h"
13-
#include "sh_texture.h"
14-
#include "sh_matrix.h"
15-
#include "sh_constant.h"
16-
#include "sh_rt.h"
12+
#include "SH_Atomic.h"
13+
#include "SH_Texture.h"
14+
#include "SH_Matrix.h"
15+
#include "SH_Constant.h"
16+
#include "SH_RT.h"
1717

1818
using sh_list = xr_vector<shared_str>;
1919
class CBlender_Compile;

src/Layers/xrRenderGL/glHW.cpp

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ void CHW::CreateDevice(HWND hWnd, bool move_window)
140140
updateWindowProps(m_hWnd);
141141
fill_vid_mode_list(this);
142142
#endif
143+
144+
InitResources(resources);
143145
}
144146

145147
void CHW::DestroyDevice()
@@ -319,6 +321,104 @@ void fill_vid_mode_list(CHW* /*_hw*/)
319321
}
320322
}
321323

324+
325+
void CHW::InitResources(TBuiltInResource& Resources)
326+
{
327+
Resources.maxLights = 32;
328+
Resources.maxClipPlanes = 6;
329+
Resources.maxTextureUnits = 32;
330+
Resources.maxTextureCoords = 32;
331+
Resources.maxVertexAttribs = 64;
332+
Resources.maxVertexUniformComponents = 4096;
333+
Resources.maxVaryingFloats = 64;
334+
Resources.maxVertexTextureImageUnits = 32;
335+
Resources.maxCombinedTextureImageUnits = 80;
336+
Resources.maxTextureImageUnits = 32;
337+
Resources.maxFragmentUniformComponents = 4096;
338+
Resources.maxDrawBuffers = 32;
339+
Resources.maxVertexUniformVectors = 128;
340+
Resources.maxVaryingVectors = 8;
341+
Resources.maxFragmentUniformVectors = 16;
342+
Resources.maxVertexOutputVectors = 16;
343+
Resources.maxFragmentInputVectors = 15;
344+
Resources.minProgramTexelOffset = -8;
345+
Resources.maxProgramTexelOffset = 7;
346+
Resources.maxClipDistances = 8;
347+
Resources.maxComputeWorkGroupCountX = 65535;
348+
Resources.maxComputeWorkGroupCountY = 65535;
349+
Resources.maxComputeWorkGroupCountZ = 65535;
350+
Resources.maxComputeWorkGroupSizeX = 1024;
351+
Resources.maxComputeWorkGroupSizeY = 1024;
352+
Resources.maxComputeWorkGroupSizeZ = 64;
353+
Resources.maxComputeUniformComponents = 1024;
354+
Resources.maxComputeTextureImageUnits = 16;
355+
Resources.maxComputeImageUniforms = 8;
356+
Resources.maxComputeAtomicCounters = 8;
357+
Resources.maxComputeAtomicCounterBuffers = 1;
358+
Resources.maxVaryingComponents = 60;
359+
Resources.maxVertexOutputComponents = 64;
360+
Resources.maxGeometryInputComponents = 64;
361+
Resources.maxGeometryOutputComponents = 128;
362+
Resources.maxFragmentInputComponents = 128;
363+
Resources.maxImageUnits = 8;
364+
Resources.maxCombinedImageUnitsAndFragmentOutputs = 8;
365+
Resources.maxCombinedShaderOutputResources = 8;
366+
Resources.maxImageSamples = 0;
367+
Resources.maxVertexImageUniforms = 0;
368+
Resources.maxTessControlImageUniforms = 0;
369+
Resources.maxTessEvaluationImageUniforms = 0;
370+
Resources.maxGeometryImageUniforms = 0;
371+
Resources.maxFragmentImageUniforms = 8;
372+
Resources.maxCombinedImageUniforms = 8;
373+
Resources.maxGeometryTextureImageUnits = 16;
374+
Resources.maxGeometryOutputVertices = 256;
375+
Resources.maxGeometryTotalOutputComponents = 1024;
376+
Resources.maxGeometryUniformComponents = 1024;
377+
Resources.maxGeometryVaryingComponents = 64;
378+
Resources.maxTessControlInputComponents = 128;
379+
Resources.maxTessControlOutputComponents = 128;
380+
Resources.maxTessControlTextureImageUnits = 16;
381+
Resources.maxTessControlUniformComponents = 1024;
382+
Resources.maxTessControlTotalOutputComponents = 4096;
383+
Resources.maxTessEvaluationInputComponents = 128;
384+
Resources.maxTessEvaluationOutputComponents = 128;
385+
Resources.maxTessEvaluationTextureImageUnits = 16;
386+
Resources.maxTessEvaluationUniformComponents = 1024;
387+
Resources.maxTessPatchComponents = 120;
388+
Resources.maxPatchVertices = 32;
389+
Resources.maxTessGenLevel = 64;
390+
Resources.maxViewports = 16;
391+
Resources.maxVertexAtomicCounters = 0;
392+
Resources.maxTessControlAtomicCounters = 0;
393+
Resources.maxTessEvaluationAtomicCounters = 0;
394+
Resources.maxGeometryAtomicCounters = 0;
395+
Resources.maxFragmentAtomicCounters = 8;
396+
Resources.maxCombinedAtomicCounters = 8;
397+
Resources.maxAtomicCounterBindings = 1;
398+
Resources.maxVertexAtomicCounterBuffers = 0;
399+
Resources.maxTessControlAtomicCounterBuffers = 0;
400+
Resources.maxTessEvaluationAtomicCounterBuffers = 0;
401+
Resources.maxGeometryAtomicCounterBuffers = 0;
402+
Resources.maxFragmentAtomicCounterBuffers = 1;
403+
Resources.maxCombinedAtomicCounterBuffers = 1;
404+
Resources.maxAtomicCounterBufferSize = 16384;
405+
Resources.maxTransformFeedbackBuffers = 4;
406+
Resources.maxTransformFeedbackInterleavedComponents = 64;
407+
Resources.maxCullDistances = 8;
408+
Resources.maxCombinedClipAndCullDistances = 8;
409+
Resources.maxSamples = 4;
410+
Resources.limits.nonInductiveForLoops = 1;
411+
Resources.limits.whileLoops = 1;
412+
Resources.limits.doWhileLoops = 1;
413+
Resources.limits.generalUniformIndexing = 1;
414+
Resources.limits.generalAttributeMatrixVectorIndexing = 1;
415+
Resources.limits.generalVaryingIndexing = 1;
416+
Resources.limits.generalSamplerIndexing = 1;
417+
Resources.limits.generalVariableIndexing = 1;
418+
Resources.limits.generalConstantMatrixVectorIndexing = 1;
419+
}
420+
421+
322422
void CHW::UpdateViews()
323423
{
324424
// Create the program pipeline used for rendering with shaders

src/Layers/xrRenderPC_GL/rgl.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include "stdafx.h"
2+
3+
#include <glslang/SPIRV/GlslangToSpv.h>
4+
25
#include "rgl.h"
36
#include "Layers/xrRender/FBasicVisual.h"
47
#include "xrEngine/xr_object.h"
@@ -119,6 +122,8 @@ extern ENGINE_API BOOL r2_advanced_pp; // advanced post process and effects
119122
// Just two static storage
120123
void CRender::create()
121124
{
125+
glslang::InitializeProcess();
126+
122127
Device.seqFrame.Add(this,REG_PRIORITY_HIGH + 0x12345678);
123128

124129
m_skinning = -1;
@@ -391,6 +396,7 @@ void CRender::destroy()
391396
PSLibrary.OnDestroy();
392397
Device.seqFrame.Remove(this);
393398
r_dsgraph_destroy();
399+
glslang::FinalizeProcess();
394400
}
395401

396402
void CRender::reset_begin()
@@ -703,6 +709,15 @@ void CRender::DumpStatistics(IGameFont& font, IPerformanceAlert* alert)
703709
HOM.DumpStatistics(font, alert);
704710
}
705711

712+
void CRender::addShaderOption(const char* name, const char* value)
713+
{
714+
m_ShaderOptions += "#define ";
715+
m_ShaderOptions += name;
716+
m_ShaderOptions += " ";
717+
m_ShaderOptions += value;
718+
m_ShaderOptions += "\n";
719+
}
720+
706721
static inline bool match_shader_id(LPCSTR const debug_shader_id, LPCSTR const full_shader_id,
707722
FS_FileSet const& file_set, string_path& result);
708723

src/Layers/xrRenderPC_GL/rgl.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,18 @@ class CRender : public D3DXRenderBase
378378
// Constructor/destructor/loader
379379
CRender();
380380
virtual ~CRender();
381+
382+
void addShaderOption(pcstr name, pcstr value);
383+
void clearAllShaderOptions() { m_ShaderOptions.clear(); }
384+
385+
private:
386+
xr_string m_ShaderOptions;
387+
381388
protected:
382389
void ScreenshotImpl(ScreenshotMode mode, LPCSTR name, CMemoryWriter* memory_writer) override;
390+
391+
private:
392+
FS_FileSet m_file_set;
383393
};
384394

385395
extern CRender RImplementation;

src/Layers/xrRenderPC_GL/stdafx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <gl/GLU.h>
1515
#include <gl/glext.h>
1616
#include <gl/wglext.h>
17+
#include <ShaderLang.h>
1718

1819
#include "Layers/xrRender/xrD3DDefs.h"
1920
#include "Layers/xrRender/Debug/dxPixEventWrapper.h"

src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
</PropertyGroup>
7878
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7979
<ClCompile>
80-
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
80+
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;$(xrExternals)glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
8181
<PreprocessorDefinitions>_USRDLL;XRRENDER_GL_EXPORTS;USE_OGL;NO_XR_VDECLARATOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
8282
</ClCompile>
8383
<Link>
@@ -87,7 +87,7 @@
8787
</ItemDefinitionGroup>
8888
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
8989
<ClCompile>
90-
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
90+
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;$(xrExternals)glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
9191
<PreprocessorDefinitions>_USRDLL;XRRENDER_GL_EXPORTS;USE_OGL;NO_XR_VDECLARATOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9292
</ClCompile>
9393
<Link>
@@ -97,7 +97,7 @@
9797
</ItemDefinitionGroup>
9898
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
9999
<ClCompile>
100-
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
100+
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;$(xrExternals)glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
101101
<PreprocessorDefinitions>_USRDLL;XRRENDER_GL_EXPORTS;USE_OGL;NO_XR_VDECLARATOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
102102
</ClCompile>
103103
<Link>
@@ -107,7 +107,7 @@
107107
</ItemDefinitionGroup>
108108
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
109109
<ClCompile>
110-
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
110+
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;$(xrExternals)glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
111111
<PreprocessorDefinitions>_USRDLL;XRRENDER_GL_EXPORTS;USE_OGL;NO_XR_VDECLARATOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
112112
<FloatingPointModel>Precise</FloatingPointModel>
113113
</ClCompile>
@@ -118,7 +118,7 @@
118118
</ItemDefinitionGroup>
119119
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Mixed|Win32'">
120120
<ClCompile>
121-
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
121+
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;$(xrExternals)glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
122122
<PreprocessorDefinitions>_USRDLL;XRRENDER_GL_EXPORTS;USE_OGL;NO_XR_VDECLARATOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
123123
</ClCompile>
124124
<Link>
@@ -128,7 +128,7 @@
128128
</ItemDefinitionGroup>
129129
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Mixed|x64'">
130130
<ClCompile>
131-
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
131+
<AdditionalIncludeDirectories>$(xrExternals)OpenAutomate\inc;$(xrExternals)gl\include;$(xrExternals)glew\include;$(xrExternals)gli;$(xrExternals)gli\external\glm;$(xrExternals)AGS_SDK;$(xrExternals)glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
132132
<PreprocessorDefinitions>_USRDLL;XRRENDER_GL_EXPORTS;USE_OGL;NO_XR_VDECLARATOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
133133
</ClCompile>
134134
<Link>
@@ -471,6 +471,9 @@
471471
<ProjectReference Include="$(xrExternals)oalib.vcxproj">
472472
<Project>{61d4856f-fa82-4f02-bb88-909ddfb1fe74}</Project>
473473
</ProjectReference>
474+
<ProjectReference Include="..\..\..\Externals\glslang.vcxproj">
475+
<Project>{8559bc92-bc07-32ef-beed-0c50fe6ca3c3}</Project>
476+
</ProjectReference>
474477
<ProjectReference Include="..\..\utils\xrMiscMath\xrMiscMath.vcxproj">
475478
<Project>{7885cf3c-ee04-4c67-9467-1fbf9a36b037}</Project>
476479
</ProjectReference>

0 commit comments

Comments
 (0)