mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
gpu/internal/shaders: generate shader variants
We're about to add Direct3D support, where shaders are written in HLSL. Rather than write shaders twice (or more), convert them to a GLSL variant understood by the glslcc cross-compiler and generate the OpenGL ES 2.0 and HLSL variants. The HLSL is used by a future change. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+27
-1
@@ -23,7 +23,7 @@ type Backend interface {
|
||||
NilTexture() Texture
|
||||
NewFramebuffer() Framebuffer
|
||||
NewBuffer(typ BufferType, data []byte) Buffer
|
||||
NewProgram(vertexShader, fragmentShader string, attribMap []string) (Program, error)
|
||||
NewProgram(vertexShader, fragmentShader ShaderSources, attribMap []string) (Program, error)
|
||||
SetupVertexArray(slot int, size int, dataType DataType, stride, offset int)
|
||||
|
||||
DepthFunc(f DepthFunc)
|
||||
@@ -39,6 +39,32 @@ type Backend interface {
|
||||
BlendFunc(sfactor, dfactor BlendFactor)
|
||||
}
|
||||
|
||||
type ShaderSources struct {
|
||||
GLES2 string
|
||||
HLSL []byte
|
||||
Uniforms []UniformLocation
|
||||
Inputs []InputLocation
|
||||
}
|
||||
|
||||
type UniformLocation struct {
|
||||
Name string
|
||||
Type DataType
|
||||
Size int
|
||||
Offset int
|
||||
}
|
||||
|
||||
type InputLocation struct {
|
||||
// For GLSL.
|
||||
Name string
|
||||
Location int
|
||||
// For HLSL.
|
||||
Semantic string
|
||||
SemanticIndex int
|
||||
|
||||
Type DataType
|
||||
Size int
|
||||
}
|
||||
|
||||
type BlendFactor uint8
|
||||
|
||||
type DrawMode uint8
|
||||
|
||||
Reference in New Issue
Block a user