descriptor pool final fix
This commit is contained in:
parent
6afc638902
commit
915469e0f3
4 changed files with 16 additions and 17 deletions
|
@ -13,7 +13,6 @@ Engine::Engine(int width, int height, std::string name, const char *icon) : xeWi
|
||||||
xeRenderer{xeWindow, xeDevice},
|
xeRenderer{xeWindow, xeDevice},
|
||||||
xeCamera{},
|
xeCamera{},
|
||||||
xeInput{xeWindow} {
|
xeInput{xeWindow} {
|
||||||
loadDescriptorPool();
|
|
||||||
alutInit(0, NULL);
|
alutInit(0, NULL);
|
||||||
std::cout << "Audio device: " << alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER) << "\n";
|
std::cout << "Audio device: " << alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER) << "\n";
|
||||||
_instance = this;
|
_instance = this;
|
||||||
|
@ -25,15 +24,6 @@ Engine::~Engine() {
|
||||||
alutExit();
|
alutExit();
|
||||||
};
|
};
|
||||||
|
|
||||||
void Engine::loadDescriptorPool() {
|
|
||||||
xeDescriptorPool = DescriptorPool::Builder(xeDevice)
|
|
||||||
.setMaxSets(SwapChain::MAX_FRAMES_IN_FLIGHT)
|
|
||||||
.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, SwapChain::MAX_FRAMES_IN_FLIGHT * 4)
|
|
||||||
.addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, SwapChain::MAX_FRAMES_IN_FLIGHT * 4)
|
|
||||||
.addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, SwapChain::MAX_FRAMES_IN_FLIGHT * 4)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Engine::poll() {
|
bool Engine::poll() {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
auto newTime = std::chrono::high_resolution_clock::now();
|
auto newTime = std::chrono::high_resolution_clock::now();
|
||||||
|
|
|
@ -40,9 +40,7 @@ class Engine {
|
||||||
static Engine* getInstance();
|
static Engine* getInstance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void loadDescriptorPool();
|
|
||||||
|
|
||||||
Window xeWindow;
|
Window xeWindow;
|
||||||
Device xeDevice;
|
Device xeDevice;
|
||||||
Renderer xeRenderer;
|
Renderer xeRenderer;
|
||||||
|
@ -54,8 +52,6 @@ class Engine {
|
||||||
|
|
||||||
float FOV = 50.f;
|
float FOV = 50.f;
|
||||||
|
|
||||||
std::unique_ptr<DescriptorPool> xeDescriptorPool;
|
|
||||||
|
|
||||||
friend class RenderSystem;
|
friend class RenderSystem;
|
||||||
friend class Image;
|
friend class Image;
|
||||||
friend class Model;
|
friend class Model;
|
||||||
|
|
|
@ -15,11 +15,11 @@ RenderSystem::RenderSystem(
|
||||||
uint32_t vertexSize
|
uint32_t vertexSize
|
||||||
) : xeDevice{xeEngine.xeDevice},
|
) : xeDevice{xeEngine.xeDevice},
|
||||||
xeRenderer{xeEngine.xeRenderer},
|
xeRenderer{xeEngine.xeRenderer},
|
||||||
xeDescriptorPool{xeEngine.xeDescriptorPool},
|
|
||||||
pushCunstantDataSize{pushCunstantDataSize},
|
pushCunstantDataSize{pushCunstantDataSize},
|
||||||
uniformBindings{uniformBindings},
|
uniformBindings{uniformBindings},
|
||||||
imageBindings{imageBindings},
|
imageBindings{imageBindings},
|
||||||
imageArrayBindings{imageArrayBindings} {
|
imageArrayBindings{imageArrayBindings} {
|
||||||
|
createDescriptorPool();
|
||||||
createDescriptorSetLayout();
|
createDescriptorSetLayout();
|
||||||
createUniformBuffers();
|
createUniformBuffers();
|
||||||
createDescriptorSets();
|
createDescriptorSets();
|
||||||
|
@ -31,6 +31,18 @@ RenderSystem::~RenderSystem() {
|
||||||
vkDestroyPipelineLayout(xeDevice.device(), pipelineLayout, nullptr);
|
vkDestroyPipelineLayout(xeDevice.device(), pipelineLayout, nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void RenderSystem::createDescriptorPool() {
|
||||||
|
DescriptorPool::Builder builder{xeDevice};
|
||||||
|
builder.setMaxSets(SwapChain::MAX_FRAMES_IN_FLIGHT);
|
||||||
|
builder.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, uniformBindings.size() * SwapChain::MAX_FRAMES_IN_FLIGHT);
|
||||||
|
uint32_t images = imageBindings.size();
|
||||||
|
for ( const auto &[binding, size]: imageArrayBindings) {
|
||||||
|
images += size.size();
|
||||||
|
}
|
||||||
|
builder.addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, images * SwapChain::MAX_FRAMES_IN_FLIGHT);
|
||||||
|
xeDescriptorPool = builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
void RenderSystem::createDescriptorSetLayout() {
|
void RenderSystem::createDescriptorSetLayout() {
|
||||||
DescriptorSetLayout::Builder builder{xeDevice};
|
DescriptorSetLayout::Builder builder{xeDevice};
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,7 @@ class RenderSystem {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void createDescriptorPool();
|
||||||
void createDescriptorSetLayout();
|
void createDescriptorSetLayout();
|
||||||
void createUniformBuffers();
|
void createUniformBuffers();
|
||||||
void createDescriptorSets();
|
void createDescriptorSets();
|
||||||
|
@ -148,7 +149,7 @@ class RenderSystem {
|
||||||
|
|
||||||
VkPipelineLayout pipelineLayout;
|
VkPipelineLayout pipelineLayout;
|
||||||
std::unique_ptr<Pipeline> xePipeline;
|
std::unique_ptr<Pipeline> xePipeline;
|
||||||
std::unique_ptr<DescriptorPool> &xeDescriptorPool;
|
std::unique_ptr<DescriptorPool> xeDescriptorPool;
|
||||||
std::unique_ptr<DescriptorSetLayout> xeDescriptorSetLayout;
|
std::unique_ptr<DescriptorSetLayout> xeDescriptorSetLayout;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue