Skip to content

Commit 19fa77f

Browse files
authored
Merge pull request #1500 from HifiExperiments/samplerAssert
fix sampler assert
2 parents fd7c69d + 70aa1f6 commit 19fa77f

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,7 @@ void GLBackend::do_setResourceTexture(const Batch& batch, size_t paramOffset) {
245245
}
246246

247247
const auto& resourceTexture = batch._textures.get(batch._params[paramOffset + 0]._uint);
248-
Sampler sampler;
249-
if (resourceTexture) {
250-
sampler = batch._samplers.get(batch._params[paramOffset + 2]._uint);
251-
}
248+
const Sampler& sampler = batch._samplers.get(batch._params[paramOffset + 2]._uint);
252249
bindResourceTexture(slot, resourceTexture, sampler);
253250
}
254251

@@ -278,9 +275,10 @@ void GLBackend::do_setResourceFramebufferSwapChainTexture(const Batch& batch, si
278275
}
279276
auto index = batch._params[paramOffset + 2]._uint;
280277
auto renderBufferSlot = batch._params[paramOffset + 3]._uint;
278+
const Sampler& sampler = batch._samplers.get(batch._params[paramOffset + 4]._uint);
279+
281280
const auto& resourceFramebuffer = swapChain->get(index);
282281
const auto& resourceTexture = resourceFramebuffer->getRenderBuffer(renderBufferSlot);
283-
Sampler sampler = batch._samplers.get(batch._params[paramOffset + 4]._uint);
284282
setResourceTexture(slot, resourceTexture, sampler);
285283
}
286284

@@ -325,11 +323,7 @@ void GLBackend::do_setResourceTextureTable(const Batch& batch, size_t paramOffse
325323
const auto& textures = textureTable.getTextures();
326324
for (GLuint slot = 0; slot < textures.size(); ++slot) {
327325
const auto& texture = textures[slot];
328-
329-
Sampler sampler;
330-
if (texture) {
331-
sampler = batch._samplers.get(batch._params[paramOffset + 2 + (samplerIndex++)]._uint);
332-
}
326+
const Sampler& sampler = batch._samplers.get(batch._params[paramOffset + 2 + (samplerIndex++)]._uint);
333327

334328
bindResourceTexture(slot + startSlot, texture, sampler);
335329
}

libraries/gpu/src/gpu/Batch.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,7 @@ void Batch::setResourceTexture(uint32 slot, const TexturePointer& texture) {
387387

388388
_params.emplace_back(_textures.cache(texture));
389389
_params.emplace_back(slot);
390-
if (texture) {
391-
_params.emplace_back(_samplers.cache(texture->getSampler()));
392-
}
390+
_params.emplace_back(_samplers.cache(texture ? texture->getSampler() : Sampler()));
393391
}
394392

395393
void Batch::setResourceTexture(uint32 slot, const TextureView& view) {
@@ -403,9 +401,7 @@ void Batch::setResourceTextureTable(const TextureTablePointer& textureTable, uin
403401
if (textureTable) {
404402
TextureTable::Array textures = textureTable->getTextures();
405403
for (auto& texture : textures) {
406-
if (texture) {
407-
_params.emplace_back(_samplers.cache(texture->getSampler()));
408-
}
404+
_params.emplace_back(_samplers.cache(texture ? texture->getSampler() : Sampler()));
409405
}
410406
}
411407
}
@@ -421,6 +417,8 @@ void Batch::setResourceFramebufferSwapChainTexture(uint32 slot, const Framebuffe
421417
const auto& resourceFramebuffer = framebuffer->get(swapChainIndex);
422418
const auto& resourceTexture = resourceFramebuffer->getRenderBuffer(renderBufferSlot);
423419
_params.emplace_back(_samplers.cache(resourceTexture->getSampler()));
420+
} else {
421+
_params.emplace_back(_samplers.cache(Sampler()));
424422
}
425423
}
426424

0 commit comments

Comments
 (0)