@@ -51,126 +51,133 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createCube(const h
51
51
});
52
52
}
53
53
54
- //
55
- const hlsl::float32_t3 pos[8 ] =
56
- {
57
- hlsl::float32_t3 (-0 .5f ,-0 .5f , 0 .5f ) * size,
58
- hlsl::float32_t3 (0 .5f ,-0 .5f , 0 .5f ) * size,
59
- hlsl::float32_t3 (0 .5f , 0 .5f , 0 .5f ) * size,
60
- hlsl::float32_t3 (-0 .5f , 0 .5f , 0 .5f ) * size,
61
- hlsl::float32_t3 (0 .5f ,-0 .5f ,-0 .5f ) * size,
62
- hlsl::float32_t3 (-0 .5f , 0 .5f ,-0 .5f ) * size,
63
- hlsl::float32_t3 (-0 .5f ,-0 .5f ,-0 .5f ) * size,
64
- hlsl::float32_t3 (0 .5f , 0 .5f ,-0 .5f ) * size
65
- };
66
- constexpr auto Dim = 4 ; // for now because no reliable RGB10A2 encode and scant support for 24-bit UTB formats
67
- const hlsl::vector<int8_t ,Dim> norm[6 ] =
68
- {
69
- hlsl::vector<int8_t ,Dim>(0 , 0 , 127 , 0 ),
70
- hlsl::vector<int8_t ,Dim>(127 , 0 , 0 , 0 ),
71
- hlsl::vector<int8_t ,Dim>(0 , 0 ,-127 , 0 ),
72
- hlsl::vector<int8_t ,Dim>(-127 , 0 , 0 , 0 ),
73
- hlsl::vector<int8_t ,Dim>(0 , 127 , 0 , 0 ),
74
- hlsl::vector<int8_t ,Dim>(0 ,-127 , 0 , 0 )
75
- };
76
- const hlsl::vector<uint8_t ,2 > uv[4 ] =
77
- {
78
- hlsl::vector<uint8_t ,2 >( 0 ,127 ),
79
- hlsl::vector<uint8_t ,2 >(127 ,127 ),
80
- hlsl::vector<uint8_t ,2 >(127 , 0 ),
81
- hlsl::vector<uint8_t ,2 >( 0 , 0 )
82
- };
54
+ constexpr auto CubeUniqueVertices = 24 ;
83
55
84
56
// Create vertex attributes with NONE usage because we have no clue how they'll be used
85
57
hlsl::float32_t3* positions;
86
- hlsl::vector<int8_t ,Dim>* normals;
58
+ // for now because no reliable RGB10A2 encode and scant support for 24-bit UTB formats
59
+ hlsl::vector<int8_t ,4 >* normals;
87
60
hlsl::vector<uint8_t ,2 >* uvs;
88
61
{
89
62
{
90
- auto buff = ICPUBuffer::create ({sizeof (pos),IBuffer::EUF_NONE});
63
+ constexpr auto AttrSize = sizeof (decltype (*positions));
64
+ auto buff = ICPUBuffer::create ({AttrSize*CubeUniqueVertices,IBuffer::EUF_NONE});
91
65
positions = reinterpret_cast <decltype (positions)>(buff->getPointer ());
92
66
shapes::AABB<4 ,float32_t > aabb;
93
67
aabb.maxVx = float32_t4 (size*0 .5f ,0 .f );
94
68
aabb.minVx = -aabb.maxVx ;
95
69
retval->setPositionView ({
96
70
.composed = {
97
71
.encodedDataRange = {.f32 =aabb},
98
- .stride = sizeof (pos[ 0 ]) ,
72
+ .stride = AttrSize ,
99
73
.format = EF_R32G32B32_SFLOAT,
100
74
.rangeFormat = IGeometryBase::EAABBFormat::F32
101
75
},
102
- .src = {.offset =0 ,.size =sizeof (pos ),.buffer = std::move (buff)}
76
+ .src = {.offset =0 ,.size =buff-> getSize ( ),.buffer = std::move (buff)}
103
77
});
104
78
}
105
79
{
106
- auto buff = ICPUBuffer::create ({sizeof (norm),IBuffer::EUF_NONE});
80
+ constexpr auto AttrSize = sizeof (decltype (*normals));
81
+ auto buff = ICPUBuffer::create ({AttrSize*CubeUniqueVertices,IBuffer::EUF_NONE});
107
82
normals = reinterpret_cast <decltype (normals)>(buff->getPointer ());
108
83
shapes::AABB<4 ,int8_t > aabb;
109
84
aabb.maxVx = hlsl::vector<int8_t ,4 >(127 ,127 ,127 ,0 );
110
85
aabb.minVx = -aabb.maxVx ;
111
- retval->setPositionView ({
86
+ retval->setNormalView ({
112
87
.composed = {
113
88
.encodedDataRange = {.s8 =aabb},
114
- .stride = sizeof (norm[ 0 ]) ,
89
+ .stride = AttrSize ,
115
90
.format = EF_R8G8B8A8_SNORM,
116
91
.rangeFormat = IGeometryBase::EAABBFormat::S8_NORM
117
92
},
118
- .src = {.offset =0 ,.size =sizeof (norm ),.buffer =std::move (buff)}
93
+ .src = {.offset =0 ,.size =buff-> getSize ( ),.buffer =std::move (buff)}
119
94
});
120
95
}
121
96
{
122
- auto buff = ICPUBuffer::create ({sizeof (uv),IBuffer::EUF_NONE});
97
+ constexpr auto AttrSize = sizeof (decltype (*uvs));
98
+ auto buff = ICPUBuffer::create ({AttrSize*CubeUniqueVertices,IBuffer::EUF_NONE});
123
99
uvs = reinterpret_cast <decltype (uvs)>(buff->getPointer ());
124
100
shapes::AABB<4 ,uint8_t > aabb;
125
101
aabb.minVx = hlsl::vector<uint8_t ,4 >(0 ,0 ,0 ,0 );
126
102
aabb.maxVx = hlsl::vector<uint8_t ,4 >(127 ,127 ,0 ,0 );
127
- retval->setPositionView ({
103
+ retval->getAuxAttributeViews ()-> push_back ({
128
104
.composed = {
129
105
.encodedDataRange = {.u8 =aabb},
130
- .stride = sizeof (uv[ 0 ]) ,
106
+ .stride = AttrSize ,
131
107
.format = EF_R8G8_UNORM,
132
108
.rangeFormat = IGeometryBase::EAABBFormat::U8_NORM
133
109
},
134
- .src = {.offset =0 ,.size =sizeof (uv ),.buffer =std::move (buff)}
110
+ .src = {.offset =0 ,.size =buff-> getSize ( ),.buffer =std::move (buff)}
135
111
});
136
112
}
137
113
}
138
114
139
115
//
140
- positions[0 ] = hlsl::float32_t3 (pos[0 ][0 ], pos[0 ][1 ], pos[0 ][2 ]);
141
- positions[1 ] = hlsl::float32_t3 (pos[1 ][0 ], pos[1 ][1 ], pos[1 ][2 ]);
142
- positions[2 ] = hlsl::float32_t3 (pos[2 ][0 ], pos[2 ][1 ], pos[2 ][2 ]);
143
- positions[3 ] = hlsl::float32_t3 (pos[3 ][0 ], pos[3 ][1 ], pos[3 ][2 ]);
144
- positions[4 ] = hlsl::float32_t3 (pos[1 ][0 ], pos[1 ][1 ], pos[1 ][2 ]);
145
- positions[5 ] = hlsl::float32_t3 (pos[4 ][0 ], pos[4 ][1 ], pos[4 ][2 ]);
146
- positions[6 ] = hlsl::float32_t3 (pos[7 ][0 ], pos[7 ][1 ], pos[7 ][2 ]);
147
- positions[7 ] = hlsl::float32_t3 (pos[2 ][0 ], pos[2 ][1 ], pos[2 ][2 ]);
148
- positions[8 ] = hlsl::float32_t3 (pos[4 ][0 ], pos[4 ][1 ], pos[4 ][2 ]);
149
- positions[9 ] = hlsl::float32_t3 (pos[6 ][0 ], pos[6 ][1 ], pos[6 ][2 ]);
150
- positions[10 ] = hlsl::float32_t3 (pos[5 ][0 ], pos[5 ][1 ], pos[5 ][2 ]);
151
- positions[11 ] = hlsl::float32_t3 (pos[7 ][0 ], pos[7 ][1 ], pos[7 ][2 ]);
152
- positions[12 ] = hlsl::float32_t3 (pos[6 ][0 ], pos[6 ][1 ], pos[6 ][2 ]);
153
- positions[13 ] = hlsl::float32_t3 (pos[0 ][0 ], pos[0 ][1 ], pos[0 ][2 ]);
154
- positions[14 ] = hlsl::float32_t3 (pos[3 ][0 ], pos[3 ][1 ], pos[3 ][2 ]);
155
- positions[15 ] = hlsl::float32_t3 (pos[5 ][0 ], pos[5 ][1 ], pos[5 ][2 ]);
156
- positions[16 ] = hlsl::float32_t3 (pos[3 ][0 ], pos[3 ][1 ], pos[3 ][2 ]);
157
- positions[17 ] = hlsl::float32_t3 (pos[2 ][0 ], pos[2 ][1 ], pos[2 ][2 ]);
158
- positions[18 ] = hlsl::float32_t3 (pos[7 ][0 ], pos[7 ][1 ], pos[7 ][2 ]);
159
- positions[19 ] = hlsl::float32_t3 (pos[5 ][0 ], pos[5 ][1 ], pos[5 ][2 ]);
160
- positions[20 ] = hlsl::float32_t3 (pos[0 ][0 ], pos[0 ][1 ], pos[0 ][2 ]);
161
- positions[21 ] = hlsl::float32_t3 (pos[6 ][0 ], pos[6 ][1 ], pos[6 ][2 ]);
162
- positions[22 ] = hlsl::float32_t3 (pos[4 ][0 ], pos[4 ][1 ], pos[4 ][2 ]);
163
- positions[23 ] = hlsl::float32_t3 (pos[1 ][0 ], pos[1 ][1 ], pos[1 ][2 ]);
116
+ {
117
+ const hlsl::float32_t3 pos[8 ] =
118
+ {
119
+ hlsl::float32_t3 (-0 .5f ,-0 .5f , 0 .5f ) * size,
120
+ hlsl::float32_t3 (0 .5f ,-0 .5f , 0 .5f ) * size,
121
+ hlsl::float32_t3 (0 .5f , 0 .5f , 0 .5f ) * size,
122
+ hlsl::float32_t3 (-0 .5f , 0 .5f , 0 .5f ) * size,
123
+ hlsl::float32_t3 (0 .5f ,-0 .5f ,-0 .5f ) * size,
124
+ hlsl::float32_t3 (-0 .5f , 0 .5f ,-0 .5f ) * size,
125
+ hlsl::float32_t3 (-0 .5f ,-0 .5f ,-0 .5f ) * size,
126
+ hlsl::float32_t3 (0 .5f , 0 .5f ,-0 .5f ) * size
127
+ };
128
+ positions[0 ] = hlsl::float32_t3 (pos[0 ][0 ], pos[0 ][1 ], pos[0 ][2 ]);
129
+ positions[1 ] = hlsl::float32_t3 (pos[1 ][0 ], pos[1 ][1 ], pos[1 ][2 ]);
130
+ positions[2 ] = hlsl::float32_t3 (pos[2 ][0 ], pos[2 ][1 ], pos[2 ][2 ]);
131
+ positions[3 ] = hlsl::float32_t3 (pos[3 ][0 ], pos[3 ][1 ], pos[3 ][2 ]);
132
+ positions[4 ] = hlsl::float32_t3 (pos[1 ][0 ], pos[1 ][1 ], pos[1 ][2 ]);
133
+ positions[5 ] = hlsl::float32_t3 (pos[4 ][0 ], pos[4 ][1 ], pos[4 ][2 ]);
134
+ positions[6 ] = hlsl::float32_t3 (pos[7 ][0 ], pos[7 ][1 ], pos[7 ][2 ]);
135
+ positions[7 ] = hlsl::float32_t3 (pos[2 ][0 ], pos[2 ][1 ], pos[2 ][2 ]);
136
+ positions[8 ] = hlsl::float32_t3 (pos[4 ][0 ], pos[4 ][1 ], pos[4 ][2 ]);
137
+ positions[9 ] = hlsl::float32_t3 (pos[6 ][0 ], pos[6 ][1 ], pos[6 ][2 ]);
138
+ positions[10 ] = hlsl::float32_t3 (pos[5 ][0 ], pos[5 ][1 ], pos[5 ][2 ]);
139
+ positions[11 ] = hlsl::float32_t3 (pos[7 ][0 ], pos[7 ][1 ], pos[7 ][2 ]);
140
+ positions[12 ] = hlsl::float32_t3 (pos[6 ][0 ], pos[6 ][1 ], pos[6 ][2 ]);
141
+ positions[13 ] = hlsl::float32_t3 (pos[0 ][0 ], pos[0 ][1 ], pos[0 ][2 ]);
142
+ positions[14 ] = hlsl::float32_t3 (pos[3 ][0 ], pos[3 ][1 ], pos[3 ][2 ]);
143
+ positions[15 ] = hlsl::float32_t3 (pos[5 ][0 ], pos[5 ][1 ], pos[5 ][2 ]);
144
+ positions[16 ] = hlsl::float32_t3 (pos[3 ][0 ], pos[3 ][1 ], pos[3 ][2 ]);
145
+ positions[17 ] = hlsl::float32_t3 (pos[2 ][0 ], pos[2 ][1 ], pos[2 ][2 ]);
146
+ positions[18 ] = hlsl::float32_t3 (pos[7 ][0 ], pos[7 ][1 ], pos[7 ][2 ]);
147
+ positions[19 ] = hlsl::float32_t3 (pos[5 ][0 ], pos[5 ][1 ], pos[5 ][2 ]);
148
+ positions[20 ] = hlsl::float32_t3 (pos[0 ][0 ], pos[0 ][1 ], pos[0 ][2 ]);
149
+ positions[21 ] = hlsl::float32_t3 (pos[6 ][0 ], pos[6 ][1 ], pos[6 ][2 ]);
150
+ positions[22 ] = hlsl::float32_t3 (pos[4 ][0 ], pos[4 ][1 ], pos[4 ][2 ]);
151
+ positions[23 ] = hlsl::float32_t3 (pos[1 ][0 ], pos[1 ][1 ], pos[1 ][2 ]);
152
+ }
164
153
165
154
//
166
- for (size_t f=0ull ; f<6ull ; ++f)
167
155
{
168
- const size_t v = f*4ull ;
169
-
170
- for (size_t i=0ull ; i<4ull ; ++i)
156
+ const hlsl::vector<int8_t , 3 > norm[6 ] =
157
+ {
158
+ hlsl::vector<int8_t ,3 >(0 , 0 , 127 ),
159
+ hlsl::vector<int8_t ,3 >(127 , 0 , 0 ),
160
+ hlsl::vector<int8_t ,3 >(0 , 0 ,-127 ),
161
+ hlsl::vector<int8_t ,3 >(-127 , 0 , 0 ),
162
+ hlsl::vector<int8_t ,3 >(0 , 127 , 0 ),
163
+ hlsl::vector<int8_t ,3 >(0 ,-127 , 0 )
164
+ };
165
+ const hlsl::vector<uint8_t , 2 > uv[4 ] =
171
166
{
172
- normals[v+i] = norm[f];
173
- uvs[v+i] = uv[i];
167
+ hlsl::vector<uint8_t ,2 >(0 ,127 ),
168
+ hlsl::vector<uint8_t ,2 >(127 ,127 ),
169
+ hlsl::vector<uint8_t ,2 >(127 , 0 ),
170
+ hlsl::vector<uint8_t ,2 >(0 , 0 )
171
+ };
172
+ for (size_t f=0ull ; f<6ull ; ++f)
173
+ {
174
+ const size_t v = f*4ull ;
175
+
176
+ for (size_t i=0ull ; i<4ull ; ++i)
177
+ {
178
+ normals[v+i] = vector<int8_t ,4 >(norm[f],0 );
179
+ uvs[v+i] = uv[i];
180
+ }
174
181
}
175
182
}
176
183
0 commit comments