No longer submit initial depth/stencil image barrier outside of setup command buffer (#57), updated swapChain usage to recent refactorings
This commit is contained in:
parent
0e00f30fb1
commit
edc92112df
3 changed files with 19 additions and 16 deletions
|
|
@ -245,8 +245,8 @@ struct VulkanExample
|
||||||
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties);
|
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties);
|
||||||
|
|
||||||
// Swap chain
|
// Swap chain
|
||||||
swapChain.init(instance, physicalDevice, device);
|
swapChain.connect(instance, physicalDevice, device);
|
||||||
swapChain.initSwapChain(app->window);
|
swapChain.initSurface(app->window);
|
||||||
|
|
||||||
// Command buffer pool
|
// Command buffer pool
|
||||||
VkCommandPoolCreateInfo cmdPoolInfo = {};
|
VkCommandPoolCreateInfo cmdPoolInfo = {};
|
||||||
|
|
@ -264,15 +264,17 @@ struct VulkanExample
|
||||||
|
|
||||||
createSetupCommandBuffer();
|
createSetupCommandBuffer();
|
||||||
startSetupCommandBuffer();
|
startSetupCommandBuffer();
|
||||||
swapChain.setup(setupCmdBuffer, &width, &height);
|
|
||||||
flushSetupCommandBuffer();
|
|
||||||
|
|
||||||
createCommandBuffers();
|
swapChain.create(setupCmdBuffer, &width, &height);
|
||||||
|
|
||||||
setupDepthStencil();
|
setupDepthStencil();
|
||||||
setupRenderPass();
|
setupRenderPass();
|
||||||
setupFrameBuffer();
|
setupFrameBuffer();
|
||||||
|
|
||||||
|
flushSetupCommandBuffer();
|
||||||
|
|
||||||
|
createCommandBuffers();
|
||||||
|
|
||||||
prepareVertices();
|
prepareVertices();
|
||||||
prepareUniformBuffers();
|
prepareUniformBuffers();
|
||||||
setupDescriptorSetLayout();
|
setupDescriptorSetLayout();
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#include <android/asset_manager.h>
|
#include <android/asset_manager.h>
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
#define GLM_FORCE_RADIANS
|
||||||
|
#define GLM_DEPTH_ZERO_TO_ONE
|
||||||
#include "glm/glm.hpp"
|
#include "glm/glm.hpp"
|
||||||
#include "glm/gtc/matrix_transform.hpp"
|
#include "glm/gtc/matrix_transform.hpp"
|
||||||
|
|
||||||
|
|
@ -24,7 +25,6 @@
|
||||||
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "AndroidProject1.NativeActivity", __VA_ARGS__))
|
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "AndroidProject1.NativeActivity", __VA_ARGS__))
|
||||||
|
|
||||||
#define VERTEX_BUFFER_BIND_ID 0
|
#define VERTEX_BUFFER_BIND_ID 0
|
||||||
#define deg_to_rad(deg) deg * float(M_PI / 180)
|
|
||||||
|
|
||||||
struct saved_state {
|
struct saved_state {
|
||||||
glm::vec3 rotation;
|
glm::vec3 rotation;
|
||||||
|
|
@ -558,8 +558,8 @@ struct VulkanExample
|
||||||
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties);
|
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties);
|
||||||
|
|
||||||
// Swap chain
|
// Swap chain
|
||||||
swapChain.init(instance, physicalDevice, device);
|
swapChain.connect(instance, physicalDevice, device);
|
||||||
swapChain.initSwapChain(app->window);
|
swapChain.initSurface(app->window);
|
||||||
|
|
||||||
// Command buffer pool
|
// Command buffer pool
|
||||||
VkCommandPoolCreateInfo cmdPoolInfo = {};
|
VkCommandPoolCreateInfo cmdPoolInfo = {};
|
||||||
|
|
@ -577,20 +577,22 @@ struct VulkanExample
|
||||||
|
|
||||||
createSetupCommandBuffer();
|
createSetupCommandBuffer();
|
||||||
startSetupCommandBuffer();
|
startSetupCommandBuffer();
|
||||||
swapChain.setup(setupCmdBuffer, &width, &height);
|
|
||||||
flushSetupCommandBuffer();
|
|
||||||
|
|
||||||
createCommandBuffers();
|
swapChain.create(setupCmdBuffer, &width, &height);
|
||||||
|
|
||||||
setupDepthStencil();
|
setupDepthStencil();
|
||||||
setupRenderPass();
|
setupRenderPass();
|
||||||
setupFrameBuffer();
|
setupFrameBuffer();
|
||||||
|
|
||||||
|
flushSetupCommandBuffer();
|
||||||
|
|
||||||
loadTexture(
|
loadTexture(
|
||||||
"textures/vulkan_android_robot.ktx",
|
"textures/vulkan_android_robot.ktx",
|
||||||
VK_FORMAT_R8G8B8A8_UNORM,
|
VK_FORMAT_R8G8B8A8_UNORM,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
createCommandBuffers();
|
||||||
|
|
||||||
prepareVertices();
|
prepareVertices();
|
||||||
prepareUniformBuffers();
|
prepareUniformBuffers();
|
||||||
setupDescriptorSetLayout();
|
setupDescriptorSetLayout();
|
||||||
|
|
@ -831,14 +833,14 @@ struct VulkanExample
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
// Update matrices
|
// Update matrices
|
||||||
uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||||
|
|
||||||
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, state.zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, state.zoom));
|
||||||
|
|
||||||
uboVS.model = viewMatrix;
|
uboVS.model = viewMatrix;
|
||||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(state.rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(state.rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(state.rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(state.rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboVS.model = glm::rotate(uboVS.model, deg_to_rad(state.rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
uboVS.model = glm::rotate(uboVS.model, glm::radians(state.rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
// Map uniform buffer and update it
|
// Map uniform buffer and update it
|
||||||
uint8_t *pData;
|
uint8_t *pData;
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,6 @@ struct VulkanExample
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
createSetupCommandBuffer();
|
createSetupCommandBuffer();
|
||||||
|
|
||||||
startSetupCommandBuffer();
|
startSetupCommandBuffer();
|
||||||
|
|
||||||
swapChain.create(setupCmdBuffer, &width, &height);
|
swapChain.create(setupCmdBuffer, &width, &height);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue