HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
VE_ShaderCompile.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: VE_ShaderCompile.h ( VE Library, C++)
7
*
8
* COMMENTS:
9
*/
10
11
#ifndef __VE_SHADER_COMPILE_H__
12
#define __VE_SHADER_COMPILE_H__
13
14
#include "
VE_API.h
"
15
16
#include <
UT/UT_Array.h
>
17
#include <
UT/UT_Map.h
>
18
#include <
UT/UT_StringHolder.h
>
19
#include <
UT/UT_UniquePtr.h
>
20
21
class
UT_WorkBuffer
;
22
struct
VE_SpvProgramCompileImpl;
23
struct
VE_SpvStageCompileImpl;
24
class
VE_ShaderStageCompiler
;
25
26
// Values of this enum must be in sync with RE_ShaderType!
27
enum
VE_ShaderType
28
{
29
VE_SHADER_VERTEX
= 0x1,
30
VE_SHADER_GEOMETRY
= 0x2,
31
VE_SHADER_FRAGMENT
= 0x4,
32
VE_SHADER_TESSCONTROL
= 0x8,
33
VE_SHADER_TESSEVAL
= 0x10,
34
35
VE_SHADER_COMPUTE
= 0x20
36
37
// RE_SHADER_ALL isn't an actual stage, so we don't need a corresponding
38
// value here.
39
};
40
41
// ~~ Overview
42
// takes a collection of GLSL shader files
43
// compiles them into SPIR-V modules
44
// optionally does linkage checks as well
45
46
// ~~ Shader Compiler Ownership
47
// Implemented using glslang library
48
// glslang interface has the quirks that:
49
// - shaders cannot be detatched from a program
50
// - shaders cannot be used in multiple programs
51
// - shaders must be destroyed after program
52
// so, the program compiler takes ownership of any shaders
53
// added to it
54
55
class
VE_API
VE_ShaderProgramCompiler
56
{
57
public
:
58
VE_ShaderProgramCompiler
();
59
~
VE_ShaderProgramCompiler
();
60
61
VE_ShaderProgramCompiler
(
const
VE_ShaderProgramCompiler
&) =
delete
;
62
63
// Must be called in order:
64
// add shaders, compile, link, get modules
65
bool
addShader(
UT_UniquePtr<VE_ShaderStageCompiler>
&& shr);
66
bool
compileShaders(
UT_WorkBuffer
& messages_out);
67
bool
linkShaders(
UT_WorkBuffer
& messages_out);
68
// T can be uint8_t or uint32_t.
69
template
<
typename
T>
70
bool
getSpvModules(
UT_Map
<
VE_ShaderType
,
UT_Array<T>
>& modules_out,
71
UT_WorkBuffer
& messages_out);
72
73
bool
isValid()
const
;
74
75
private
:
76
UT_UniquePtr<VE_SpvProgramCompileImpl>
myImpl;
77
friend
VE_SpvProgramCompileImpl;
78
};
79
80
class
VE_API
VE_ShaderStageCompiler
81
{
82
public
:
83
VE_ShaderStageCompiler
(
const
char
*
source
,
const
char
*
name
,
84
VE_ShaderType
stage,
int
version
= 0);
85
~
VE_ShaderStageCompiler
();
86
87
bool
compile(
UT_WorkBuffer
& messages_out);
88
89
bool
isCompiled();
90
bool
isValid();
91
92
VE_ShaderType
getStageType();
93
void
getString(
UT_WorkBuffer
&
string
);
94
const
char
*
getname
()
95
{
96
return
myName;
97
}
98
99
private
:
100
UT_StringHolder
myName;
101
UT_StringHolder
mySource;
102
VE_ShaderType
myStage;
103
UT_UniquePtr<VE_SpvStageCompileImpl>
myImpl;
104
int
myVersion;
105
106
friend
VE_SpvStageCompileImpl;
107
friend
VE_ShaderProgramCompiler
;
108
};
109
110
#endif
111
UT_WorkBuffer
Definition:
UT_WorkBuffer.h:74
VE_SHADER_COMPUTE
Definition:
VE_ShaderCompile.h:35
UT_Map
Unsorted map container.
Definition:
UT_Map.h:109
VE_SHADER_TESSCONTROL
Definition:
VE_ShaderCompile.h:32
VE_API.h
UT_Array.h
UT_Array
Definition:
BV_KDOPTree.h:18
UT_UniquePtr
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition:
UT_UniquePtr.h:39
UT_StringHolder
Definition:
UT_StringHolder.h:1009
UT_Map.h
VE_ShaderProgramCompiler
Definition:
VE_ShaderCompile.h:55
VE_ShaderType
VE_ShaderType
Definition:
VE_ShaderCompile.h:27
VE_API
#define VE_API
Definition:
VE_API.h:20
source
GLsizei GLsizei GLchar * source
Definition:
glcorearb.h:803
VE_SHADER_TESSEVAL
Definition:
VE_ShaderCompile.h:33
VE_ShaderStageCompiler::getname
const char * getname()
Definition:
VE_ShaderCompile.h:94
name
GLuint const GLchar * name
Definition:
glcorearb.h:786
GT_Names::version
GT_API const UT_StringHolder version
VE_SHADER_FRAGMENT
Definition:
VE_ShaderCompile.h:31
UT_UniquePtr.h
VE_ShaderStageCompiler
Definition:
VE_ShaderCompile.h:80
UT_StringHolder.h
VE_SHADER_VERTEX
Definition:
VE_ShaderCompile.h:29
VE_SHADER_GEOMETRY
Definition:
VE_ShaderCompile.h:30
VE
VE_ShaderCompile.h
Generated on Thu Sep 4 2025 02:39:58 for HDK by
1.8.6