Mercurial > games > semicongine
annotate src/semicongine/core/gpu_data.nim @ 333:27aaf43e18b4
fix: material handling, gltf loading, loader example
author | Sam <sam@basx.dev> |
---|---|
date | Mon, 04 Sep 2023 00:31:17 +0700 |
parents | 04531bec3583 |
children | 01ccd1393e7f |
rev | line source |
---|---|
111 | 1 import std/strformat |
2 import std/tables | |
3 | |
206
7f921d7d0a2b
did: small refactoring of module structure
Sam <sam@basx.dev>
parents:
201
diff
changeset
|
4 import ./vulkanapi |
7f921d7d0a2b
did: small refactoring of module structure
Sam <sam@basx.dev>
parents:
201
diff
changeset
|
5 import ./vector |
7f921d7d0a2b
did: small refactoring of module structure
Sam <sam@basx.dev>
parents:
201
diff
changeset
|
6 import ./matrix |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
7 import ./utils |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
8 import ./imagetypes |
111 | 9 |
10 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
|
11 Sampler2DType* = object |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
12 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] | Texture |
111 | 13 DataType* = enum |
14 Float32 | |
15 Float64 | |
16 Int8 | |
17 Int16 | |
18 Int32 | |
19 Int64 | |
20 UInt8 | |
21 UInt16 | |
22 UInt32 | |
23 UInt64 | |
121
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
24 Vec2I32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
25 Vec2I64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
26 Vec3I32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
27 Vec3I64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
28 Vec4I32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
29 Vec4I64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
30 Vec2U32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
31 Vec2U64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
32 Vec3U32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
33 Vec3U64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
34 Vec4U32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
35 Vec4U64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
36 Vec2F32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
37 Vec2F64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
38 Vec3F32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
39 Vec3F64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
40 Vec4F32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
41 Vec4F64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
42 Mat2F32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
43 Mat2F64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
44 Mat23F32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
45 Mat23F64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
46 Mat32F32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
47 Mat32F64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
48 Mat3F32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
49 Mat3F64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
50 Mat34F32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
51 Mat34F64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
52 Mat43F32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
53 Mat43F64 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
54 Mat4F32 |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
55 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
|
56 Sampler2D |
121
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
57 DataValue* = object |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
58 case theType*: DataType |
121
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 of Mat4F64: mat4f64: TMat4[float64] |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
101 of Sampler2D: texture: Texture |
123
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
102 DataList* = object |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
103 len*: int |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
104 case theType*: DataType |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
105 of Float32: float32: seq[float32] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
106 of Float64: float64: seq[float64] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
107 of Int8: int8: seq[int8] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
108 of Int16: int16: seq[int16] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
109 of Int32: int32: seq[int32] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
110 of Int64: int64: seq[int64] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
111 of UInt8: uint8: seq[uint8] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
112 of UInt16: uint16: seq[uint16] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
113 of UInt32: uint32: seq[uint32] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
114 of UInt64: uint64: seq[uint64] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
115 of Vec2I32: vec2i32: seq[TVec2[int32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
116 of Vec2I64: vec2i64: seq[TVec2[int64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
117 of Vec3I32: vec3i32: seq[TVec3[int32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
118 of Vec3I64: vec3i64: seq[TVec3[int64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
119 of Vec4I32: vec4i32: seq[TVec4[int32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
120 of Vec4I64: vec4i64: seq[TVec4[int64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
121 of Vec2U32: vec2u32: seq[TVec2[uint32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
122 of Vec2U64: vec2u64: seq[TVec2[uint64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
123 of Vec3U32: vec3u32: seq[TVec3[uint32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
124 of Vec3U64: vec3u64: seq[TVec3[uint64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
125 of Vec4U32: vec4u32: seq[TVec4[uint32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
126 of Vec4U64: vec4u64: seq[TVec4[uint64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
127 of Vec2F32: vec2f32: seq[TVec2[float32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
128 of Vec2F64: vec2f64: seq[TVec2[float64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
129 of Vec3F32: vec3f32: seq[TVec3[float32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
130 of Vec3F64: vec3f64: seq[TVec3[float64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
131 of Vec4F32: vec4f32: seq[TVec4[float32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
132 of Vec4F64: vec4f64: seq[TVec4[float64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
133 of Mat2F32: mat2f32: seq[TMat2[float32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
134 of Mat2F64: mat2f64: seq[TMat2[float64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
135 of Mat23F32: mat23f32: seq[TMat23[float32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
136 of Mat23F64: mat23f64: seq[TMat23[float64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
137 of Mat32F32: mat32f32: seq[TMat32[float32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
138 of Mat32F64: mat32f64: seq[TMat32[float64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
139 of Mat3F32: mat3f32: seq[TMat3[float32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
140 of Mat3F64: mat3f64: seq[TMat3[float64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
141 of Mat34F32: mat34f32: seq[TMat34[float32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
142 of Mat34F64: mat34f64: seq[TMat34[float64]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
143 of Mat43F32: mat43f32: seq[TMat43[float32]] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
144 of Mat43F64: mat43f64: seq[TMat43[float64]] |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
145 of Mat4F32: mat4f32: seq[TMat4[float32]] |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
146 of Mat4F64: mat4f64: seq[TMat4[float64]] |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
147 of Sampler2D: texture: seq[Texture] |
156 | 148 MemoryPerformanceHint* = enum |
149 PreferFastRead, PreferFastWrite | |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
150 ShaderAttribute* = object |
111 | 151 name*: string |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
152 theType*: DataType |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
153 arrayCount*: int |
111 | 154 perInstance*: bool |
267
a107d9ef1a1f
add: flat attribute for shader in/outputs
Sam <sam@basx.dev>
parents:
266
diff
changeset
|
155 noInterpolation: bool |
156 | 156 memoryPerformanceHint*: MemoryPerformanceHint |
111 | 157 |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
158 func `==`*(a, b: DataList | DataValue): bool = |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
159 if a.theType != b.theType: |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
160 return false |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
161 case a.theType |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
162 of Float32: return a.float32 == b.float32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
163 of Float64: return a.float64 == b.float64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
164 of Int8: return a.int8 == b.int8 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
165 of Int16: return a.int16 == b.int16 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
166 of Int32: return a.int32 == b.int32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
167 of Int64: return a.int64 == b.int64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
168 of UInt8: return a.uint8 == b.uint8 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
169 of UInt16: return a.uint16 == b.uint16 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
170 of UInt32: return a.uint32 == b.uint32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
171 of UInt64: return a.uint64 == b.uint64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
172 of Vec2I32: return a.vec2i32 == b.vec2i32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
173 of Vec2I64: return a.vec2i64 == b.vec2i64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
174 of Vec3I32: return a.vec3i32 == b.vec3i32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
175 of Vec3I64: return a.vec3i64 == b.vec3i64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
176 of Vec4I32: return a.vec4i32 == b.vec4i32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
177 of Vec4I64: return a.vec4i64 == b.vec4i64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
178 of Vec2U32: return a.vec2u32 == b.vec2u32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
179 of Vec2U64: return a.vec2u64 == b.vec2u64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
180 of Vec3U32: return a.vec3u32 == b.vec3u32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
181 of Vec3U64: return a.vec3u64 == b.vec3u64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
182 of Vec4U32: return a.vec4u32 == b.vec4u32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
183 of Vec4U64: return a.vec4u64 == b.vec4u64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
184 of Vec2F32: return a.vec2f32 == b.vec2f32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
185 of Vec2F64: return a.vec2f64 == b.vec2f64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
186 of Vec3F32: return a.vec3f32 == b.vec3f32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
187 of Vec3F64: return a.vec3f64 == b.vec3f64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
188 of Vec4F32: return a.vec4f32 == b.vec4f32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
189 of Vec4F64: return a.vec4f64 == b.vec4f64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
190 of Mat2F32: return a.mat2f32 == b.mat2f32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
191 of Mat2F64: return a.mat2f64 == b.mat2f64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
192 of Mat23F32: return a.mat23f32 == b.mat23f32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
193 of Mat23F64: return a.mat23f64 == b.mat23f64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
194 of Mat32F32: return a.mat32f32 == b.mat32f32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
195 of Mat32F64: return a.mat32f64 == b.mat32f64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
196 of Mat3F32: return a.mat3f32 == b.mat3f32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
197 of Mat3F64: return a.mat3f64 == b.mat3f64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
198 of Mat34F32: return a.mat34f32 == b.mat34f32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
199 of Mat34F64: return a.mat34f64 == b.mat34f64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
200 of Mat43F32: return a.mat43f32 == b.mat43f32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
201 of Mat43F64: return a.mat43f64 == b.mat43f64 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
202 of Mat4F32: return a.mat4f32 == b.mat4f32 |
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
203 of Mat4F64: return a.mat4f64 == b.mat4f64 |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
204 of Sampler2D: a.texture == b.texture |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
205 |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
206 func vertexInputs*(attributes: seq[ShaderAttribute]): seq[ShaderAttribute] = |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
207 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
|
208 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
|
209 result.add attr |
7b695fb335ed
did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents:
112
diff
changeset
|
210 |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
211 func instanceInputs*(attributes: seq[ShaderAttribute]): seq[ShaderAttribute] = |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
212 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
|
213 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
|
214 result.add attr |
7b695fb335ed
did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents:
112
diff
changeset
|
215 |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
216 func numberOfVertexInputAttributeDescriptors*(theType: DataType): int = |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
217 case theType: |
121
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
218 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
|
219 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
|
220 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
|
221 else: 1 |
111 | 222 |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
223 func size*(theType: DataType): int = |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
224 case theType: |
111 | 225 of Float32: 4 |
226 of Float64: 8 | |
227 of Int8: 1 | |
228 of Int16: 2 | |
229 of Int32: 4 | |
230 of Int64: 8 | |
231 of UInt8: 1 | |
232 of UInt16: 2 | |
233 of UInt32: 4 | |
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 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
|
251 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
|
252 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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 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
|
261 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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 of Sampler2D: 0 |
123
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
268 |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
269 func size*(attribute: ShaderAttribute, perDescriptor=false): int = |
227 | 270 if perDescriptor: |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
271 attribute.theType.size div attribute.theType.numberOfVertexInputAttributeDescriptors |
227 | 272 else: |
273 if attribute.arrayCount == 0: | |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
274 attribute.theType.size |
227 | 275 else: |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
276 attribute.theType.size * attribute.arrayCount |
111 | 277 |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
278 func size*(theType: seq[ShaderAttribute]): int = |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
279 for attribute in theType: |
111 | 280 result += attribute.size |
281 | |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
282 func size*(value: DataValue): int = |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
283 value.theType.size |
123
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
284 |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
285 func size*(value: DataList): int = |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
286 value.theType.size * value.len |
123
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
287 |
121
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 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
|
310 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
|
311 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
|
312 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
323 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
|
324 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
|
325 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
|
326 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
|
327 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
|
328 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
|
329 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
|
330 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
|
331 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
|
332 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
|
333 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
|
334 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
|
335 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
|
336 elif T is TMat4[float64]: Mat4F64 |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
337 elif T is Texture: Sampler2D |
113
7b695fb335ed
did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents:
112
diff
changeset
|
338 else: |
7b695fb335ed
did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents:
112
diff
changeset
|
339 static: |
7b695fb335ed
did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents:
112
diff
changeset
|
340 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
|
341 |
121
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
342 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
|
343 name: string, |
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
344 perInstance=false, |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
345 arrayCount=0, |
267
a107d9ef1a1f
add: flat attribute for shader in/outputs
Sam <sam@basx.dev>
parents:
266
diff
changeset
|
346 noInterpolation=false, |
156 | 347 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
|
348 ): auto = |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
349 ShaderAttribute( |
121
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
350 name: name, |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
351 theType: getDataType[T](), |
121
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
352 perInstance: perInstance, |
201 | 353 arrayCount: arrayCount, |
267
a107d9ef1a1f
add: flat attribute for shader in/outputs
Sam <sam@basx.dev>
parents:
266
diff
changeset
|
354 noInterpolation: noInterpolation, |
156 | 355 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
|
356 ) |
113
7b695fb335ed
did: first final implementation of scene-graph <-> pipeline connection, not working yet
Sam <sam@basx.dev>
parents:
112
diff
changeset
|
357 |
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
|
358 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
|
359 when T is float32: value.float32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
360 elif T is float64: value.float64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
361 elif T is int8: value.int8 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
362 elif T is int16: value.int16 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
363 elif T is int32: value.int32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
364 elif T is int64: value.int64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
365 elif T is uint8: value.uint8 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
366 elif T is uint16: value.uint16 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
367 elif T is uint32: value.uint32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
368 elif T is uint64: value.uint64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
369 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
|
370 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
|
371 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
|
372 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
|
373 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
|
374 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
|
375 elif T is TVec2[int32]: value.vec2i32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
376 elif T is TVec2[int64]: value.vec2i64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
377 elif T is TVec3[int32]: value.vec3i32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
378 elif T is TVec3[int64]: value.vec3i64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
379 elif T is TVec4[int32]: value.vec4i32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
380 elif T is TVec4[int64]: value.vec4i64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
381 elif T is TVec2[uint32]: value.vec2u32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
382 elif T is TVec2[uint64]: value.vec2u64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
383 elif T is TVec3[uint32]: value.vec3u32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
384 elif T is TVec3[uint64]: value.vec3u64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
385 elif T is TVec4[uint32]: value.vec4u32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
386 elif T is TVec4[uint64]: value.vec4u64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
387 elif T is TVec2[float32]: value.vec2f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
388 elif T is TVec2[float64]: value.vec2f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
389 elif T is TVec3[float32]: value.vec3f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
390 elif T is TVec3[float64]: value.vec3f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
391 elif T is TVec4[float32]: value.vec4f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
392 elif T is TVec4[float64]: value.vec4f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
393 elif T is TMat2[float32]: value.mat2f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
394 elif T is TMat2[float64]: value.mat2f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
395 elif T is TMat23[float32]: value.mat23f |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
396 elif T is TMat23[float64]: value.mat23f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
397 elif T is TMat32[float32]: value.mat32f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
398 elif T is TMat32[float64]: value.mat32f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
399 elif T is TMat3[float32]: value.mat3f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
400 elif T is TMat3[float64]: value.mat3f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
401 elif T is TMat34[float32]: value.mat34f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
402 elif T is TMat34[float64]: value.mat34f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
403 elif T is TMat43[float32]: value.mat43f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
404 elif T is TMat43[float64]: value.mat43f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
405 elif T is TMat4[float32]: value.mat4f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
406 elif T is TMat4[float64]: value.mat4f64 |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
407 elif T is Texture: value.texture |
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
|
408 else: {.error: "Virtual datatype has no value" .} |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
409 |
225
d078b19bf531
fix: a ton of bug after refactoring gpu_data, start to add ideas for materials
Sam <sam@basx.dev>
parents:
224
diff
changeset
|
410 func setValues*[T: GPUType|int|uint|float](value: var DataList, data: seq[T]) = |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
411 value.len = data.len |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
412 when T is float32: value.float32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
413 elif T is float64: value.float64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
414 elif T is int8: value.int8 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
415 elif T is int16: value.int16 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
416 elif T is int32: value.int32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
417 elif T is int64: value.int64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
418 elif T is uint8: value.uint8 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
419 elif T is uint16: value.uint16 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
420 elif T is uint32: value.uint32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
421 elif T is uint64: value.uint64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
422 elif T is int and sizeof(int) == sizeof(int32): value.int32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
423 elif T is int and sizeof(int) == sizeof(int64): value.int64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
424 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
425 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
426 elif T is float and sizeof(float) == sizeof(float32): value.float32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
427 elif T is float and sizeof(float) == sizeof(float64): value.float64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
428 elif T is TVec2[int32]: value.vec2i32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
429 elif T is TVec2[int64]: value.vec2i64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
430 elif T is TVec3[int32]: value.vec3i32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
431 elif T is TVec3[int64]: value.vec3i64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
432 elif T is TVec4[int32]: value.vec4i32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
433 elif T is TVec4[int64]: value.vec4i64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
434 elif T is TVec2[uint32]: value.vec2u32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
435 elif T is TVec2[uint64]: value.vec2u64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
436 elif T is TVec3[uint32]: value.vec3u32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
437 elif T is TVec3[uint64]: value.vec3u64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
438 elif T is TVec4[uint32]: value.vec4u32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
439 elif T is TVec4[uint64]: value.vec4u64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
440 elif T is TVec2[float32]: value.vec2f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
441 elif T is TVec2[float64]: value.vec2f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
442 elif T is TVec3[float32]: value.vec3f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
443 elif T is TVec3[float64]: value.vec3f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
444 elif T is TVec4[float32]: value.vec4f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
445 elif T is TVec4[float64]: value.vec4f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
446 elif T is TMat2[float32]: value.mat2f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
447 elif T is TMat2[float64]: value.mat2f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
448 elif T is TMat23[float32]: value.mat23f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
449 elif T is TMat23[float64]: value.mat23f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
450 elif T is TMat32[float32]: value.mat32f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
451 elif T is TMat32[float64]: value.mat32f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
452 elif T is TMat3[float32]: value.mat3f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
453 elif T is TMat3[float64]: value.mat3f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
454 elif T is TMat34[float32]: value.mat34f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
455 elif T is TMat34[float64]: value.mat34f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
456 elif T is TMat43[float32]: value.mat43f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
457 elif T is TMat43[float64]: value.mat43f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
458 elif T is TMat4[float32]: value.mat4f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
459 elif T is TMat4[float64]: value.mat4f64 = data |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
460 elif T is Texture: value.texture = data |
225
d078b19bf531
fix: a ton of bug after refactoring gpu_data, start to add ideas for materials
Sam <sam@basx.dev>
parents:
224
diff
changeset
|
461 else: {. error: "Virtual datatype has no values" .} |
d078b19bf531
fix: a ton of bug after refactoring gpu_data, start to add ideas for materials
Sam <sam@basx.dev>
parents:
224
diff
changeset
|
462 |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
463 func newDataList*(theType: DataType): DataList = |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
464 result = DataList(theType: theType) |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
465 case result.theType |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
466 of Float32: result.float32 = newSeq[float32]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
467 of Float64: result.float64 = newSeq[float64]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
468 of Int8: result.int8 = newSeq[int8]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
469 of Int16: result.int16 = newSeq[int16]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
470 of Int32: result.int32 = newSeq[int32]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
471 of Int64: result.int64 = newSeq[int64]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
472 of UInt8: result.uint8 = newSeq[uint8]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
473 of UInt16: result.uint16 = newSeq[uint16]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
474 of UInt32: result.uint32 = newSeq[uint32]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
475 of UInt64: result.uint64 = newSeq[uint64]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
476 of Vec2I32: result.vec2i32 = newSeq[TVec2[int32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
477 of Vec2I64: result.vec2i64 = newSeq[TVec2[int64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
478 of Vec3I32: result.vec3i32 = newSeq[TVec3[int32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
479 of Vec3I64: result.vec3i64 = newSeq[TVec3[int64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
480 of Vec4I32: result.vec4i32 = newSeq[TVec4[int32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
481 of Vec4I64: result.vec4i64 = newSeq[TVec4[int64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
482 of Vec2U32: result.vec2u32 = newSeq[TVec2[uint32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
483 of Vec2U64: result.vec2u64 = newSeq[TVec2[uint64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
484 of Vec3U32: result.vec3u32 = newSeq[TVec3[uint32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
485 of Vec3U64: result.vec3u64 = newSeq[TVec3[uint64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
486 of Vec4U32: result.vec4u32 = newSeq[TVec4[uint32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
487 of Vec4U64: result.vec4u64 = newSeq[TVec4[uint64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
488 of Vec2F32: result.vec2f32 = newSeq[TVec2[float32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
489 of Vec2F64: result.vec2f64 = newSeq[TVec2[float64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
490 of Vec3F32: result.vec3f32 = newSeq[TVec3[float32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
491 of Vec3F64: result.vec3f64 = newSeq[TVec3[float64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
492 of Vec4F32: result.vec4f32 = newSeq[TVec4[float32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
493 of Vec4F64: result.vec4f64 = newSeq[TVec4[float64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
494 of Mat2F32: result.mat2f32 = newSeq[TMat2[float32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
495 of Mat2F64: result.mat2f64 = newSeq[TMat2[float64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
496 of Mat23F32: result.mat23f32 = newSeq[TMat23[float32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
497 of Mat23F64: result.mat23f64 = newSeq[TMat23[float64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
498 of Mat32F32: result.mat32f32 = newSeq[TMat32[float32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
499 of Mat32F64: result.mat32f64 = newSeq[TMat32[float64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
500 of Mat3F32: result.mat3f32 = newSeq[TMat3[float32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
501 of Mat3F64: result.mat3f64 = newSeq[TMat3[float64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
502 of Mat34F32: result.mat34f32 = newSeq[TMat34[float32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
503 of Mat34F64: result.mat34f64 = newSeq[TMat34[float64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
504 of Mat43F32: result.mat43f32 = newSeq[TMat43[float32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
505 of Mat43F64: result.mat43f64 = newSeq[TMat43[float64]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
506 of Mat4F32: result.mat4f32 = newSeq[TMat4[float32]]() |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
507 of Mat4F64: result.mat4f64 = newSeq[TMat4[float64]]() |
224 | 508 of Sampler2D: discard |
509 | |
510 func newDataList*[T: GPUType](len=0): DataList = | |
511 result = newDataList(getDataType[T]()) | |
512 if len > 0: | |
513 result.initData(len) | |
514 | |
515 func newDataList*[T: GPUType](data: seq[T]): DataList = | |
516 result = newDataList(getDataType[T]()) | |
225
d078b19bf531
fix: a ton of bug after refactoring gpu_data, start to add ideas for materials
Sam <sam@basx.dev>
parents:
224
diff
changeset
|
517 setValues[T](result, data) |
224 | 518 |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
519 func toGPUValue*[T: GPUType](value: T): DataValue = |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
520 result = DataValue(theType: getDataType[T]()) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
521 result.setValue(value) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
522 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
523 func toGPUValue*[T: GPUType](value: seq[T]): DataList = |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
524 result = newDataList[T](value.len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
525 result.setValue(value) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
526 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
527 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
|
528 when T is float32: value.float32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
529 elif T is float64: value.float64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
530 elif T is int8: value.int8 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
531 elif T is int16: value.int16 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
532 elif T is int32: value.int32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
533 elif T is int64: value.int64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
534 elif T is uint8: value.uint8 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
535 elif T is uint16: value.uint16 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
536 elif T is uint32: value.uint32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
537 elif T is uint64: value.uint64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
538 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
|
539 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
|
540 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
|
541 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
|
542 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
|
543 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
|
544 elif T is TVec2[int32]: value.vec2i32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
545 elif T is TVec2[int64]: value.vec2i64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
546 elif T is TVec3[int32]: value.vec3i32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
547 elif T is TVec3[int64]: value.vec3i64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
548 elif T is TVec4[int32]: value.vec4i32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
549 elif T is TVec4[int64]: value.vec4i64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
550 elif T is TVec2[uint32]: value.vec2u32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
551 elif T is TVec2[uint64]: value.vec2u64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
552 elif T is TVec3[uint32]: value.vec3u32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
553 elif T is TVec3[uint64]: value.vec3u64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
554 elif T is TVec4[uint32]: value.vec4u32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
555 elif T is TVec4[uint64]: value.vec4u64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
556 elif T is TVec2[float32]: value.vec2f32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
557 elif T is TVec2[float64]: value.vec2f64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
558 elif T is TVec3[float32]: value.vec3f32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
559 elif T is TVec3[float64]: value.vec3f64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
560 elif T is TVec4[float32]: value.vec4f32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
561 elif T is TVec4[float64]: value.vec4f64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
562 elif T is TMat2[float32]: value.mat2f32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
563 elif T is TMat2[float64]: value.mat2f64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
564 elif T is TMat23[float32]: value.mat23f |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
565 elif T is TMat23[float64]: value.mat23f64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
566 elif T is TMat32[float32]: value.mat32f32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
567 elif T is TMat32[float64]: value.mat32f64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
568 elif T is TMat3[float32]: value.mat3f32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
569 elif T is TMat3[float64]: value.mat3f64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
570 elif T is TMat34[float32]: value.mat34f32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
571 elif T is TMat34[float64]: value.mat34f64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
572 elif T is TMat43[float32]: value.mat43f32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
573 elif T is TMat43[float64]: value.mat43f64 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
574 elif T is TMat4[float32]: value.mat4f32 |
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
575 elif T is TMat4[float64]: value.mat4f64 |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
576 elif T is Texture: value.texture |
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
|
577 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
|
578 |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
579 func getValue*[T: GPUType|int|uint|float](value: DataList, i: int): T = |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
580 when T is float32: value.float32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
581 elif T is float64: value.float64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
582 elif T is int8: value.int8[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
583 elif T is int16: value.int16[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
584 elif T is int32: value.int32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
585 elif T is int64: value.int64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
586 elif T is uint8: value.uint8[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
587 elif T is uint16: value.uint16[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
588 elif T is uint32: value.uint32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
589 elif T is uint64: value.uint64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
590 elif T is int and sizeof(int) == sizeof(int32): value.int32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
591 elif T is int and sizeof(int) == sizeof(int64): value.int64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
592 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
593 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
594 elif T is float and sizeof(float) == sizeof(float32): value.float32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
595 elif T is float and sizeof(float) == sizeof(float64): value.float64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
596 elif T is TVec2[int32]: value.vec2i32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
597 elif T is TVec2[int64]: value.vec2i64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
598 elif T is TVec3[int32]: value.vec3i32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
599 elif T is TVec3[int64]: value.vec3i64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
600 elif T is TVec4[int32]: value.vec4i32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
601 elif T is TVec4[int64]: value.vec4i64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
602 elif T is TVec2[uint32]: value.vec2u32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
603 elif T is TVec2[uint64]: value.vec2u64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
604 elif T is TVec3[uint32]: value.vec3u32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
605 elif T is TVec3[uint64]: value.vec3u64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
606 elif T is TVec4[uint32]: value.vec4u32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
607 elif T is TVec4[uint64]: value.vec4u64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
608 elif T is TVec2[float32]: value.vec2f32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
609 elif T is TVec2[float64]: value.vec2f64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
610 elif T is TVec3[float32]: value.vec3f32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
611 elif T is TVec3[float64]: value.vec3f64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
612 elif T is TVec4[float32]: value.vec4f32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
613 elif T is TVec4[float64]: value.vec4f64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
614 elif T is TMat2[float32]: value.mat2f32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
615 elif T is TMat2[float64]: value.mat2f64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
616 elif T is TMat23[float32]: value.mat23f[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
617 elif T is TMat23[float64]: value.mat23f64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
618 elif T is TMat32[float32]: value.mat32f32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
619 elif T is TMat32[float64]: value.mat32f64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
620 elif T is TMat3[float32]: value.mat3f32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
621 elif T is TMat3[float64]: value.mat3f64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
622 elif T is TMat34[float32]: value.mat34f32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
623 elif T is TMat34[float64]: value.mat34f64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
624 elif T is TMat43[float32]: value.mat43f32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
625 elif T is TMat43[float64]: value.mat43f64[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
626 elif T is TMat4[float32]: value.mat4f32[i] |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
627 elif T is TMat4[float64]: value.mat4f64[i] |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
628 elif T is Texture: value.texture[i] |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
629 else: {. error: "Virtual datatype has no values" .} |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
630 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
631 func getRawData*(value: var DataValue): (pointer, int) = |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
632 result[1] = value.theType.size |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
633 case value.theType |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
634 of Float32: result[0] = addr value.float32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
635 of Float64: result[0] = addr value.float64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
636 of Int8: result[0] = addr value.int8 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
637 of Int16: result[0] = addr value.int16 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
638 of Int32: result[0] = addr value.int32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
639 of Int64: result[0] = addr value.int64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
640 of UInt8: result[0] = addr value.uint8 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
641 of UInt16: result[0] = addr value.uint16 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
642 of UInt32: result[0] = addr value.uint32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
643 of UInt64: result[0] = addr value.uint64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
644 of Vec2I32: result[0] = addr value.vec2i32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
645 of Vec2I64: result[0] = addr value.vec2i64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
646 of Vec3I32: result[0] = addr value.vec3i32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
647 of Vec3I64: result[0] = addr value.vec3i64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
648 of Vec4I32: result[0] = addr value.vec4i32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
649 of Vec4I64: result[0] = addr value.vec4i64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
650 of Vec2U32: result[0] = addr value.vec2u32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
651 of Vec2U64: result[0] = addr value.vec2u64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
652 of Vec3U32: result[0] = addr value.vec3u32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
653 of Vec3U64: result[0] = addr value.vec3u64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
654 of Vec4U32: result[0] = addr value.vec4u32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
655 of Vec4U64: result[0] = addr value.vec4u64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
656 of Vec2F32: result[0] = addr value.vec2f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
657 of Vec2F64: result[0] = addr value.vec2f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
658 of Vec3F32: result[0] = addr value.vec3f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
659 of Vec3F64: result[0] = addr value.vec3f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
660 of Vec4F32: result[0] = addr value.vec4f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
661 of Vec4F64: result[0] = addr value.vec4f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
662 of Mat2F32: result[0] = addr value.mat2f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
663 of Mat2F64: result[0] = addr value.mat2f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
664 of Mat23F32: result[0] = addr value.mat23f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
665 of Mat23F64: result[0] = addr value.mat23f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
666 of Mat32F32: result[0] = addr value.mat32f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
667 of Mat32F64: result[0] = addr value.mat32f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
668 of Mat3F32: result[0] = addr value.mat3f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
669 of Mat3F64: result[0] = addr value.mat3f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
670 of Mat34F32: result[0] = addr value.mat34f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
671 of Mat34F64: result[0] = addr value.mat34f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
672 of Mat43F32: result[0] = addr value.mat43f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
673 of Mat43F64: result[0] = addr value.mat43f64 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
674 of Mat4F32: result[0] = addr value.mat4f32 |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
675 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
|
676 of Sampler2D: result[0] = nil |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
677 |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
678 func getRawData*(value: var DataList): (pointer, int) = |
222
ddfc54036e00
add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents:
206
diff
changeset
|
679 if value.len == 0: |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
680 return (nil, 0) |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
681 result[1] = value.theType.size * value.len |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
682 case value.theType |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
683 of Float32: result[0] = value.float32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
684 of Float64: result[0] = value.float64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
685 of Int8: result[0] = value.int8.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
686 of Int16: result[0] = value.int16.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
687 of Int32: result[0] = value.int32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
688 of Int64: result[0] = value.int64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
689 of UInt8: result[0] = value.uint8.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
690 of UInt16: result[0] = value.uint16.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
691 of UInt32: result[0] = value.uint32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
692 of UInt64: result[0] = value.uint64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
693 of Vec2I32: result[0] = value.vec2i32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
694 of Vec2I64: result[0] = value.vec2i64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
695 of Vec3I32: result[0] = value.vec3i32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
696 of Vec3I64: result[0] = value.vec3i64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
697 of Vec4I32: result[0] = value.vec4i32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
698 of Vec4I64: result[0] = value.vec4i64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
699 of Vec2U32: result[0] = value.vec2u32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
700 of Vec2U64: result[0] = value.vec2u64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
701 of Vec3U32: result[0] = value.vec3u32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
702 of Vec3U64: result[0] = value.vec3u64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
703 of Vec4U32: result[0] = value.vec4u32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
704 of Vec4U64: result[0] = value.vec4u64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
705 of Vec2F32: result[0] = value.vec2f32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
706 of Vec2F64: result[0] = value.vec2f64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
707 of Vec3F32: result[0] = value.vec3f32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
708 of Vec3F64: result[0] = value.vec3f64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
709 of Vec4F32: result[0] = value.vec4f32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
710 of Vec4F64: result[0] = value.vec4f64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
711 of Mat2F32: result[0] = value.mat2f32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
712 of Mat2F64: result[0] = value.mat2f64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
713 of Mat23F32: result[0] = value.mat23f32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
714 of Mat23F64: result[0] = value.mat23f64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
715 of Mat32F32: result[0] = value.mat32f32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
716 of Mat32F64: result[0] = value.mat32f64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
717 of Mat3F32: result[0] = value.mat3f32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
718 of Mat3F64: result[0] = value.mat3f64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
719 of Mat34F32: result[0] = value.mat34f32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
720 of Mat34F64: result[0] = value.mat34f64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
721 of Mat43F32: result[0] = value.mat43f32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
722 of Mat43F64: result[0] = value.mat43f64.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
723 of Mat4F32: result[0] = value.mat4f32.toCPointer |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
724 of Mat4F64: result[0] = value.mat4f64.toCPointer |
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
|
725 of Sampler2D: result[0] = nil |
123
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
726 |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
727 func initData*(value: var DataList, len: int) = |
146 | 728 value.len = len |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
729 case value.theType |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
730 of Float32: value.float32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
731 of Float64: value.float64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
732 of Int8: value.int8.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
733 of Int16: value.int16.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
734 of Int32: value.int32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
735 of Int64: value.int64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
736 of UInt8: value.uint8.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
737 of UInt16: value.uint16.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
738 of UInt32: value.uint32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
739 of UInt64: value.uint64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
740 of Vec2I32: value.vec2i32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
741 of Vec2I64: value.vec2i64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
742 of Vec3I32: value.vec3i32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
743 of Vec3I64: value.vec3i64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
744 of Vec4I32: value.vec4i32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
745 of Vec4I64: value.vec4i64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
746 of Vec2U32: value.vec2u32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
747 of Vec2U64: value.vec2u64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
748 of Vec3U32: value.vec3u32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
749 of Vec3U64: value.vec3u64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
750 of Vec4U32: value.vec4u32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
751 of Vec4U64: value.vec4u64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
752 of Vec2F32: value.vec2f32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
753 of Vec2F64: value.vec2f64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
754 of Vec3F32: value.vec3f32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
755 of Vec3F64: value.vec3f64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
756 of Vec4F32: value.vec4f32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
757 of Vec4F64: value.vec4f64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
758 of Mat2F32: value.mat2f32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
759 of Mat2F64: value.mat2f64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
760 of Mat23F32: value.mat23f32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
761 of Mat23F64: value.mat23f64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
762 of Mat32F32: value.mat32f32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
763 of Mat32F64: value.mat32f64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
764 of Mat3F32: value.mat3f32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
765 of Mat3F64: value.mat3f64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
766 of Mat34F32: value.mat34f32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
767 of Mat34F64: value.mat34f64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
768 of Mat43F32: value.mat43f32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
769 of Mat43F64: value.mat43f64.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
770 of Mat4F32: value.mat4f32.setLen(len) |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
771 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
|
772 of Sampler2D: discard |
146 | 773 |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
774 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
|
775 when T is float32: value.float32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
776 elif T is float64: value.float64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
777 elif T is int8: value.int8 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
778 elif T is int16: value.int16 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
779 elif T is int32: value.int32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
780 elif T is int64: value.int64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
781 elif T is uint8: value.uint8 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
782 elif T is uint16: value.uint16 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
783 elif T is uint32: value.uint32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
784 elif T is uint64: value.uint64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
785 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
|
786 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
|
787 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
|
788 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
|
789 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
|
790 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
|
791 elif T is TVec2[int32]: value.vec2i32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
792 elif T is TVec2[int64]: value.vec2i64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
793 elif T is TVec3[int32]: value.vec3i32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
794 elif T is TVec3[int64]: value.vec3i64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
795 elif T is TVec4[int32]: value.vec4i32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
796 elif T is TVec4[int64]: value.vec4i64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
797 elif T is TVec2[uint32]: value.vec2u32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
798 elif T is TVec2[uint64]: value.vec2u64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
799 elif T is TVec3[uint32]: value.vec3u32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
800 elif T is TVec3[uint64]: value.vec3u64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
801 elif T is TVec4[uint32]: value.vec4u32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
802 elif T is TVec4[uint64]: value.vec4u64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
803 elif T is TVec2[float32]: value.vec2f32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
804 elif T is TVec2[float64]: value.vec2f64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
805 elif T is TVec3[float32]: value.vec3f32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
806 elif T is TVec3[float64]: value.vec3f64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
807 elif T is TVec4[float32]: value.vec4f32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
808 elif T is TVec4[float64]: value.vec4f64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
809 elif T is TMat2[float32]: value.mat2f32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
810 elif T is TMat2[float64]: value.mat2f64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
811 elif T is TMat23[float32]: value.mat23f32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
812 elif T is TMat23[float64]: value.mat23f64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
813 elif T is TMat32[float32]: value.mat32f32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
814 elif T is TMat32[float64]: value.mat32f64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
815 elif T is TMat3[float32]: value.mat3f32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
816 elif T is TMat3[float64]: value.mat3f64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
817 elif T is TMat34[float32]: value.mat34f32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
818 elif T is TMat34[float64]: value.mat34f64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
819 elif T is TMat43[float32]: value.mat43f32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
820 elif T is TMat43[float64]: value.mat43f64 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
821 elif T is TMat4[float32]: value.mat4f32 = data |
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
822 elif T is TMat4[float64]: value.mat4f64 = data |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
823 elif T is Texture: value.texture = 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
|
824 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
|
825 |
222
ddfc54036e00
add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents:
206
diff
changeset
|
826 func appendValues*[T: GPUType|int|uint|float](value: var DataList, data: seq[T]) = |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
827 value.len += data.len |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
828 when T is float32: value.float32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
829 elif T is float64: value.float64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
830 elif T is int8: value.int8.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
831 elif T is int16: value.int16.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
832 elif T is int32: value.int32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
833 elif T is int64: value.int64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
834 elif T is uint8: value.uint8.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
835 elif T is uint16: value.uint16.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
836 elif T is uint32: value.uint32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
837 elif T is uint64: value.uint64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
838 elif T is int and sizeof(int) == sizeof(int32): value.int32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
839 elif T is int and sizeof(int) == sizeof(int64): value.int64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
840 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
841 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
842 elif T is float and sizeof(float) == sizeof(float32): value.float32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
843 elif T is float and sizeof(float) == sizeof(float64): value.float64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
844 elif T is TVec2[int32]: value.vec2i32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
845 elif T is TVec2[int64]: value.vec2i64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
846 elif T is TVec3[int32]: value.vec3i32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
847 elif T is TVec3[int64]: value.vec3i64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
848 elif T is TVec4[int32]: value.vec4i32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
849 elif T is TVec4[int64]: value.vec4i64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
850 elif T is TVec2[uint32]: value.vec2u32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
851 elif T is TVec2[uint64]: value.vec2u64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
852 elif T is TVec3[uint32]: value.vec3u32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
853 elif T is TVec3[uint64]: value.vec3u64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
854 elif T is TVec4[uint32]: value.vec4u32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
855 elif T is TVec4[uint64]: value.vec4u64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
856 elif T is TVec2[float32]: value.vec2f32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
857 elif T is TVec2[float64]: value.vec2f64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
858 elif T is TVec3[float32]: value.vec3f32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
859 elif T is TVec3[float64]: value.vec3f64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
860 elif T is TVec4[float32]: value.vec4f32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
861 elif T is TVec4[float64]: value.vec4f64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
862 elif T is TMat2[float32]: value.mat2f32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
863 elif T is TMat2[float64]: value.mat2f64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
864 elif T is TMat23[float32]: value.mat23f32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
865 elif T is TMat23[float64]: value.mat23f64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
866 elif T is TMat32[float32]: value.mat32f32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
867 elif T is TMat32[float64]: value.mat32f64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
868 elif T is TMat3[float32]: value.mat3f32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
869 elif T is TMat3[float64]: value.mat3f64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
870 elif T is TMat34[float32]: value.mat34f32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
871 elif T is TMat34[float64]: value.mat34f64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
872 elif T is TMat43[float32]: value.mat43f32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
873 elif T is TMat43[float64]: value.mat43f64.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
874 elif T is TMat4[float32]: value.mat4f32.add data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
875 elif T is TMat4[float64]: value.mat4f64.add data |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
876 elif T is Texture: value.texture.add data |
222
ddfc54036e00
add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents:
206
diff
changeset
|
877 else: {. error: "Virtual datatype has no values" .} |
ddfc54036e00
add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents:
206
diff
changeset
|
878 |
ddfc54036e00
add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents:
206
diff
changeset
|
879 func appendValues*(value: var DataList, data: DataList) = |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
880 assert value.theType == data.theType |
222
ddfc54036e00
add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents:
206
diff
changeset
|
881 value.len += data.len |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
882 case value.theType: |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
883 of Float32: value.float32.add data.float32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
884 of Float64: value.float64.add data.float64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
885 of Int8: value.int8.add data.int8 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
886 of Int16: value.int16.add data.int16 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
887 of Int32: value.int32.add data.int32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
888 of Int64: value.int64.add data.int64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
889 of UInt8: value.uint8.add data.uint8 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
890 of UInt16: value.uint16.add data.uint16 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
891 of UInt32: value.uint32.add data.uint32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
892 of UInt64: value.uint64.add data.uint64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
893 of Vec2I32: value.vec2i32.add data.vec2i32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
894 of Vec2I64: value.vec2i64.add data.vec2i64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
895 of Vec3I32: value.vec3i32.add data.vec3i32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
896 of Vec3I64: value.vec3i64.add data.vec3i64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
897 of Vec4I32: value.vec4i32.add data.vec4i32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
898 of Vec4I64: value.vec4i64.add data.vec4i64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
899 of Vec2U32: value.vec2u32.add data.vec2u32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
900 of Vec2U64: value.vec2u64.add data.vec2u64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
901 of Vec3U32: value.vec3u32.add data.vec3u32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
902 of Vec3U64: value.vec3u64.add data.vec3u64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
903 of Vec4U32: value.vec4u32.add data.vec4u32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
904 of Vec4U64: value.vec4u64.add data.vec4u64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
905 of Vec2F32: value.vec2f32.add data.vec2f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
906 of Vec2F64: value.vec2f64.add data.vec2f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
907 of Vec3F32: value.vec3f32.add data.vec3f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
908 of Vec3F64: value.vec3f64.add data.vec3f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
909 of Vec4F32: value.vec4f32.add data.vec4f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
910 of Vec4F64: value.vec4f64.add data.vec4f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
911 of Mat2F32: value.mat2f32.add data.mat2f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
912 of Mat2F64: value.mat2f64.add data.mat2f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
913 of Mat23F32: value.mat23f32.add data.mat23f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
914 of Mat23F64: value.mat23f64.add data.mat23f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
915 of Mat32F32: value.mat32f32.add data.mat32f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
916 of Mat32F64: value.mat32f64.add data.mat32f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
917 of Mat3F32: value.mat3f32.add data.mat3f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
918 of Mat3F64: value.mat3f64.add data.mat3f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
919 of Mat34F32: value.mat34f32.add data.mat34f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
920 of Mat34F64: value.mat34f64.add data.mat34f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
921 of Mat43F32: value.mat43f32.add data.mat43f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
922 of Mat43F64: value.mat43f64.add data.mat43f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
923 of Mat4F32: value.mat4f32.add data.mat4f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
924 of Mat4F64: value.mat4f64.add data.mat4f64 |
222
ddfc54036e00
add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents:
206
diff
changeset
|
925 else: raise newException(Exception, &"Unsupported data type for GPU data:" ) |
ddfc54036e00
add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents:
206
diff
changeset
|
926 |
266
fd1a95f433d1
add: better material loading system, still far from great
Sam <sam@basx.dev>
parents:
231
diff
changeset
|
927 func appendValue*(value: var DataList, data: DataValue) = |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
928 assert value.theType == data.theType, &"appendValue expected {value.theType} but got {data.theType}" |
266
fd1a95f433d1
add: better material loading system, still far from great
Sam <sam@basx.dev>
parents:
231
diff
changeset
|
929 value.len += 1 |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
930 case value.theType: |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
931 of Float32: value.float32.add data.float32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
932 of Float64: value.float64.add data.float64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
933 of Int8: value.int8.add data.int8 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
934 of Int16: value.int16.add data.int16 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
935 of Int32: value.int32.add data.int32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
936 of Int64: value.int64.add data.int64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
937 of UInt8: value.uint8.add data.uint8 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
938 of UInt16: value.uint16.add data.uint16 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
939 of UInt32: value.uint32.add data.uint32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
940 of UInt64: value.uint64.add data.uint64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
941 of Vec2I32: value.vec2i32.add data.vec2i32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
942 of Vec2I64: value.vec2i64.add data.vec2i64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
943 of Vec3I32: value.vec3i32.add data.vec3i32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
944 of Vec3I64: value.vec3i64.add data.vec3i64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
945 of Vec4I32: value.vec4i32.add data.vec4i32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
946 of Vec4I64: value.vec4i64.add data.vec4i64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
947 of Vec2U32: value.vec2u32.add data.vec2u32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
948 of Vec2U64: value.vec2u64.add data.vec2u64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
949 of Vec3U32: value.vec3u32.add data.vec3u32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
950 of Vec3U64: value.vec3u64.add data.vec3u64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
951 of Vec4U32: value.vec4u32.add data.vec4u32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
952 of Vec4U64: value.vec4u64.add data.vec4u64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
953 of Vec2F32: value.vec2f32.add data.vec2f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
954 of Vec2F64: value.vec2f64.add data.vec2f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
955 of Vec3F32: value.vec3f32.add data.vec3f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
956 of Vec3F64: value.vec3f64.add data.vec3f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
957 of Vec4F32: value.vec4f32.add data.vec4f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
958 of Vec4F64: value.vec4f64.add data.vec4f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
959 of Mat2F32: value.mat2f32.add data.mat2f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
960 of Mat2F64: value.mat2f64.add data.mat2f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
961 of Mat23F32: value.mat23f32.add data.mat23f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
962 of Mat23F64: value.mat23f64.add data.mat23f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
963 of Mat32F32: value.mat32f32.add data.mat32f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
964 of Mat32F64: value.mat32f64.add data.mat32f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
965 of Mat3F32: value.mat3f32.add data.mat3f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
966 of Mat3F64: value.mat3f64.add data.mat3f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
967 of Mat34F32: value.mat34f32.add data.mat34f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
968 of Mat34F64: value.mat34f64.add data.mat34f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
969 of Mat43F32: value.mat43f32.add data.mat43f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
970 of Mat43F64: value.mat43f64.add data.mat43f64 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
971 of Mat4F32: value.mat4f32.add data.mat4f32 |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
972 of Mat4F64: value.mat4f64.add data.mat4f64 |
266
fd1a95f433d1
add: better material loading system, still far from great
Sam <sam@basx.dev>
parents:
231
diff
changeset
|
973 else: raise newException(Exception, &"Unsupported data type for GPU data:" ) |
fd1a95f433d1
add: better material loading system, still far from great
Sam <sam@basx.dev>
parents:
231
diff
changeset
|
974 |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
975 func setValue*[T: GPUType|int|uint|float](value: var DataList, data: seq[T]) = |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
976 when T is float32: value.float32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
977 elif T is float64: value.float64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
978 elif T is int8: value.int8 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
979 elif T is int16: value.int16 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
980 elif T is int32: value.int32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
981 elif T is int64: value.int64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
982 elif T is uint8: value.uint8 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
983 elif T is uint16: value.uint16 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
984 elif T is uint32: value.uint32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
985 elif T is uint64: value.uint64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
986 elif T is int and sizeof(int) == sizeof(int32): value.int32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
987 elif T is int and sizeof(int) == sizeof(int64): value.int64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
988 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
989 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
990 elif T is float and sizeof(float) == sizeof(float32): value.float32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
991 elif T is float and sizeof(float) == sizeof(float64): value.float64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
992 elif T is TVec2[int32]: value.vec2i32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
993 elif T is TVec2[int64]: value.vec2i64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
994 elif T is TVec3[int32]: value.vec3i32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
995 elif T is TVec3[int64]: value.vec3i64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
996 elif T is TVec4[int32]: value.vec4i32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
997 elif T is TVec4[int64]: value.vec4i64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
998 elif T is TVec2[uint32]: value.vec2u32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
999 elif T is TVec2[uint64]: value.vec2u64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1000 elif T is TVec3[uint32]: value.vec3u32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1001 elif T is TVec3[uint64]: value.vec3u64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1002 elif T is TVec4[uint32]: value.vec4u32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1003 elif T is TVec4[uint64]: value.vec4u64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1004 elif T is TVec2[float32]: value.vec2f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1005 elif T is TVec2[float64]: value.vec2f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1006 elif T is TVec3[float32]: value.vec3f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1007 elif T is TVec3[float64]: value.vec3f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1008 elif T is TVec4[float32]: value.vec4f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1009 elif T is TVec4[float64]: value.vec4f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1010 elif T is TMat2[float32]: value.mat2f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1011 elif T is TMat2[float64]: value.mat2f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1012 elif T is TMat23[float32]: value.mat23f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1013 elif T is TMat23[float64]: value.mat23f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1014 elif T is TMat32[float32]: value.mat32f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1015 elif T is TMat32[float64]: value.mat32f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1016 elif T is TMat3[float32]: value.mat3f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1017 elif T is TMat3[float64]: value.mat3f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1018 elif T is TMat34[float32]: value.mat34f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1019 elif T is TMat34[float64]: value.mat34f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1020 elif T is TMat43[float32]: value.mat43f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1021 elif T is TMat43[float64]: value.mat43f64 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1022 elif T is TMat4[float32]: value.mat4f32 = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1023 elif T is TMat4[float64]: value.mat4f64 = data |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
1024 elif T is Texture: value.texture = data |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1025 else: {. error: "Virtual datatype has no values" .} |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1026 |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
1027 func setValue*[T: GPUType|int|uint|float](value: var DataList, i: int, data: T) = |
123
55be3579dc30
did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents:
122
diff
changeset
|
1028 assert i < value.len |
330
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1029 when T is float32: value.float32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1030 elif T is float64: value.float64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1031 elif T is int8: value.int8[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1032 elif T is int16: value.int16[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1033 elif T is int32: value.int32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1034 elif T is int64: value.int64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1035 elif T is uint8: value.uint8[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1036 elif T is uint16: value.uint16[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1037 elif T is uint32: value.uint32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1038 elif T is uint64: value.uint64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1039 elif T is int and sizeof(int) == sizeof(int32): value.int32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1040 elif T is int and sizeof(int) == sizeof(int64): value.int64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1041 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1042 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1043 elif T is float and sizeof(float) == sizeof(float32): value.float32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1044 elif T is float and sizeof(float) == sizeof(float64): value.float64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1045 elif T is TVec2[int32]: value.vec2i32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1046 elif T is TVec2[int64]: value.vec2i64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1047 elif T is TVec3[int32]: value.vec3i32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1048 elif T is TVec3[int64]: value.vec3i64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1049 elif T is TVec4[int32]: value.vec4i32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1050 elif T is TVec4[int64]: value.vec4i64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1051 elif T is TVec2[uint32]: value.vec2u32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1052 elif T is TVec2[uint64]: value.vec2u64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1053 elif T is TVec3[uint32]: value.vec3u32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1054 elif T is TVec3[uint64]: value.vec3u64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1055 elif T is TVec4[uint32]: value.vec4u32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1056 elif T is TVec4[uint64]: value.vec4u64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1057 elif T is TVec2[float32]: value.vec2f32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1058 elif T is TVec2[float64]: value.vec2f64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1059 elif T is TVec3[float32]: value.vec3f32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1060 elif T is TVec3[float64]: value.vec3f64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1061 elif T is TVec4[float32]: value.vec4f32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1062 elif T is TVec4[float64]: value.vec4f64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1063 elif T is TMat2[float32]: value.mat2f32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1064 elif T is TMat2[float64]: value.mat2f64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1065 elif T is TMat23[float32]: value.mat23f32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1066 elif T is TMat23[float64]: value.mat23f64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1067 elif T is TMat32[float32]: value.mat32f32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1068 elif T is TMat32[float64]: value.mat32f64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1069 elif T is TMat3[float32]: value.mat3f32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1070 elif T is TMat3[float64]: value.mat3f64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1071 elif T is TMat34[float32]: value.mat34f32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1072 elif T is TMat34[float64]: value.mat34f64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1073 elif T is TMat43[float32]: value.mat43f32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1074 elif T is TMat43[float64]: value.mat43f64[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1075 elif T is TMat4[float32]: value.mat4f32[i] = data |
04531bec3583
did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents:
329
diff
changeset
|
1076 elif T is TMat4[float64]: value.mat4f64[i] = data |
333
27aaf43e18b4
fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents:
330
diff
changeset
|
1077 elif T is Texture: value.texture[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
|
1078 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
|
1079 |
111 | 1080 const TYPEMAP = { |
1081 Float32: VK_FORMAT_R32_SFLOAT, | |
1082 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
|
1083 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
|
1084 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
|
1085 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
|
1086 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
|
1087 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
|
1088 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
|
1089 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
|
1090 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
|
1091 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
|
1092 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
|
1093 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
|
1094 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
|
1095 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
|
1096 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
|
1097 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
|
1098 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
|
1099 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
|
1100 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
|
1101 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
|
1102 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
|
1103 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
|
1104 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
|
1105 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
|
1106 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
|
1107 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
|
1108 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
|
1109 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
|
1110 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
|
1111 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
|
1112 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
|
1113 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
|
1114 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
|
1115 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
|
1116 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
|
1117 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
|
1118 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
|
1119 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
|
1120 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
|
1121 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
|
1122 Mat4F64: VK_FORMAT_R64G64B64A64_SFLOAT, |
111 | 1123 }.toTable |
1124 | |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1125 func getVkFormat*(theType: DataType): VkFormat = |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1126 TYPEMAP[theType] |
111 | 1127 |
1128 # from https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap15.html | |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1129 func nLocationSlots*(theType: DataType): int = |
111 | 1130 #[ |
1131 single location: | |
1132 16-bit scalar and vector types, and | |
1133 32-bit scalar and vector types, and | |
1134 64-bit scalar and 2-component vector types. | |
1135 two locations | |
1136 64-bit three- and four-component vectors | |
1137 ]# | |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1138 case theType: |
111 | 1139 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
|
1140 of Float64: 1 |
111 | 1141 of Int8: 1 |
1142 of Int16: 1 | |
1143 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
|
1144 of Int64: 1 |
111 | 1145 of UInt8: 1 |
1146 of UInt16: 1 | |
1147 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
|
1148 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
|
1149 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
|
1150 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
|
1151 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
|
1152 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
|
1153 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
|
1154 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
|
1155 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
|
1156 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
|
1157 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
|
1158 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
|
1159 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
|
1160 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
|
1161 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
|
1162 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
|
1163 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
|
1164 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
|
1165 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
|
1166 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
|
1167 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
|
1168 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
|
1169 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
|
1170 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
|
1171 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
|
1172 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
|
1173 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
|
1174 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
|
1175 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
|
1176 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
|
1177 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
|
1178 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
|
1179 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
|
1180 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
|
1181 of Sampler2D: 1 |
111 | 1182 |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1183 func glslType*(theType: DataType): string = |
111 | 1184 # todo: likely not correct as we would need to enable some |
1185 # extensions somewhere (Vulkan/GLSL compiler?) to have | |
1186 # everything work as intended. Or maybe the GPU driver does | |
1187 # some automagic conversion stuf.. | |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1188 case theType: |
121
dfaddaf96f09
did: refactor GPU data types, more generic, prepare to use for decriptors/uniforms
Sam <sam@basx.dev>
parents:
120
diff
changeset
|
1189 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
|
1190 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
|
1191 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
|
1192 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
|
1193 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
|
1194 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
|
1195 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
|
1196 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
|
1197 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
|
1198 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
|
1199 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
|
1200 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
|
1201 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
|
1202 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
|
1203 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
|
1204 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
|
1205 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
|
1206 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
|
1207 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
|
1208 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
|
1209 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
|
1210 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
|
1211 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
|
1212 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
|
1213 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
|
1214 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
|
1215 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
|
1216 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
|
1217 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
|
1218 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
|
1219 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
|
1220 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
|
1221 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
|
1222 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
|
1223 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
|
1224 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
|
1225 of Sampler2D: "sampler2D" |
111 | 1226 |
321
30117d8f0052
did next step in renderpipeline-refactoring, using shaderconfiguration objects instead for less ambigious shader-pipeline configuration
Sam <sam@basx.dev>
parents:
267
diff
changeset
|
1227 func glslInput*(group: openArray[ShaderAttribute]): seq[string] = |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
1228 if group.len == 0: |
111 | 1229 return @[] |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
1230 var i = 0 |
137 | 1231 for attribute in group: |
227 | 1232 assert attribute.arrayCount == 0, "arrays not supported for shader vertex attributes" |
267
a107d9ef1a1f
add: flat attribute for shader in/outputs
Sam <sam@basx.dev>
parents:
266
diff
changeset
|
1233 let flat = if attribute.noInterpolation: "flat " else: "" |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1234 result.add &"layout(location = {i}) {flat}in {attribute.theType.glslType} {attribute.name};" |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1235 for j in 0 ..< attribute.theType.numberOfVertexInputAttributeDescriptors: |
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1236 i += attribute.theType.nLocationSlots |
111 | 1237 |
321
30117d8f0052
did next step in renderpipeline-refactoring, using shaderconfiguration objects instead for less ambigious shader-pipeline configuration
Sam <sam@basx.dev>
parents:
267
diff
changeset
|
1238 func glslUniforms*(group: openArray[ShaderAttribute], blockName="Uniforms", binding: int): seq[string] = |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
1239 if group.len == 0: |
111 | 1240 return @[] |
1241 # currently only a single uniform block supported, therefore binding = 0 | |
229
7741bca03e7c
add: support for struct members to be array
Sam <sam@basx.dev>
parents:
227
diff
changeset
|
1242 result.add(&"layout(std430, binding = {binding}) uniform T{blockName} {{") |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
1243 for attribute in group: |
227 | 1244 var arrayDecl = "" |
1245 if attribute.arrayCount > 0: | |
1246 arrayDecl = &"[{attribute.arrayCount}]" | |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1247 result.add(&" {attribute.theType.glslType} {attribute.name}{arrayDecl};") |
111 | 1248 result.add(&"}} {blockName};") |
1249 | |
321
30117d8f0052
did next step in renderpipeline-refactoring, using shaderconfiguration objects instead for less ambigious shader-pipeline configuration
Sam <sam@basx.dev>
parents:
267
diff
changeset
|
1250 func glslSamplers*(group: openArray[ShaderAttribute], basebinding: int): seq[string] = |
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
|
1251 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
|
1252 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
|
1253 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
|
1254 for attribute in group: |
201 | 1255 var arrayDecl = "" |
1256 if attribute.arrayCount > 0: | |
1257 arrayDecl = &"[{attribute.arrayCount}]" | |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1258 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
|
1259 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
|
1260 |
321
30117d8f0052
did next step in renderpipeline-refactoring, using shaderconfiguration objects instead for less ambigious shader-pipeline configuration
Sam <sam@basx.dev>
parents:
267
diff
changeset
|
1261 func glslOutput*(group: openArray[ShaderAttribute]): seq[string] = |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
1262 if group.len == 0: |
111 | 1263 return @[] |
326
4ec852355750
fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents:
323
diff
changeset
|
1264 var i = 0 |
122
506090173619
did: implement uniforms, some refactoring
Sam <sam@basx.dev>
parents:
121
diff
changeset
|
1265 for attribute in group: |
227 | 1266 assert attribute.arrayCount == 0, "arrays not supported for outputs" |
267
a107d9ef1a1f
add: flat attribute for shader in/outputs
Sam <sam@basx.dev>
parents:
266
diff
changeset
|
1267 let flat = if attribute.noInterpolation: "flat " else: "" |
329
69e18f69713b
add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents:
326
diff
changeset
|
1268 result.add &"layout(location = {i}) {flat}out {attribute.theType.glslType} {attribute.name};" |
111 | 1269 i += 1 |