Skip to content

Commit

Permalink
Fix out of pool errors on Non-Nvidia devices
Browse files Browse the repository at this point in the history
  • Loading branch information
thr3343 committed Jul 18, 2024
1 parent 5268960 commit 537698f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class DescriptorManager {

Initializer.LOGGER.info("Setting Rendering Mode: Bindless mode: {}", semiBindless ? "Semi-Bindless" : "Fully-Bindless");
Initializer.LOGGER.info("Max Per Stage Samplers: {}", maxPerStageSamplers);
Initializer.LOGGER.info("Sets: {}", semiBindless ? MAX_SETS : TOTAL_SETS);
try (MemoryStack stack = stackPush()) {


Expand Down Expand Up @@ -148,29 +149,30 @@ public static long createGlobalDescriptorPool()
{
try(MemoryStack stack = stackPush()) {
VkDescriptorPoolSize.Buffer poolSizes = VkDescriptorPoolSize.calloc(3, stack);

//4 Sets on Bindless, 64 on semi-Bindless
final int maxSets = (semiBindless ? TOTAL_SETS : MAX_SETS) * PER_SET_ALLOCS;

VkDescriptorPoolSize uniformBufferPoolSize = poolSizes.get(0);
uniformBufferPoolSize.type(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
uniformBufferPoolSize.descriptorCount(1);
uniformBufferPoolSize.descriptorCount(maxSets);

VkDescriptorPoolSize uniformBufferPoolSize2 = poolSizes.get(1);
uniformBufferPoolSize2.type(VK13.VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK);
uniformBufferPoolSize2.descriptorCount(INLINE_UNIFORM_SIZE); //Byte Count/Size For Inline Uniform block

VkDescriptorPoolSize textureSamplerPoolSize = poolSizes.get(2);
textureSamplerPoolSize.type(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER);
textureSamplerPoolSize.descriptorCount(MAX_POOL_SAMPLERS);
textureSamplerPoolSize.descriptorCount(semiBindless ? maxPerStageSamplers * PER_SET_ALLOCS * maxSets : MAX_POOL_SAMPLERS);

VkDescriptorPoolInlineUniformBlockCreateInfo inlineUniformBlockCreateInfo = VkDescriptorPoolInlineUniformBlockCreateInfo.calloc(stack)
.sType$Default()
.maxInlineUniformBlockBindings(1);
.maxInlineUniformBlockBindings(maxSets);

VkDescriptorPoolCreateInfo poolInfo = VkDescriptorPoolCreateInfo.calloc(stack);
poolInfo.sType(VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO);
poolInfo.pNext(inlineUniformBlockCreateInfo);
poolInfo.pPoolSizes(poolSizes);
poolInfo.maxSets(MAX_SETS * (semiBindless ? TOTAL_SETS : PER_SET_ALLOCS)); //The real descriptor pool size is pPoolSizes * maxSets: not the individual descriptorPool sizes
poolInfo.maxSets(maxSets);

LongBuffer pDescriptorPool = stack.mallocLong(1);

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/vulkanmod/vulkan/util/VkResult.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.vulkanmod.vulkan.util;

import org.lwjgl.vulkan.VK11;

public class VkResult {
public static final int VK_SUCCESS = 0;
public static final int VK_NOT_READY = 1;
Expand Down Expand Up @@ -41,6 +43,7 @@ public static String decode(int result) {
case VK_ERROR_TOO_MANY_OBJECTS -> "VK_ERROR_TOO_MANY_OBJECTS";
case VK_ERROR_FORMAT_NOT_SUPPORTED -> "VK_ERROR_FORMAT_NOT_SUPPORTED";
case VK_ERROR_FRAGMENTED_POOL -> "VK_ERROR_FRAGMENTED_POOL";
case VK11.VK_ERROR_OUT_OF_POOL_MEMORY -> "VK_ERROR_OUT_OF_POOL_MEMORY";
case VK_ERROR_UNKNOWN -> "VK_ERROR_UNKNOWN";

default -> Integer.toString(result);
Expand Down

0 comments on commit 537698f

Please sign in to comment.