Display occlusion query stats on text overlay
This commit is contained in:
parent
05b920cf01
commit
f601b35229
2 changed files with 17 additions and 16 deletions
|
|
@ -30,7 +30,7 @@
|
||||||
#define STB_NUM_CHARS STB_FONT_consolas_24_latin1_NUM_CHARS
|
#define STB_NUM_CHARS STB_FONT_consolas_24_latin1_NUM_CHARS
|
||||||
|
|
||||||
// Max. number of chars the text overlay buffer can hold
|
// Max. number of chars the text overlay buffer can hold
|
||||||
#define MAX_CHAR_COUNT 512
|
#define MAX_CHAR_COUNT 1024
|
||||||
|
|
||||||
// Mostly self-contained text overlay class
|
// Mostly self-contained text overlay class
|
||||||
// todo : comment
|
// todo : comment
|
||||||
|
|
|
||||||
|
|
@ -96,13 +96,8 @@ public:
|
||||||
zoomSpeed = 2.5f;
|
zoomSpeed = 2.5f;
|
||||||
rotationSpeed = 0.5f;
|
rotationSpeed = 0.5f;
|
||||||
rotation = { 0.0, -123.75, 0.0 };
|
rotation = { 0.0, -123.75, 0.0 };
|
||||||
|
enableTextOverlay = true;
|
||||||
title = "Vulkan Example - Occlusion queries";
|
title = "Vulkan Example - Occlusion queries";
|
||||||
#ifdef _WIN32
|
|
||||||
if (!ENABLE_VALIDATION)
|
|
||||||
{
|
|
||||||
setupConsole(title);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~VulkanExample()
|
~VulkanExample()
|
||||||
|
|
@ -314,10 +309,10 @@ public:
|
||||||
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
||||||
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
|
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
|
||||||
|
|
||||||
VulkanExampleBase::submitFrame();
|
|
||||||
|
|
||||||
// Read query results for displaying in next frame
|
// Read query results for displaying in next frame
|
||||||
getQueryResults();
|
getQueryResults();
|
||||||
|
|
||||||
|
VulkanExampleBase::submitFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadMeshes()
|
void loadMeshes()
|
||||||
|
|
@ -579,21 +574,20 @@ public:
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
glm::mat4 viewMatrix = glm::mat4();
|
|
||||||
uboVS.projection = glm::perspective(glm::radians(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);
|
||||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));
|
||||||
|
|
||||||
glm::mat4 rotMatrix = glm::mat4();
|
glm::mat4 rotMatrix = glm::mat4();
|
||||||
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
uboVS.model = glm::mat4();
|
uboVS.model = viewMatrix * rotMatrix;
|
||||||
uboVS.model = viewMatrix * rotMatrix;;
|
|
||||||
|
|
||||||
uboVS.visible = 1.0f;
|
|
||||||
|
|
||||||
uint8_t *pData;
|
uint8_t *pData;
|
||||||
|
|
||||||
|
// Occluder
|
||||||
|
uboVS.visible = 1.0f;
|
||||||
VK_CHECK_RESULT(vkMapMemory(device, uniformData.vsScene.memory, 0, sizeof(uboVS), 0, (void **)&pData));
|
VK_CHECK_RESULT(vkMapMemory(device, uniformData.vsScene.memory, 0, sizeof(uboVS), 0, (void **)&pData));
|
||||||
memcpy(pData, &uboVS, sizeof(uboVS));
|
memcpy(pData, &uboVS, sizeof(uboVS));
|
||||||
vkUnmapMemory(device, uniformData.vsScene.memory);
|
vkUnmapMemory(device, uniformData.vsScene.memory);
|
||||||
|
|
@ -641,7 +635,14 @@ public:
|
||||||
{
|
{
|
||||||
vkDeviceWaitIdle(device);
|
vkDeviceWaitIdle(device);
|
||||||
updateUniformBuffers();
|
updateUniformBuffers();
|
||||||
std::cout << "Passed samples : Teapot = " << passedSamples[0] << " / Sphere = " << passedSamples[1] <<"\n";
|
VulkanExampleBase::updateTextOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void getOverlayText(VulkanTextOverlay *textOverlay)
|
||||||
|
{
|
||||||
|
textOverlay->addText("Occlusion queries:", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||||
|
textOverlay->addText("Teapot: " + std::to_string(passedSamples[0]) + " samples passed" , 5.0f, 105.0f, VulkanTextOverlay::alignLeft);
|
||||||
|
textOverlay->addText("Sphere: " + std::to_string(passedSamples[1]) + " samples passed", 5.0f, 125.0f, VulkanTextOverlay::alignLeft);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue