@@ -138,12 +138,16 @@ COpenGLCommandBuffer::~COpenGLCommandBuffer()
138
138
139
139
const auto bpp = asset::getBytesPerPixel (format);
140
140
const auto blockDims = asset::getBlockDimensions (format);
141
+ const auto blockByteSize = asset::getTexelOrBlockBytesize (format);
141
142
142
143
ctxlocal->nextState .pixelUnpack .buffer = core::smart_refctd_ptr<const COpenGLBuffer>(static_cast <const COpenGLBuffer*>(srcBuffer));
143
144
for (auto it = c.regions ; it != c.regions + c.regionCount ; it++)
144
145
{
145
- // TODO: check it->bufferOffset is aligned to data type of E_FORMAT
146
- // assert(?);
146
+ if (it->bufferOffset != core::alignUp (it->bufferOffset , blockByteSize))
147
+ {
148
+ assert (false && " bufferOffset should be aligned to block/texel byte size." );
149
+ continue ;
150
+ }
147
151
148
152
uint32_t pitch = ((it->bufferRowLength ? it->bufferRowLength : it->imageExtent .width ) * bpp).getIntegerApprox ();
149
153
int32_t alignment = 0x1 << core::min (core::min<uint32_t >(core::findLSB (it->bufferOffset ),core::findLSB (pitch)), 3u );
@@ -233,6 +237,7 @@ COpenGLCommandBuffer::~COpenGLCommandBuffer()
233
237
234
238
const auto bpp = asset::getBytesPerPixel (format);
235
239
const auto blockDims = asset::getBlockDimensions (format);
240
+ const auto blockByteSize = asset::getTexelOrBlockBytesize (format);
236
241
237
242
const bool usingGetTexSubImage = (gl->features ->Version >= 450 || gl->features ->FeatureAvailable [gl->features ->EOpenGLFeatures ::NBL_ARB_get_texture_sub_image]);
238
243
@@ -243,8 +248,11 @@ COpenGLCommandBuffer::~COpenGLCommandBuffer()
243
248
ctxlocal->nextState .pixelPack .buffer = core::smart_refctd_ptr<const COpenGLBuffer>(static_cast <COpenGLBuffer*>(dstBuffer));
244
249
for (auto it = c.regions ; it != c.regions + c.regionCount ; it++)
245
250
{
246
- // TODO: check it->bufferOffset is aligned to data type of E_FORMAT
247
- // assert(?);
251
+ if (it->bufferOffset != core::alignUp (it->bufferOffset , blockByteSize))
252
+ {
253
+ assert (false && " bufferOffset should be aligned to block/texel byte size." );
254
+ continue ;
255
+ }
248
256
249
257
uint32_t pitch = ((it->bufferRowLength ? it->bufferRowLength : it->imageExtent .width ) * bpp).getIntegerApprox ();
250
258
int32_t alignment = 0x1 << core::min (core::max (core::findLSB (it->bufferOffset ), core::findLSB (pitch)), 3u );
0 commit comments