mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
gpu/internal/driver: rename gpu/backend
There are no longer any importers of package backend outside of gioui.org/gpu. Move it internally, and rename it to the slightly more specific "driver" while we're at it. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"gioui.org/gpu/backend"
|
||||
"gioui.org/gpu/internal/driver"
|
||||
)
|
||||
|
||||
// GLSLCC is a shader cross-compilation tool.
|
||||
@@ -25,10 +25,10 @@ func NewGLSLCC() *GLSLCC { return &GLSLCC{Bin: "glslcc"} }
|
||||
|
||||
// Metadata contains reflection data about the shader.
|
||||
type Metadata struct {
|
||||
Uniforms backend.UniformsReflection
|
||||
Inputs []backend.InputLocation
|
||||
Textures []backend.TextureBinding
|
||||
StorageBuffers []backend.StorageBufferBinding
|
||||
Uniforms driver.UniformsReflection
|
||||
Inputs []driver.InputLocation
|
||||
Textures []driver.TextureBinding
|
||||
StorageBuffers []driver.StorageBufferBinding
|
||||
}
|
||||
|
||||
// Convert converts input data to the target shader.
|
||||
@@ -163,7 +163,7 @@ func (glslcc *GLSLCC) parseReflection(jsonData []byte) (Metadata, error) {
|
||||
if err != nil {
|
||||
return info, fmt.Errorf("parseReflection: %v", err)
|
||||
}
|
||||
info.Inputs = append(info.Inputs, backend.InputLocation{
|
||||
info.Inputs = append(info.Inputs, driver.InputLocation{
|
||||
Name: input.Name,
|
||||
Location: input.Location,
|
||||
Semantic: input.Semantic,
|
||||
@@ -183,7 +183,7 @@ func (glslcc *GLSLCC) parseReflection(jsonData []byte) (Metadata, error) {
|
||||
|
||||
blockOffset := 0
|
||||
for _, block := range shaderBlocks {
|
||||
info.Uniforms.Blocks = append(info.Uniforms.Blocks, backend.UniformBlock{
|
||||
info.Uniforms.Blocks = append(info.Uniforms.Blocks, driver.UniformBlock{
|
||||
Name: block.Name,
|
||||
Binding: block.Binding,
|
||||
})
|
||||
@@ -192,7 +192,7 @@ func (glslcc *GLSLCC) parseReflection(jsonData []byte) (Metadata, error) {
|
||||
if err != nil {
|
||||
return info, fmt.Errorf("parseReflection: %v", err)
|
||||
}
|
||||
info.Uniforms.Locations = append(info.Uniforms.Locations, backend.UniformLocation{
|
||||
info.Uniforms.Locations = append(info.Uniforms.Locations, driver.UniformLocation{
|
||||
// Synthetic name generated by glslcc.
|
||||
Name: fmt.Sprintf("_%d.%s", block.ID, member.Name),
|
||||
Type: dataType,
|
||||
@@ -209,14 +209,14 @@ func (glslcc *GLSLCC) parseReflection(jsonData []byte) (Metadata, error) {
|
||||
textures = reflect.FS.Textures
|
||||
}
|
||||
for _, texture := range textures {
|
||||
info.Textures = append(info.Textures, backend.TextureBinding{
|
||||
info.Textures = append(info.Textures, driver.TextureBinding{
|
||||
Name: texture.Name,
|
||||
Binding: texture.Binding,
|
||||
})
|
||||
}
|
||||
|
||||
for _, sb := range reflect.CS.StorageBuffers {
|
||||
info.StorageBuffers = append(info.StorageBuffers, backend.StorageBufferBinding{
|
||||
info.StorageBuffers = append(info.StorageBuffers, driver.StorageBufferBinding{
|
||||
Binding: sb.Binding,
|
||||
BlockSize: sb.BlockSize,
|
||||
})
|
||||
@@ -225,24 +225,24 @@ func (glslcc *GLSLCC) parseReflection(jsonData []byte) (Metadata, error) {
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func parseDataType(t string) (backend.DataType, int, error) {
|
||||
func parseDataType(t string) (driver.DataType, int, error) {
|
||||
switch t {
|
||||
case "float":
|
||||
return backend.DataTypeFloat, 1, nil
|
||||
return driver.DataTypeFloat, 1, nil
|
||||
case "float2":
|
||||
return backend.DataTypeFloat, 2, nil
|
||||
return driver.DataTypeFloat, 2, nil
|
||||
case "float3":
|
||||
return backend.DataTypeFloat, 3, nil
|
||||
return driver.DataTypeFloat, 3, nil
|
||||
case "float4":
|
||||
return backend.DataTypeFloat, 4, nil
|
||||
return driver.DataTypeFloat, 4, nil
|
||||
case "int":
|
||||
return backend.DataTypeInt, 1, nil
|
||||
return driver.DataTypeInt, 1, nil
|
||||
case "int2":
|
||||
return backend.DataTypeInt, 2, nil
|
||||
return driver.DataTypeInt, 2, nil
|
||||
case "int3":
|
||||
return backend.DataTypeInt, 3, nil
|
||||
return driver.DataTypeInt, 3, nil
|
||||
case "int4":
|
||||
return backend.DataTypeInt, 4, nil
|
||||
return driver.DataTypeInt, 4, nil
|
||||
default:
|
||||
return 0, 0, fmt.Errorf("unsupported input data type: %s", t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user