From b1df7b2cd0dd29f07d75792fd59deb87caf07899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 29 May 2018 23:30:41 +0200 Subject: [PATCH] Thin3D: Handle binding a null texture better. --- ext/native/thin3d/thin3d.h | 5 +++-- ext/native/thin3d/thin3d_vulkan.cpp | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/native/thin3d/thin3d.h b/ext/native/thin3d/thin3d.h index 2aa081c273..bc5927392c 100644 --- a/ext/native/thin3d/thin3d.h +++ b/ext/native/thin3d/thin3d.h @@ -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. diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index ab9b828def..d2fa0e1619 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -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(textures[i]); - boundImageView_[i] = boundTextures_[i]->GetImageView(); + boundImageView_[i] = boundTextures_[i] ? boundTextures_[i]->GetImageView() : VK_NULL_HANDLE; } }