Skip to content

Commit

Permalink
Merge pull request #17415 from hrydgard/misc-fixes
Browse files Browse the repository at this point in the history
Misc fixes and checks
  • Loading branch information
hrydgard committed May 6, 2023
2 parents bf79e4b + ac88e73 commit 23c24d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Common/GPU/Vulkan/thin3d_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ VulkanTexture *VKContext::GetNullTexture() {
uint32_t bindOffset;
VkBuffer bindBuf;
uint32_t *data = (uint32_t *)push_->Allocate(w * h * 4, 4, &bindBuf, &bindOffset);
_assert_(data != nullptr);
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
// data[y*w + x] = ((x ^ y) & 1) ? 0xFF808080 : 0xFF000000; // gray/black checkerboard
Expand Down Expand Up @@ -788,6 +789,7 @@ bool VKTexture::Create(VkCommandBuffer cmd, VulkanPushPool *push, const TextureD
size_t size = w * h * d * bytesPerPixel;
if (desc.initDataCallback) {
uint8_t *dest = (uint8_t *)push->Allocate(size, 16, &buf, &offset);
_assert_(dest != nullptr);
if (!desc.initDataCallback(dest, desc.initData[i], w, h, d, w * bytesPerPixel, h * w * bytesPerPixel)) {
memcpy(dest, desc.initData[i], size);
}
Expand Down Expand Up @@ -1505,7 +1507,12 @@ void VKContext::DrawUP(const void *vdata, int vertexCount) {
}

VkBuffer vulkanVbuf, vulkanUBObuf;
size_t vbBindOffset = push_->Push(vdata, vertexCount * curPipeline_->stride[0], 4, &vulkanVbuf);
size_t dataSize = vertexCount * curPipeline_->stride[0];
uint32_t vbBindOffset;
uint8_t *dataPtr = push_->Allocate(dataSize, 4, &vulkanVbuf, &vbBindOffset);
_assert_(dataPtr != nullptr);
memcpy(dataPtr, vdata, dataSize);

uint32_t ubo_offset = (uint32_t)curPipeline_->PushUBO(push_, vulkan_, &vulkanUBObuf);

VkDescriptorSet descSet = GetOrCreateDescriptorSet(vulkanUBObuf);
Expand Down
2 changes: 1 addition & 1 deletion Common/Render/Text/draw_text_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool TextDrawerAndroid::IsReady() const {
uint32_t TextDrawerAndroid::SetFont(const char *fontName, int size, int flags) {
// We will only use the default font but just for consistency let's still involve
// the font name.
uint32_t fontHash = hash::Adler32((const uint8_t *)fontName, strlen(fontName));
uint32_t fontHash = fontName ? hash::Adler32((const uint8_t *)fontName, strlen(fontName)) : 1337;
fontHash ^= size;
fontHash ^= flags << 10;

Expand Down

0 comments on commit 23c24d2

Please sign in to comment.