Removed function to get enabled features, features can be set directly in derived constructor due to new explicit Vulkan initialization
This commit is contained in:
parent
ca27585ee6
commit
401369f716
7 changed files with 44 additions and 47 deletions
|
|
@ -54,11 +54,6 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
|||
return vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
|
||||
}
|
||||
|
||||
VkPhysicalDeviceFeatures VulkanExampleBase::getEnabledFeatures()
|
||||
{
|
||||
return VkPhysicalDeviceFeatures{};
|
||||
}
|
||||
|
||||
std::string VulkanExampleBase::getWindowTitle()
|
||||
{
|
||||
std::string device(deviceProperties.deviceName);
|
||||
|
|
@ -830,7 +825,7 @@ void VulkanExampleBase::initVulkan()
|
|||
// This is handled by a separate class that gets a logical device representation
|
||||
// and encapsulates functions related to a device
|
||||
vulkanDevice = new vk::VulkanDevice(physicalDevice);
|
||||
VK_CHECK_RESULT(vulkanDevice->createLogicalDevice(getEnabledFeatures()));
|
||||
VK_CHECK_RESULT(vulkanDevice->createLogicalDevice(enabledFeatures));
|
||||
device = vulkanDevice->logicalDevice;
|
||||
|
||||
// todo: remove
|
||||
|
|
|
|||
|
|
@ -44,17 +44,11 @@
|
|||
#include "vulkantextoverlay.hpp"
|
||||
#include "camera.hpp"
|
||||
|
||||
// Function pointer for getting physical device fetures to be enabled
|
||||
typedef VkPhysicalDeviceFeatures (*PFN_GetEnabledFeatures)();
|
||||
|
||||
class VulkanExampleBase
|
||||
{
|
||||
private:
|
||||
// Set to true if v-sync will be forced for the swapchain
|
||||
bool enableVSync = false;
|
||||
// Device features enabled by the example
|
||||
// If not set, no additional features are enabled (may result in validation layer errors)
|
||||
VkPhysicalDeviceFeatures enabledFeatures = {};
|
||||
// fps timer (one second interval)
|
||||
float fpsTimer = 0.0f;
|
||||
// Get window title with example name, device, et.
|
||||
|
|
@ -81,10 +75,16 @@ protected:
|
|||
VkPhysicalDevice physicalDevice;
|
||||
// Stores physical device properties (for e.g. checking device limits)
|
||||
VkPhysicalDeviceProperties deviceProperties;
|
||||
// Stores phyiscal device features (for e.g. checking if a feature is available)
|
||||
// Stores the features available on the selected physical device (for e.g. checking if a feature is available)
|
||||
VkPhysicalDeviceFeatures deviceFeatures;
|
||||
// Stores all available memory (type) properties for the physical device
|
||||
VkPhysicalDeviceMemoryProperties deviceMemoryProperties;
|
||||
/**
|
||||
* Set of physical device features to be enabled for this example (must be set in the derived constructor)
|
||||
*
|
||||
* @note By default no phyiscal device features are enabled
|
||||
*/
|
||||
VkPhysicalDeviceFeatures enabledFeatures{};
|
||||
/** @brief Logical device, application's view of the physical device (GPU) */
|
||||
// todo: getter? should always point to VulkanDevice->device
|
||||
VkDevice device;
|
||||
|
|
@ -233,13 +233,6 @@ public:
|
|||
*/
|
||||
virtual VkResult createInstance(bool enableValidation);
|
||||
|
||||
/**
|
||||
* Get physical device features to be enabled for this example
|
||||
*
|
||||
* @note Virtual, can be overriden by derived example class for custom instance creation
|
||||
*/
|
||||
virtual VkPhysicalDeviceFeatures getEnabledFeatures();
|
||||
|
||||
// Pure virtual render function (override in derived class)
|
||||
virtual void render() = 0;
|
||||
// Called when view change occurs
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -79,8 +79,6 @@ public:
|
|||
virtual VkPhysicalDeviceFeatures getEnabledFeatures()
|
||||
{
|
||||
VkPhysicalDeviceFeatures enabledFeatures{};
|
||||
enabledFeatures.tessellationShader = VK_TRUE;
|
||||
enabledFeatures.fillModeNonSolid = VK_TRUE;
|
||||
return enabledFeatures;
|
||||
}
|
||||
|
||||
|
|
@ -90,11 +88,11 @@ public:
|
|||
rotation = glm::vec3(-20.0f, 45.0f, 0.0f);
|
||||
enableTextOverlay = true;
|
||||
title = "Vulkan Example - Tessellation shader displacement mapping";
|
||||
// Support for tessellation shaders is optional, so check first
|
||||
if (!deviceFeatures.tessellationShader)
|
||||
{
|
||||
vkTools::exitFatal("Selected GPU does not support tessellation shaders!", "Feature not supported");
|
||||
}
|
||||
// Enable physical device features required for this example
|
||||
// Tell the driver that we are going to use geometry shaders
|
||||
enabledFeatures.tessellationShader = VK_TRUE;
|
||||
// Example also uses a wireframe pipeline, enable non-solid fill modes
|
||||
enabledFeatures.fillModeNonSolid = VK_TRUE;
|
||||
}
|
||||
|
||||
~VulkanExample()
|
||||
|
|
@ -508,6 +506,12 @@ public:
|
|||
|
||||
void prepare()
|
||||
{
|
||||
// Check if device supports tessellation shaders
|
||||
if (!deviceFeatures.tessellationShader)
|
||||
{
|
||||
vkTools::exitFatal("Selected GPU does not support tessellation shaders!", "Feature not supported");
|
||||
}
|
||||
|
||||
VulkanExampleBase::prepare();
|
||||
loadMeshes();
|
||||
loadTextures();
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ public:
|
|||
rotation = glm::vec3(0.0f, -25.0f, 0.0f);
|
||||
enableTextOverlay = true;
|
||||
title = "Vulkan Example - Geometry shader";
|
||||
// Enable physical device features required for this example
|
||||
// Tell the driver that we are going to use geometry shaders
|
||||
enabledFeatures.geometryShader = VK_TRUE;
|
||||
}
|
||||
|
||||
~VulkanExample()
|
||||
|
|
|
|||
|
|
@ -112,15 +112,6 @@ public:
|
|||
// View frustum passed to tessellation control shader for culling
|
||||
vkTools::Frustum frustum;
|
||||
|
||||
// Device features to be enabled for this example
|
||||
virtual VkPhysicalDeviceFeatures getEnabledFeatures()
|
||||
{
|
||||
VkPhysicalDeviceFeatures enabledFeatures{};
|
||||
enabledFeatures.tessellationShader = VK_TRUE;
|
||||
enabledFeatures.fillModeNonSolid = VK_TRUE;
|
||||
return enabledFeatures;
|
||||
}
|
||||
|
||||
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
||||
{
|
||||
enableTextOverlay = true;
|
||||
|
|
@ -129,13 +120,12 @@ public:
|
|||
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 512.0f);
|
||||
camera.setRotation(glm::vec3(-12.0f, 159.0f, 0.0f));
|
||||
camera.setTranslation(glm::vec3(18.0f, 22.5f, 57.5f));
|
||||
|
||||
camera.movementSpeed = 7.5f;
|
||||
// Support for tessellation shaders is optional, so check first
|
||||
//if (!deviceFeatures.tessellationShader)
|
||||
//{
|
||||
// vkTools::exitFatal("Selected GPU does not support tessellation shaders!", "Feature not supported");
|
||||
//}
|
||||
// Enable physical device features required for this example
|
||||
// Tell the driver that we are going to use geometry shaders
|
||||
enabledFeatures.tessellationShader = VK_TRUE;
|
||||
// Example also uses a wireframe pipeline, enable non-solid fill modes
|
||||
enabledFeatures.fillModeNonSolid = VK_TRUE;
|
||||
}
|
||||
|
||||
~VulkanExample()
|
||||
|
|
@ -896,6 +886,12 @@ public:
|
|||
|
||||
void prepare()
|
||||
{
|
||||
// Check if device supports tessellation shaders
|
||||
if (!deviceFeatures.tessellationShader)
|
||||
{
|
||||
vkTools::exitFatal("Selected GPU does not support tessellation shaders!", "Feature not supported");
|
||||
}
|
||||
|
||||
VulkanExampleBase::prepare();
|
||||
loadMeshes();
|
||||
loadTextures();
|
||||
|
|
|
|||
|
|
@ -94,11 +94,11 @@ public:
|
|||
cameraPos = glm::vec3(-3.0f, 2.3f, 0.0f);
|
||||
title = "Vulkan Example - Tessellation shader (PN Triangles)";
|
||||
enableTextOverlay = true;
|
||||
// Support for tessellation shaders is optional, so check first
|
||||
if (!deviceFeatures.tessellationShader)
|
||||
{
|
||||
vkTools::exitFatal("Selected GPU does not support tessellation shaders!", "Feature not supported");
|
||||
}
|
||||
// Enable physical device features required for this example
|
||||
// Tell the driver that we are going to use geometry shaders
|
||||
enabledFeatures.tessellationShader = VK_TRUE;
|
||||
// Example also uses a wireframe pipeline, enable non-solid fill modes
|
||||
enabledFeatures.fillModeNonSolid = VK_TRUE;
|
||||
}
|
||||
|
||||
~VulkanExample()
|
||||
|
|
@ -511,6 +511,12 @@ public:
|
|||
|
||||
void prepare()
|
||||
{
|
||||
// Check if device supports tessellation shaders
|
||||
if (!deviceFeatures.tessellationShader)
|
||||
{
|
||||
vkTools::exitFatal("Selected GPU does not support tessellation shaders!", "Feature not supported");
|
||||
}
|
||||
|
||||
VulkanExampleBase::prepare();
|
||||
loadTextures();
|
||||
loadMeshes();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue