annotate src/semicongine/core/gpu_data.nim @ 206:7f921d7d0a2b

did: small refactoring of module structure
author Sam <sam@basx.dev>
date Tue, 09 May 2023 01:11:51 +0700
parents src/semicongine/gpu_data.nim@ab626e67a1ee
children ddfc54036e00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
113
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
1 import std/typetraits
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
2 import std/strformat
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
3 import std/tables
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
4
206
7f921d7d0a2b did: small refactoring of module structure
Sam <sam@basx.dev>
parents: 201
diff changeset
5 import ./vulkanapi
7f921d7d0a2b did: small refactoring of module structure
Sam <sam@basx.dev>
parents: 201
diff changeset
6 import ./vector
7f921d7d0a2b did: small refactoring of module structure
Sam <sam@basx.dev>
parents: 201
diff changeset
7 import ./matrix
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
8
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
9 type
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
10 Sampler2DType* = object
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
11 GPUType* = float32 | float64 | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | TVec2[int32] | TVec2[int64] | TVec3[int32] | TVec3[int64] | TVec4[int32] | TVec4[int64] | TVec2[uint32] | TVec2[uint64] | TVec3[uint32] | TVec3[uint64] | TVec4[uint32] | TVec4[uint64] | TVec2[float32] | TVec2[float64] | TVec3[float32] | TVec3[float64] | TVec4[float32] | TVec4[float64] | TMat2[float32] | TMat2[float64] | TMat23[float32] | TMat23[float64] | TMat32[float32] | TMat32[float64] | TMat3[float32] | TMat3[float64] | TMat34[float32] | TMat34[float64] | TMat43[float32] | TMat43[float64] | TMat4[float32] | TMat4[float64] | Sampler2DType
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
12 DataType* = enum
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
13 Float32
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
14 Float64
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
15 Int8
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
16 Int16
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
17 Int32
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
18 Int64
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
19 UInt8
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
20 UInt16
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
21 UInt32
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
22 UInt64
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
23 Vec2I32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
24 Vec2I64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
25 Vec3I32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
26 Vec3I64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
27 Vec4I32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
28 Vec4I64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
29 Vec2U32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
30 Vec2U64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
31 Vec3U32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
32 Vec3U64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
33 Vec4U32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
34 Vec4U64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
35 Vec2F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
36 Vec2F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
37 Vec3F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
38 Vec3F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
39 Vec4F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
40 Vec4F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
41 Mat2F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
42 Mat2F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
43 Mat23F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
44 Mat23F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
45 Mat32F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
46 Mat32F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
47 Mat3F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
48 Mat3F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
49 Mat34F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
50 Mat34F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
51 Mat43F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
52 Mat43F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
53 Mat4F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
54 Mat4F64
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
55 Sampler2D
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
56 DataValue* = object
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
57 case thetype*: DataType
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
58 of Float32: float32: float32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
59 of Float64: float64: float64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
60 of Int8: int8: int8
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
61 of Int16: int16: int16
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
62 of Int32: int32: int32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
63 of Int64: int64: int64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
64 of UInt8: uint8: uint8
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
65 of UInt16: uint16: uint16
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
66 of UInt32: uint32: uint32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
67 of UInt64: uint64: uint64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
68 of Vec2I32: vec2i32: TVec2[int32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
69 of Vec2I64: vec2i64: TVec2[int64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
70 of Vec3I32: vec3i32: TVec3[int32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
71 of Vec3I64: vec3i64: TVec3[int64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
72 of Vec4I32: vec4i32: TVec4[int32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
73 of Vec4I64: vec4i64: TVec4[int64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
74 of Vec2U32: vec2u32: TVec2[uint32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
75 of Vec2U64: vec2u64: TVec2[uint64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
76 of Vec3U32: vec3u32: TVec3[uint32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
77 of Vec3U64: vec3u64: TVec3[uint64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
78 of Vec4U32: vec4u32: TVec4[uint32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
79 of Vec4U64: vec4u64: TVec4[uint64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
80 of Vec2F32: vec2f32: TVec2[float32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
81 of Vec2F64: vec2f64: TVec2[float64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
82 of Vec3F32: vec3f32: TVec3[float32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
83 of Vec3F64: vec3f64: TVec3[float64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
84 of Vec4F32: vec4f32: TVec4[float32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
85 of Vec4F64: vec4f64: TVec4[float64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
86 of Mat2F32: mat2f32: TMat2[float32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
87 of Mat2F64: mat2f64: TMat2[float64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
88 of Mat23F32: mat23f32: TMat23[float32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
89 of Mat23F64: mat23f64: TMat23[float64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
90 of Mat32F32: mat32f32: TMat32[float32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
91 of Mat32F64: mat32f64: TMat32[float64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
92 of Mat3F32: mat3f32: TMat3[float32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
93 of Mat3F64: mat3f64: TMat3[float64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
94 of Mat34F32: mat34f32: TMat34[float32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
95 of Mat34F64: mat34f64: TMat34[float64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
96 of Mat43F32: mat43f32: TMat43[float32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
97 of Mat43F64: mat43f64: TMat43[float64]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
98 of Mat4F32: mat4f32: TMat4[float32]
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
99 of Mat4F64: mat4f64: TMat4[float64]
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
100 of Sampler2D: discard
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
101 DataList* = object
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
102 len*: uint32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
103 case thetype*: DataType
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
104 of Float32: float32: seq[float32]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
105 of Float64: float64: seq[float64]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
106 of Int8: int8: seq[int8]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
107 of Int16: int16: seq[int16]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
108 of Int32: int32: seq[int32]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
109 of Int64: int64: seq[int64]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
110 of UInt8: uint8: seq[uint8]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
111 of UInt16: uint16: seq[uint16]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
112 of UInt32: uint32: seq[uint32]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
113 of UInt64: uint64: seq[uint64]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
114 of Vec2I32: vec2i32: seq[TVec2[int32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
115 of Vec2I64: vec2i64: seq[TVec2[int64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
116 of Vec3I32: vec3i32: seq[TVec3[int32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
117 of Vec3I64: vec3i64: seq[TVec3[int64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
118 of Vec4I32: vec4i32: seq[TVec4[int32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
119 of Vec4I64: vec4i64: seq[TVec4[int64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
120 of Vec2U32: vec2u32: seq[TVec2[uint32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
121 of Vec2U64: vec2u64: seq[TVec2[uint64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
122 of Vec3U32: vec3u32: seq[TVec3[uint32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
123 of Vec3U64: vec3u64: seq[TVec3[uint64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
124 of Vec4U32: vec4u32: seq[TVec4[uint32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
125 of Vec4U64: vec4u64: seq[TVec4[uint64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
126 of Vec2F32: vec2f32: seq[TVec2[float32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
127 of Vec2F64: vec2f64: seq[TVec2[float64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
128 of Vec3F32: vec3f32: seq[TVec3[float32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
129 of Vec3F64: vec3f64: seq[TVec3[float64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
130 of Vec4F32: vec4f32: seq[TVec4[float32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
131 of Vec4F64: vec4f64: seq[TVec4[float64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
132 of Mat2F32: mat2f32: seq[TMat2[float32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
133 of Mat2F64: mat2f64: seq[TMat2[float64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
134 of Mat23F32: mat23f32: seq[TMat23[float32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
135 of Mat23F64: mat23f64: seq[TMat23[float64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
136 of Mat32F32: mat32f32: seq[TMat32[float32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
137 of Mat32F64: mat32f64: seq[TMat32[float64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
138 of Mat3F32: mat3f32: seq[TMat3[float32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
139 of Mat3F64: mat3f64: seq[TMat3[float64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
140 of Mat34F32: mat34f32: seq[TMat34[float32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
141 of Mat34F64: mat34f64: seq[TMat34[float64]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
142 of Mat43F32: mat43f32: seq[TMat43[float32]]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
143 of Mat43F64: mat43f64: seq[TMat43[float64]]
146
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
144 of Mat4F32: mat4f32*: seq[TMat4[float32]]
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
145 of Mat4F64: mat4f64: seq[TMat4[float64]]
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
146 of Sampler2D: discard
156
134647ed5b60 did: refactor memory selection
Sam <sam@basx.dev>
parents: 146
diff changeset
147 MemoryPerformanceHint* = enum
134647ed5b60 did: refactor memory selection
Sam <sam@basx.dev>
parents: 146
diff changeset
148 PreferFastRead, PreferFastWrite
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
149 ShaderAttribute* = object
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
150 name*: string
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
151 thetype*: DataType
201
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
152 arrayCount*: int
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
153 perInstance*: bool
156
134647ed5b60 did: refactor memory selection
Sam <sam@basx.dev>
parents: 146
diff changeset
154 memoryPerformanceHint*: MemoryPerformanceHint
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
155
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
156 func vertexInputs*(attributes: seq[ShaderAttribute]): seq[ShaderAttribute] =
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
157 for attr in attributes:
113
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
158 if attr.perInstance == false:
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
159 result.add attr
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
160
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
161 func instanceInputs*(attributes: seq[ShaderAttribute]): seq[ShaderAttribute] =
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
162 for attr in attributes:
113
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
163 if attr.perInstance == false:
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
164 result.add attr
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
165
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
166 func numberOfVertexInputAttributeDescriptors*(thetype: DataType): uint32 =
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
167 case thetype:
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
168 of Mat2F32, Mat2F64, Mat23F32, Mat23F64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
169 of Mat32F32, Mat32F64, Mat3F32, Mat3F64, Mat34F32, Mat34F64: 3
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
170 of Mat43F32, Mat43F64, Mat4F32, Mat4F64: 4
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
171 else: 1
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
172
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
173 func size*(thetype: DataType): uint32 =
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
174 case thetype:
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
175 of Float32: 4
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
176 of Float64: 8
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
177 of Int8: 1
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
178 of Int16: 2
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
179 of Int32: 4
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
180 of Int64: 8
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
181 of UInt8: 1
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
182 of UInt16: 2
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
183 of UInt32: 4
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
184 of UInt64: 8
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
185 of Vec2I32: 8
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
186 of Vec2I64: 16
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
187 of Vec3I32: 12
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
188 of Vec3I64: 24
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
189 of Vec4I32: 16
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
190 of Vec4I64: 32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
191 of Vec2U32: 8
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
192 of Vec2U64: 16
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
193 of Vec3U32: 12
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
194 of Vec3U64: 24
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
195 of Vec4U32: 16
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
196 of Vec4U64: 32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
197 of Vec2F32: 8
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
198 of Vec2F64: 16
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
199 of Vec3F32: 12
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
200 of Vec3F64: 24
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
201 of Vec4F32: 16
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
202 of Vec4F64: 32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
203 of Mat2F32: 16
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
204 of Mat2F64: 32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
205 of Mat23F32: 24
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
206 of Mat23F64: 48
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
207 of Mat32F32: 24
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
208 of Mat32F64: 48
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
209 of Mat3F32: 36
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
210 of Mat3F64: 72
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
211 of Mat34F32: 48
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
212 of Mat34F64: 92
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
213 of Mat43F32: 48
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
214 of Mat43F64: 92
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
215 of Mat4F32: 64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
216 of Mat4F64: 128
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
217 of Sampler2D: 0
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
218
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
219 func size*(attribute: ShaderAttribute, perDescriptor=false): uint32 =
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
220 if perDescriptor: attribute.thetype.size div attribute.thetype.numberOfVertexInputAttributeDescriptors
201
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
221 else: attribute.thetype.size
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
222
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
223 func size*(thetype: seq[ShaderAttribute]): uint32 =
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
224 for attribute in thetype:
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
225 result += attribute.size
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
226
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
227 func size*(value: DataValue): uint32 =
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
228 value.thetype.size
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
229
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
230 func size*(value: DataList): uint32 =
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
231 value.thetype.size * value.len
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
232
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
233 func getDataType*[T: GPUType|int|uint|float](): DataType =
113
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
234 when T is float32: Float32
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
235 elif T is float64: Float64
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
236 elif T is int8: Int8
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
237 elif T is int16: Int16
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
238 elif T is int32: Int32
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
239 elif T is int64: Int64
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
240 elif T is uint8: UInt8
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
241 elif T is uint16: UInt16
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
242 elif T is uint32: UInt32
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
243 elif T is uint64: UInt64
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
244 elif T is int and sizeof(int) == sizeof(int64): Int64
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
245 elif T is int and sizeof(int) == sizeof(int32): Int32
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
246 elif T is uint and sizeof(uint) == sizeof(uint64): UInt64
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
247 elif T is uint and sizeof(uint) == sizeof(uint32): UInt32
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
248 elif T is float and sizeof(float) == sizeof(float32): Float32
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
249 elif T is float and sizeof(float) == sizeof(float64): Float64
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
250 elif T is TVec2[int32]: Vec2I32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
251 elif T is TVec2[int64]: Vec2I64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
252 elif T is TVec3[int32]: Vec3I32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
253 elif T is TVec3[int64]: Vec3I64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
254 elif T is TVec4[int32]: Vec4I32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
255 elif T is TVec4[int64]: Vec4I64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
256 elif T is TVec2[uint32]: Vec2U32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
257 elif T is TVec2[uint64]: Vec2U64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
258 elif T is TVec3[uint32]: Vec3U32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
259 elif T is TVec3[uint64]: Vec3U64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
260 elif T is TVec4[uint32]: Vec4U32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
261 elif T is TVec4[uint64]: Vec4U64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
262 elif T is TVec2[float32]: Vec2F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
263 elif T is TVec2[float64]: Vec2F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
264 elif T is TVec3[float32]: Vec3F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
265 elif T is TVec3[float64]: Vec3F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
266 elif T is TVec4[float32]: Vec4F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
267 elif T is TVec4[float64]: Vec4F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
268 elif T is TMat2[float32]: Mat2F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
269 elif T is TMat2[float64]: Mat2F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
270 elif T is TMat23[float32]: Mat23F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
271 elif T is TMat23[float64]: Mat23F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
272 elif T is TMat32[float32]: Mat32F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
273 elif T is TMat32[float64]: Mat32F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
274 elif T is TMat3[float32]: Mat3F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
275 elif T is TMat3[float64]: Mat3F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
276 elif T is TMat34[float32]: Mat34F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
277 elif T is TMat34[float64]: Mat34F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
278 elif T is TMat43[float32]: Mat43F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
279 elif T is TMat43[float64]: Mat43F64
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
280 elif T is TMat4[float32]: Mat4F32
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
281 elif T is TMat4[float64]: Mat4F64
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
282 elif T is Sampler2DType: Sampler2D
113
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
283 else:
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
284 static:
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
285 raise newException(Exception, &"Unsupported data type for GPU data: {name(T)}" )
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
286
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
287 func attr*[T: GPUType](
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
288 name: string,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
289 perInstance=false,
201
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
290 arrayCount=0,
156
134647ed5b60 did: refactor memory selection
Sam <sam@basx.dev>
parents: 146
diff changeset
291 memoryPerformanceHint=PreferFastRead,
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
292 ): auto =
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
293 ShaderAttribute(
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
294 name: name,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
295 thetype: getDataType[T](),
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
296 perInstance: perInstance,
201
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
297 arrayCount: arrayCount,
156
134647ed5b60 did: refactor memory selection
Sam <sam@basx.dev>
parents: 146
diff changeset
298 memoryPerformanceHint: memoryPerformanceHint,
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
299 )
113
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
300
190
8f2eaf0d2808 add: uncomment some of the prepared texture code, nice interface for scene-global shader values (aka uniforms
Sam <sam@basx.dev>
parents: 189
diff changeset
301 func getValue*[T: GPUType|int|uint|float](value: DataValue): T =
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
302 when T is float32: value.float32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
303 elif T is float64: value.float64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
304 elif T is int8: value.int8
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
305 elif T is int16: value.int16
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
306 elif T is int32: value.int32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
307 elif T is int64: value.int64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
308 elif T is uint8: value.uint8
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
309 elif T is uint16: value.uint16
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
310 elif T is uint32: value.uint32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
311 elif T is uint64: value.uint64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
312 elif T is int and sizeof(int) == sizeof(int32): value.int32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
313 elif T is int and sizeof(int) == sizeof(int64): value.int64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
314 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
315 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
316 elif T is float and sizeof(float) == sizeof(float32): value.float32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
317 elif T is float and sizeof(float) == sizeof(float64): value.float64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
318 elif T is TVec2[int32]: value.vec2i32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
319 elif T is TVec2[int64]: value.vec2i64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
320 elif T is TVec3[int32]: value.vec3i32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
321 elif T is TVec3[int64]: value.vec3i64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
322 elif T is TVec4[int32]: value.vec4i32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
323 elif T is TVec4[int64]: value.vec4i64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
324 elif T is TVec2[uint32]: value.vec2u32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
325 elif T is TVec2[uint64]: value.vec2u64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
326 elif T is TVec3[uint32]: value.vec3u32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
327 elif T is TVec3[uint64]: value.vec3u64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
328 elif T is TVec4[uint32]: value.vec4u32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
329 elif T is TVec4[uint64]: value.vec4u64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
330 elif T is TVec2[float32]: value.vec2f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
331 elif T is TVec2[float64]: value.vec2f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
332 elif T is TVec3[float32]: value.vec3f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
333 elif T is TVec3[float64]: value.vec3f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
334 elif T is TVec4[float32]: value.vec4f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
335 elif T is TVec4[float64]: value.vec4f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
336 elif T is TMat2[float32]: value.mat2f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
337 elif T is TMat2[float64]: value.mat2f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
338 elif T is TMat23[float32]: value.mat23f
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
339 elif T is TMat23[float64]: value.mat23f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
340 elif T is TMat32[float32]: value.mat32f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
341 elif T is TMat32[float64]: value.mat32f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
342 elif T is TMat3[float32]: value.mat3f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
343 elif T is TMat3[float64]: value.mat3f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
344 elif T is TMat34[float32]: value.mat34f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
345 elif T is TMat34[float64]: value.mat34f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
346 elif T is TMat43[float32]: value.mat43f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
347 elif T is TMat43[float64]: value.mat43f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
348 elif T is TMat4[float32]: value.mat4f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
349 elif T is TMat4[float64]: value.mat4f64
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
350 else: {.error: "Virtual datatype has no value" .}
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
351
190
8f2eaf0d2808 add: uncomment some of the prepared texture code, nice interface for scene-global shader values (aka uniforms
Sam <sam@basx.dev>
parents: 189
diff changeset
352 func getValues*[T: GPUType|int|uint|float](value: DataList): seq[T] =
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
353 when T is float32: value.float32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
354 elif T is float64: value.float64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
355 elif T is int8: value.int8
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
356 elif T is int16: value.int16
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
357 elif T is int32: value.int32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
358 elif T is int64: value.int64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
359 elif T is uint8: value.uint8
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
360 elif T is uint16: value.uint16
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
361 elif T is uint32: value.uint32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
362 elif T is uint64: value.uint64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
363 elif T is int and sizeof(int) == sizeof(int32): value.int32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
364 elif T is int and sizeof(int) == sizeof(int64): value.int64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
365 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
366 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
367 elif T is float and sizeof(float) == sizeof(float32): value.float32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
368 elif T is float and sizeof(float) == sizeof(float64): value.float64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
369 elif T is TVec2[int32]: value.vec2i32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
370 elif T is TVec2[int64]: value.vec2i64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
371 elif T is TVec3[int32]: value.vec3i32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
372 elif T is TVec3[int64]: value.vec3i64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
373 elif T is TVec4[int32]: value.vec4i32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
374 elif T is TVec4[int64]: value.vec4i64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
375 elif T is TVec2[uint32]: value.vec2u32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
376 elif T is TVec2[uint64]: value.vec2u64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
377 elif T is TVec3[uint32]: value.vec3u32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
378 elif T is TVec3[uint64]: value.vec3u64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
379 elif T is TVec4[uint32]: value.vec4u32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
380 elif T is TVec4[uint64]: value.vec4u64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
381 elif T is TVec2[float32]: value.vec2f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
382 elif T is TVec2[float64]: value.vec2f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
383 elif T is TVec3[float32]: value.vec3f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
384 elif T is TVec3[float64]: value.vec3f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
385 elif T is TVec4[float32]: value.vec4f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
386 elif T is TVec4[float64]: value.vec4f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
387 elif T is TMat2[float32]: value.mat2f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
388 elif T is TMat2[float64]: value.mat2f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
389 elif T is TMat23[float32]: value.mat23f
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
390 elif T is TMat23[float64]: value.mat23f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
391 elif T is TMat32[float32]: value.mat32f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
392 elif T is TMat32[float64]: value.mat32f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
393 elif T is TMat3[float32]: value.mat3f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
394 elif T is TMat3[float64]: value.mat3f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
395 elif T is TMat34[float32]: value.mat34f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
396 elif T is TMat34[float64]: value.mat34f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
397 elif T is TMat43[float32]: value.mat43f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
398 elif T is TMat43[float64]: value.mat43f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
399 elif T is TMat4[float32]: value.mat4f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
400 elif T is TMat4[float64]: value.mat4f64
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
401 else: {. error: "Virtual datatype has no values" .}
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
402
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
403 func getRawData*(value: var DataValue): (pointer, uint32) =
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
404 result[1] = value.thetype.size
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
405 case value.thetype
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
406 of Float32: result[0] = addr value.float32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
407 of Float64: result[0] = addr value.float64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
408 of Int8: result[0] = addr value.int8
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
409 of Int16: result[0] = addr value.int16
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
410 of Int32: result[0] = addr value.int32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
411 of Int64: result[0] = addr value.int64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
412 of UInt8: result[0] = addr value.uint8
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
413 of UInt16: result[0] = addr value.uint16
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
414 of UInt32: result[0] = addr value.uint32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
415 of UInt64: result[0] = addr value.uint64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
416 of Vec2I32: result[0] = addr value.vec2i32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
417 of Vec2I64: result[0] = addr value.vec2i64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
418 of Vec3I32: result[0] = addr value.vec3i32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
419 of Vec3I64: result[0] = addr value.vec3i64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
420 of Vec4I32: result[0] = addr value.vec4i32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
421 of Vec4I64: result[0] = addr value.vec4i64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
422 of Vec2U32: result[0] = addr value.vec2u32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
423 of Vec2U64: result[0] = addr value.vec2u64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
424 of Vec3U32: result[0] = addr value.vec3u32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
425 of Vec3U64: result[0] = addr value.vec3u64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
426 of Vec4U32: result[0] = addr value.vec4u32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
427 of Vec4U64: result[0] = addr value.vec4u64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
428 of Vec2F32: result[0] = addr value.vec2f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
429 of Vec2F64: result[0] = addr value.vec2f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
430 of Vec3F32: result[0] = addr value.vec3f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
431 of Vec3F64: result[0] = addr value.vec3f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
432 of Vec4F32: result[0] = addr value.vec4f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
433 of Vec4F64: result[0] = addr value.vec4f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
434 of Mat2F32: result[0] = addr value.mat2f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
435 of Mat2F64: result[0] = addr value.mat2f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
436 of Mat23F32: result[0] = addr value.mat23f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
437 of Mat23F64: result[0] = addr value.mat23f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
438 of Mat32F32: result[0] = addr value.mat32f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
439 of Mat32F64: result[0] = addr value.mat32f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
440 of Mat3F32: result[0] = addr value.mat3f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
441 of Mat3F64: result[0] = addr value.mat3f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
442 of Mat34F32: result[0] = addr value.mat34f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
443 of Mat34F64: result[0] = addr value.mat34f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
444 of Mat43F32: result[0] = addr value.mat43f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
445 of Mat43F64: result[0] = addr value.mat43f64
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
446 of Mat4F32: result[0] = addr value.mat4f32
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
447 of Mat4F64: result[0] = addr value.mat4f64
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
448 of Sampler2D: result[0] = nil
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
449
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
450 func getRawData*(value: var DataList): (pointer, uint32) =
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
451 result[1] = value.thetype.size * value.len
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
452 case value.thetype
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
453 of Float32: result[0] = addr value.float32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
454 of Float64: result[0] = addr value.float64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
455 of Int8: result[0] = addr value.int8[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
456 of Int16: result[0] = addr value.int16[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
457 of Int32: result[0] = addr value.int32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
458 of Int64: result[0] = addr value.int64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
459 of UInt8: result[0] = addr value.uint8[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
460 of UInt16: result[0] = addr value.uint16[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
461 of UInt32: result[0] = addr value.uint32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
462 of UInt64: result[0] = addr value.uint64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
463 of Vec2I32: result[0] = addr value.vec2i32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
464 of Vec2I64: result[0] = addr value.vec2i64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
465 of Vec3I32: result[0] = addr value.vec3i32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
466 of Vec3I64: result[0] = addr value.vec3i64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
467 of Vec4I32: result[0] = addr value.vec4i32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
468 of Vec4I64: result[0] = addr value.vec4i64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
469 of Vec2U32: result[0] = addr value.vec2u32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
470 of Vec2U64: result[0] = addr value.vec2u64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
471 of Vec3U32: result[0] = addr value.vec3u32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
472 of Vec3U64: result[0] = addr value.vec3u64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
473 of Vec4U32: result[0] = addr value.vec4u32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
474 of Vec4U64: result[0] = addr value.vec4u64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
475 of Vec2F32: result[0] = addr value.vec2f32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
476 of Vec2F64: result[0] = addr value.vec2f64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
477 of Vec3F32: result[0] = addr value.vec3f32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
478 of Vec3F64: result[0] = addr value.vec3f64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
479 of Vec4F32: result[0] = addr value.vec4f32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
480 of Vec4F64: result[0] = addr value.vec4f64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
481 of Mat2F32: result[0] = addr value.mat2f32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
482 of Mat2F64: result[0] = addr value.mat2f64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
483 of Mat23F32: result[0] = addr value.mat23f32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
484 of Mat23F64: result[0] = addr value.mat23f64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
485 of Mat32F32: result[0] = addr value.mat32f32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
486 of Mat32F64: result[0] = addr value.mat32f64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
487 of Mat3F32: result[0] = addr value.mat3f32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
488 of Mat3F64: result[0] = addr value.mat3f64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
489 of Mat34F32: result[0] = addr value.mat34f32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
490 of Mat34F64: result[0] = addr value.mat34f64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
491 of Mat43F32: result[0] = addr value.mat43f32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
492 of Mat43F64: result[0] = addr value.mat43f64[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
493 of Mat4F32: result[0] = addr value.mat4f32[0]
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
494 of Mat4F64: result[0] = addr value.mat4f64[0]
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
495 of Sampler2D: result[0] = nil
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
496
146
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
497 func initData*(value: var DataList, len: uint32) =
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
498 value.len = len
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
499 case value.thetype
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
500 of Float32: value.float32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
501 of Float64: value.float64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
502 of Int8: value.int8.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
503 of Int16: value.int16.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
504 of Int32: value.int32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
505 of Int64: value.int64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
506 of UInt8: value.uint8.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
507 of UInt16: value.uint16.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
508 of UInt32: value.uint32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
509 of UInt64: value.uint64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
510 of Vec2I32: value.vec2i32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
511 of Vec2I64: value.vec2i64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
512 of Vec3I32: value.vec3i32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
513 of Vec3I64: value.vec3i64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
514 of Vec4I32: value.vec4i32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
515 of Vec4I64: value.vec4i64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
516 of Vec2U32: value.vec2u32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
517 of Vec2U64: value.vec2u64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
518 of Vec3U32: value.vec3u32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
519 of Vec3U64: value.vec3u64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
520 of Vec4U32: value.vec4u32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
521 of Vec4U64: value.vec4u64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
522 of Vec2F32: value.vec2f32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
523 of Vec2F64: value.vec2f64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
524 of Vec3F32: value.vec3f32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
525 of Vec3F64: value.vec3f64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
526 of Vec4F32: value.vec4f32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
527 of Vec4F64: value.vec4f64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
528 of Mat2F32: value.mat2f32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
529 of Mat2F64: value.mat2f64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
530 of Mat23F32: value.mat23f32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
531 of Mat23F64: value.mat23f64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
532 of Mat32F32: value.mat32f32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
533 of Mat32F64: value.mat32f64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
534 of Mat3F32: value.mat3f32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
535 of Mat3F64: value.mat3f64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
536 of Mat34F32: value.mat34f32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
537 of Mat34F64: value.mat34f64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
538 of Mat43F32: value.mat43f32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
539 of Mat43F64: value.mat43f64.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
540 of Mat4F32: value.mat4f32.setLen(len)
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
541 of Mat4F64: value.mat4f64.setLen(len)
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
542 of Sampler2D: discard
146
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
543
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
544 func setValue*[T: GPUType|int|uint|float](value: var DataValue, data: T) =
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
545 when T is float32: value.float32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
546 elif T is float64: value.float64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
547 elif T is int8: value.int8 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
548 elif T is int16: value.int16 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
549 elif T is int32: value.int32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
550 elif T is int64: value.int64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
551 elif T is uint8: value.uint8 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
552 elif T is uint16: value.uint16 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
553 elif T is uint32: value.uint32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
554 elif T is uint64: value.uint64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
555 elif T is int and sizeof(int) == sizeof(int32): value.int32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
556 elif T is int and sizeof(int) == sizeof(int64): value.int64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
557 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
558 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
559 elif T is float and sizeof(float) == sizeof(float32): value.float32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
560 elif T is float and sizeof(float) == sizeof(float64): value.float64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
561 elif T is TVec2[int32]: value.vec2i32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
562 elif T is TVec2[int64]: value.vec2i64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
563 elif T is TVec3[int32]: value.vec3i32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
564 elif T is TVec3[int64]: value.vec3i64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
565 elif T is TVec4[int32]: value.vec4i32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
566 elif T is TVec4[int64]: value.vec4i64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
567 elif T is TVec2[uint32]: value.vec2u32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
568 elif T is TVec2[uint64]: value.vec2u64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
569 elif T is TVec3[uint32]: value.vec3u32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
570 elif T is TVec3[uint64]: value.vec3u64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
571 elif T is TVec4[uint32]: value.vec4u32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
572 elif T is TVec4[uint64]: value.vec4u64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
573 elif T is TVec2[float32]: value.vec2f32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
574 elif T is TVec2[float64]: value.vec2f64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
575 elif T is TVec3[float32]: value.vec3f32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
576 elif T is TVec3[float64]: value.vec3f64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
577 elif T is TVec4[float32]: value.vec4f32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
578 elif T is TVec4[float64]: value.vec4f64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
579 elif T is TMat2[float32]: value.mat2f32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
580 elif T is TMat2[float64]: value.mat2f64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
581 elif T is TMat23[float32]: value.mat23f32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
582 elif T is TMat23[float64]: value.mat23f64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
583 elif T is TMat32[float32]: value.mat32f32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
584 elif T is TMat32[float64]: value.mat32f64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
585 elif T is TMat3[float32]: value.mat3f32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
586 elif T is TMat3[float64]: value.mat3f64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
587 elif T is TMat34[float32]: value.mat34f32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
588 elif T is TMat34[float64]: value.mat34f64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
589 elif T is TMat43[float32]: value.mat43f32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
590 elif T is TMat43[float64]: value.mat43f64 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
591 elif T is TMat4[float32]: value.mat4f32 = data
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
592 elif T is TMat4[float64]: value.mat4f64 = data
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
593 else: {.error: "Virtual datatype has no value" .}
113
7b695fb335ed did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents: 112
diff changeset
594
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
595 func setValues*[T: GPUType|int|uint|float](value: var DataList, data: seq[T]) =
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
596 value.len = uint32(data.len)
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
597 when T is float32: value.float32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
598 elif T is float64: value.float64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
599 elif T is int8: value.int8 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
600 elif T is int16: value.int16 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
601 elif T is int32: value.int32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
602 elif T is int64: value.int64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
603 elif T is uint8: value.uint8 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
604 elif T is uint16: value.uint16 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
605 elif T is uint32: value.uint32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
606 elif T is uint64: value.uint64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
607 elif T is int and sizeof(int) == sizeof(int32): value.int32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
608 elif T is int and sizeof(int) == sizeof(int64): value.int64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
609 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
610 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
611 elif T is float and sizeof(float) == sizeof(float32): value.float32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
612 elif T is float and sizeof(float) == sizeof(float64): value.float64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
613 elif T is TVec2[int32]: value.vec2i32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
614 elif T is TVec2[int64]: value.vec2i64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
615 elif T is TVec3[int32]: value.vec3i32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
616 elif T is TVec3[int64]: value.vec3i64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
617 elif T is TVec4[int32]: value.vec4i32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
618 elif T is TVec4[int64]: value.vec4i64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
619 elif T is TVec2[uint32]: value.vec2u32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
620 elif T is TVec2[uint64]: value.vec2u64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
621 elif T is TVec3[uint32]: value.vec3u32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
622 elif T is TVec3[uint64]: value.vec3u64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
623 elif T is TVec4[uint32]: value.vec4u32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
624 elif T is TVec4[uint64]: value.vec4u64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
625 elif T is TVec2[float32]: value.vec2f32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
626 elif T is TVec2[float64]: value.vec2f64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
627 elif T is TVec3[float32]: value.vec3f32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
628 elif T is TVec3[float64]: value.vec3f64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
629 elif T is TVec4[float32]: value.vec4f32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
630 elif T is TVec4[float64]: value.vec4f64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
631 elif T is TMat2[float32]: value.mat2f32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
632 elif T is TMat2[float64]: value.mat2f64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
633 elif T is TMat23[float32]: value.mat23f32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
634 elif T is TMat23[float64]: value.mat23f64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
635 elif T is TMat32[float32]: value.mat32f32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
636 elif T is TMat32[float64]: value.mat32f64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
637 elif T is TMat3[float32]: value.mat3f32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
638 elif T is TMat3[float64]: value.mat3f64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
639 elif T is TMat34[float32]: value.mat34f32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
640 elif T is TMat34[float64]: value.mat34f64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
641 elif T is TMat43[float32]: value.mat43f32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
642 elif T is TMat43[float64]: value.mat43f64 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
643 elif T is TMat4[float32]: value.mat4f32 = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
644 elif T is TMat4[float64]: value.mat4f64 = data
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
645 else: {. error: "Virtual datatype has no values" .}
146
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
646
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
647 func setValue*[T: GPUType|int|uint|float](value: var DataList, i: uint32, data: T) =
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
648 assert i < value.len
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
649 when T is float32: value.float32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
650 elif T is float64: value.float64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
651 elif T is int8: value.int8[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
652 elif T is int16: value.int16[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
653 elif T is int32: value.int32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
654 elif T is int64: value.int64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
655 elif T is uint8: value.uint8[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
656 elif T is uint16: value.uint16[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
657 elif T is uint32: value.uint32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
658 elif T is uint64: value.uint64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
659 elif T is int and sizeof(int) == sizeof(int32): value.int32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
660 elif T is int and sizeof(int) == sizeof(int64): value.int64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
661 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
662 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
663 elif T is float and sizeof(float) == sizeof(float32): value.float32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
664 elif T is float and sizeof(float) == sizeof(float64): value.float64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
665 elif T is TVec2[int32]: value.vec2i32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
666 elif T is TVec2[int64]: value.vec2i64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
667 elif T is TVec3[int32]: value.vec3i32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
668 elif T is TVec3[int64]: value.vec3i64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
669 elif T is TVec4[int32]: value.vec4i32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
670 elif T is TVec4[int64]: value.vec4i64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
671 elif T is TVec2[uint32]: value.vec2u32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
672 elif T is TVec2[uint64]: value.vec2u64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
673 elif T is TVec3[uint32]: value.vec3u32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
674 elif T is TVec3[uint64]: value.vec3u64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
675 elif T is TVec4[uint32]: value.vec4u32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
676 elif T is TVec4[uint64]: value.vec4u64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
677 elif T is TVec2[float32]: value.vec2f32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
678 elif T is TVec2[float64]: value.vec2f64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
679 elif T is TVec3[float32]: value.vec3f32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
680 elif T is TVec3[float64]: value.vec3f64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
681 elif T is TVec4[float32]: value.vec4f32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
682 elif T is TVec4[float64]: value.vec4f64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
683 elif T is TMat2[float32]: value.mat2f32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
684 elif T is TMat2[float64]: value.mat2f64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
685 elif T is TMat23[float32]: value.mat23f32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
686 elif T is TMat23[float64]: value.mat23f64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
687 elif T is TMat32[float32]: value.mat32f32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
688 elif T is TMat32[float64]: value.mat32f64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
689 elif T is TMat3[float32]: value.mat3f32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
690 elif T is TMat3[float64]: value.mat3f64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
691 elif T is TMat34[float32]: value.mat34f32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
692 elif T is TMat34[float64]: value.mat34f64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
693 elif T is TMat43[float32]: value.mat43f32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
694 elif T is TMat43[float64]: value.mat43f64[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
695 elif T is TMat4[float32]: value.mat4f32[i] = data
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
696 elif T is TMat4[float64]: value.mat4f64[i] = data
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
697 else: {. error: "Virtual datatype has no values" .}
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
698
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
699 const TYPEMAP = {
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
700 Float32: VK_FORMAT_R32_SFLOAT,
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
701 Float64: VK_FORMAT_R64_SFLOAT,
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
702 Int8: VK_FORMAT_R8_SINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
703 Int16: VK_FORMAT_R16_SINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
704 Int32: VK_FORMAT_R32_SINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
705 Int64: VK_FORMAT_R64_SINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
706 UInt8: VK_FORMAT_R8_UINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
707 UInt16: VK_FORMAT_R16_UINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
708 UInt32: VK_FORMAT_R32_UINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
709 UInt64: VK_FORMAT_R64_UINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
710 Vec2I32: VK_FORMAT_R32G32_SINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
711 Vec2I64: VK_FORMAT_R64G64_SINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
712 Vec3I32: VK_FORMAT_R32G32B32_SINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
713 Vec3I64: VK_FORMAT_R64G64B64_SINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
714 Vec4I32: VK_FORMAT_R32G32B32A32_SINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
715 Vec4I64: VK_FORMAT_R64G64B64A64_SINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
716 Vec2U32: VK_FORMAT_R32G32_UINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
717 Vec2U64: VK_FORMAT_R64G64_UINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
718 Vec3U32: VK_FORMAT_R32G32B32_UINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
719 Vec3U64: VK_FORMAT_R64G64B64_UINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
720 Vec4U32: VK_FORMAT_R32G32B32A32_UINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
721 Vec4U64: VK_FORMAT_R64G64B64A64_UINT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
722 Vec2F32: VK_FORMAT_R32G32_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
723 Vec2F64: VK_FORMAT_R64G64_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
724 Vec3F32: VK_FORMAT_R32G32B32_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
725 Vec3F64: VK_FORMAT_R64G64B64_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
726 Vec4F32: VK_FORMAT_R32G32B32A32_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
727 Vec4F64: VK_FORMAT_R64G64B64A64_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
728 Mat2F32: VK_FORMAT_R32G32_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
729 Mat2F64: VK_FORMAT_R64G64_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
730 Mat23F32: VK_FORMAT_R32G32B32_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
731 Mat23F64: VK_FORMAT_R64G64B64_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
732 Mat32F32: VK_FORMAT_R32G32_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
733 Mat32F64: VK_FORMAT_R64G64_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
734 Mat3F32: VK_FORMAT_R32G32B32_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
735 Mat3F64: VK_FORMAT_R64G64B64_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
736 Mat34F32: VK_FORMAT_R32G32B32A32_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
737 Mat34F64: VK_FORMAT_R64G64B64A64_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
738 Mat43F32: VK_FORMAT_R32G32B32_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
739 Mat43F64: VK_FORMAT_R64G64B64_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
740 Mat4F32: VK_FORMAT_R32G32B32A32_SFLOAT,
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
741 Mat4F64: VK_FORMAT_R64G64B64A64_SFLOAT,
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
742 }.toTable
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
743
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
744 func getVkFormat*(thetype: DataType): VkFormat =
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
745 TYPEMAP[thetype]
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
746
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
747 # from https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap15.html
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
748 func nLocationSlots*(thetype: DataType): uint32 =
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
749 #[
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
750 single location:
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
751 16-bit scalar and vector types, and
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
752 32-bit scalar and vector types, and
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
753 64-bit scalar and 2-component vector types.
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
754 two locations
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
755 64-bit three- and four-component vectors
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
756 ]#
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
757 case thetype:
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
758 of Float32: 1
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
759 of Float64: 1
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
760 of Int8: 1
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
761 of Int16: 1
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
762 of Int32: 1
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
763 of Int64: 1
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
764 of UInt8: 1
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
765 of UInt16: 1
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
766 of UInt32: 1
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
767 of UInt64: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
768 of Vec2I32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
769 of Vec2I64: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
770 of Vec3I32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
771 of Vec3I64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
772 of Vec4I32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
773 of Vec4I64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
774 of Vec2U32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
775 of Vec2U64: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
776 of Vec3U32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
777 of Vec3U64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
778 of Vec4U32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
779 of Vec4U64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
780 of Vec2F32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
781 of Vec2F64: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
782 of Vec3F32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
783 of Vec3F64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
784 of Vec4F32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
785 of Vec4F64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
786 of Mat2F32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
787 of Mat2F64: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
788 of Mat23F32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
789 of Mat23F64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
790 of Mat32F32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
791 of Mat32F64: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
792 of Mat3F32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
793 of Mat3F64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
794 of Mat34F32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
795 of Mat34F64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
796 of Mat43F32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
797 of Mat43F64: 2
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
798 of Mat4F32: 1
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
799 of Mat4F64: 2
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
800 of Sampler2D: 1
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
801
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
802 func glslType*(thetype: DataType): string =
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
803 # todo: likely not correct as we would need to enable some
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
804 # extensions somewhere (Vulkan/GLSL compiler?) to have
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
805 # everything work as intended. Or maybe the GPU driver does
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
806 # some automagic conversion stuf..
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
807 case thetype:
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
808 of Float32: "float"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
809 of Float64: "double"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
810 of Int8, Int16, Int32, Int64: "int"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
811 of UInt8, UInt16, UInt32, UInt64: "uint"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
812 of Vec2I32: "ivec2"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
813 of Vec2I64: "ivec2"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
814 of Vec3I32: "ivec3"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
815 of Vec3I64: "ivec3"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
816 of Vec4I32: "ivec4"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
817 of Vec4I64: "ivec4"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
818 of Vec2U32: "uvec2"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
819 of Vec2U64: "uvec2"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
820 of Vec3U32: "uvec3"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
821 of Vec3U64: "uvec3"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
822 of Vec4U32: "uvec4"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
823 of Vec4U64: "uvec4"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
824 of Vec2F32: "vec2"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
825 of Vec2F64: "dvec2"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
826 of Vec3F32: "vec3"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
827 of Vec3F64: "dvec3"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
828 of Vec4F32: "vec4"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
829 of Vec4F64: "dvec4"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
830 of Mat2F32: "mat2"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
831 of Mat2F64: "dmat2"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
832 of Mat23F32: "mat23"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
833 of Mat23F64: "dmat23"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
834 of Mat32F32: "mat32"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
835 of Mat32F64: "dmat32"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
836 of Mat3F32: "mat3"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
837 of Mat3F64: "dmat3"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
838 of Mat34F32: "mat34"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
839 of Mat34F64: "dmat34"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
840 of Mat43F32: "mat43"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
841 of Mat43F64: "dmat43"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
842 of Mat4F32: "mat4"
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
843 of Mat4F64: "dmat4"
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
844 of Sampler2D: "sampler2D"
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
845
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
846 func glslInput*(group: seq[ShaderAttribute]): seq[string] =
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
847 if group.len == 0:
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
848 return @[]
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
849 var i = 0'u32
137
ac2b6777c5db add: some cleanup, discovered bug
Sam <sam@basx.dev>
parents: 124
diff changeset
850 for attribute in group:
201
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
851 assert attribute.arrayCount == 0, "arrays not yet supported for shader vertex attributes"
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
852 result.add &"layout(location = {i}) in {attribute.thetype.glslType} {attribute.name};"
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
853 for j in 0 ..< attribute.thetype.numberOfVertexInputAttributeDescriptors:
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
854 i += attribute.thetype.nLocationSlots
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
855
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
856 func glslUniforms*(group: seq[ShaderAttribute], blockName="Uniforms", binding: int): seq[string] =
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
857 if group.len == 0:
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
858 return @[]
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
859 # currently only a single uniform block supported, therefore binding = 0
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
860 result.add(&"layout(binding = {binding}) uniform T{blockName} {{")
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
861 for attribute in group:
201
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
862 assert attribute.arrayCount == 0, "arrays not yet supported for uniforms"
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
863 result.add(&" {attribute.thetype.glslType} {attribute.name};")
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
864 result.add(&"}} {blockName};")
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
865
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
866 func glslSamplers*(group: seq[ShaderAttribute], basebinding: int): seq[string] =
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
867 if group.len == 0:
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
868 return @[]
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
869 var thebinding = basebinding
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
870 for attribute in group:
201
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
871 var arrayDecl = ""
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
872 if attribute.arrayCount > 0:
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
873 arrayDecl = &"[{attribute.arrayCount}]"
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
874 result.add(&"layout(binding = {thebinding}) uniform {attribute.thetype.glslType} {attribute.name}{arrayDecl};")
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
875 inc thebinding
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
876
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
877 func glslOutput*(group: seq[ShaderAttribute]): seq[string] =
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
878 if group.len == 0:
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
879 return @[]
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
880 var i = 0'u32
122
506090173619 did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents: 121
diff changeset
881 for attribute in group:
201
ab626e67a1ee add: support for arrays of samplers
Sam <sam@basx.dev>
parents: 190
diff changeset
882 assert attribute.arrayCount == 0, "arrays not yet supported for outputs"
121
dfaddaf96f09 did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents: 120
diff changeset
883 result.add &"layout(location = {i}) out {attribute.thetype.glslType} {attribute.name};"
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
884 i += 1