Thin3D: Handle binding a null texture better.

This commit is contained in:
Henrik Rydgård
2018-05-29 23:35:27 +02:00
parent 1c17373039
commit b1df7b2cd0
2 changed files with 6 additions and 6 deletions
+3 -2
View File
@@ -2,7 +2,7 @@
// Does not involve context creation etc, that should be handled separately - only does drawing.
// The goals may change in the future though.
// MIT licensed, by Henrik Rydgård 2014.
// MIT licensed, by Henrik Rydgård 2014.
#pragma once
@@ -597,7 +597,8 @@ public:
virtual void UpdateDynamicUniformBuffer(const void *ub, size_t size) = 0;
void BindTexture(int stage, Texture *texture) {
BindTextures(stage, 1, &texture);
Texture *textures[1] = { texture };
BindTextures(stage, 1, textures);
} // from sampler 0 and upwards
// Call this with 0 to signal that you have been drawing on your own, and need the state reset on the next pipeline bind.
+3 -4
View File
@@ -730,7 +730,6 @@ VKContext::VKContext(VulkanContext *vulkan, bool splitSubmit)
queue_ = vulkan->GetGraphicsQueue();
queueFamilyIndex_ = vulkan->GetGraphicsQueueFamilyIndex();
memset(boundTextures_, 0, sizeof(boundTextures_));
VkDescriptorPoolSize dpTypes[2];
dpTypes[0].descriptorCount = 200;
@@ -873,8 +872,8 @@ VkDescriptorSet VKContext::GetOrCreateDescriptorSet(VkBuffer buf) {
bufferDesc.range = curPipeline_->GetUBOSize();
VkDescriptorImageInfo imageDesc;
imageDesc.imageView = boundTextures_[0]->GetImageView();
imageDesc.sampler = boundSamplers_[0]->GetSampler();
imageDesc.imageView = boundTextures_[0] ? boundTextures_[0]->GetImageView() : VK_NULL_HANDLE;
imageDesc.sampler = boundSamplers_[0] ? boundSamplers_[0]->GetSampler() : VK_NULL_HANDLE;
#ifdef VULKAN_USE_GENERAL_LAYOUT_FOR_COLOR
imageDesc.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
#else
@@ -1122,7 +1121,7 @@ void VKContext::UpdateBuffer(Buffer *buffer, const uint8_t *data, size_t offset,
void VKContext::BindTextures(int start, int count, Texture **textures) {
for (int i = start; i < start + count; i++) {
boundTextures_[i] = static_cast<VKTexture *>(textures[i]);
boundImageView_[i] = boundTextures_[i]->GetImageView();
boundImageView_[i] = boundTextures_[i] ? boundTextures_[i]->GetImageView() : VK_NULL_HANDLE;
}
}