![]() |
CMSC23700 Common Code Library
Support code for CS23700 programming projects
|
the base class for applications More...
#include <cs237-application.hpp>

Classes | |
| struct | Queues |
| information about queue families More... | |
| struct | SamplerInfo |
| struct | SwapChainDetails |
Public Member Functions | |
| Application (std::vector< std::string > const &args, std::string const &name="CS237 App") | |
| constructor for application base class | |
| virtual | ~Application () |
| virtual void | run ()=0 |
| main function for running the application | |
| std::string | name () const |
| return the application name | |
| bool | debug () const |
| is the program in debug mode? | |
| bool | verbose () const |
| is the program in verbose mode? | |
| std::vector< vk::ExtensionProperties > | supportedDeviceExtensions () |
| Get the list of supported Vulkan device extensions for the selected physical device. | |
| vk::Sampler | createSampler (SamplerInfo const &info) |
| Create a texture sampler as specified. | |
| vk::Sampler | createDepthSampler (SamplerInfo const &info) |
| Create a depth-texture sampler as specified. | |
| vk::Device | device () const |
| get the logical device | |
| const vk::PhysicalDeviceProperties * | props () const |
| get the physical-device properties pointer | |
| const vk::PhysicalDeviceLimits * | limits () const |
| access function for the physical device limits | |
| const vk::PhysicalDeviceFeatures * | features () const |
| access function for the physical device features | |
| vk::FormatProperties | formatProps (vk::Format fmt) const |
| access function for the properties of an image format | |
| vk::PipelineLayout | createPipelineLayout (std::vector< vk::DescriptorSetLayout > descSets, std::vector< vk::PushConstantRange > pcrs) |
| Create a pipeline layout. | |
| vk::PipelineLayout | createPipelineLayout (vk::DescriptorSetLayout descSet) |
| Create a pipeline layout for a single descriptor set. | |
| vk::Pipeline | createPipeline (cs237::Shaders *shaders, vk::PipelineVertexInputStateCreateInfo const &vertexInfo, vk::PrimitiveTopology prim, bool primRestart, vk::ArrayProxy< vk::Viewport > const &viewports, vk::ArrayProxy< vk::Rect2D > const &scissors, bool depthClamp, vk::PolygonMode polyMode, vk::CullModeFlags cullMode, vk::FrontFace front, vk::PipelineLayout layout, vk::RenderPass renderPass, uint32_t subPass, vk::ArrayProxy< vk::DynamicState > const &dynamic) |
| Allocate a graphics pipeline. | |
| vk::Pipeline | createPipeline (cs237::Shaders *shaders, vk::PipelineVertexInputStateCreateInfo const &vertexInfo, vk::PrimitiveTopology prim, vk::ArrayProxy< vk::Viewport > const &viewports, vk::ArrayProxy< vk::Rect2D > const &scissors, vk::PolygonMode polyMode, vk::CullModeFlags cullMode, vk::FrontFace front, vk::PipelineLayout layout, vk::RenderPass renderPass, uint32_t subPass, vk::ArrayProxy< vk::DynamicState > const &dynamic) |
| Allocate a graphics pipeline using common defaults. | |
| vk::CommandBuffer | newCommandBuf () |
| create and initialize a command buffer | |
| void | beginCommands (vk::CommandBuffer cmdBuf, bool oneTime=false) |
| begin recording commands in the given command buffer | |
| void | endCommands (vk::CommandBuffer cmdBuf) |
| end the recording of commands in the give command buffer | |
| void | submitCommands (vk::CommandBuffer cmdBuf) |
| end the commands and submit the buffer to the graphics queue. | |
| void | freeCommandBuf (vk::CommandBuffer &cmdBuf) |
| free the command buffer | |
Static Public Member Functions | |
| static std::vector< vk::ExtensionProperties > | supportedExtensions () |
| Get the list of supported Vulkan instance extensions. | |
| static std::vector< vk::LayerProperties > | supportedLayers () |
| Get the list of supported layers. | |
Protected Member Functions | |
| void | _createInstance () |
| A helper function to create and initialize the Vulkan instance used by the application. | |
| void | _getPhysicalDeviceProperties () const |
function that gets the physical-device properties and caches the pointer in the _propsCache field. | |
| void | _getPhysicalDeviceFeatures () const |
function that gets the physical-device features and caches the pointer in the _featuresCache field. | |
| void | _selectDevice (vk::PhysicalDeviceFeatures *reqFeatures=nullptr) |
| A helper function to select the GPU to use. | |
| int32_t | _findMemory (uint32_t reqTypeBits, vk::MemoryPropertyFlags reqProps) const |
| A helper function to identify the index of a device memory type that has the required type and properties. | |
| vk::Format | _findBestFormat (std::vector< vk::Format > candidates, vk::ImageTiling tiling, vk::FormatFeatureFlags features) |
| A helper function to identify the best image format supported by the device from an ordered list of candidate formats. | |
| void | _initCommandPool () |
| allocate the command pool for the application | |
| vk::Format | _depthStencilBufferFormat (bool depth, bool stencil) |
| A helper function to identify the best depth/stencil-buffer attachment format for the device. | |
| bool | _getQIndices (vk::PhysicalDevice dev) |
| A helper function to identify the queue-family indices for the physical device that we are using. | |
| void | _createLogicalDevice () |
| A helper function to create the logical device during initialization. | |
| vk::Image | _createImage (uint32_t wid, uint32_t ht, vk::Format format, vk::ImageTiling tiling, vk::ImageUsageFlags usage, vk::ImageLayout layout, uint32_t mipLvls=1) |
| A helper function for creating a Vulkan image that can be used for textures or depth buffers. | |
| vk::Image | _createImage (uint32_t wid, uint32_t ht, vk::Format format, vk::ImageTiling tiling, vk::ImageUsageFlags usage, uint32_t mipLvls=1) |
| A helper function for creating a Vulkan image that can be used for textures or depth buffers. | |
| vk::DeviceMemory | _allocImageMemory (vk::Image img, vk::MemoryPropertyFlags props) |
| A helper function for allocating and binding device memory for an image. | |
| vk::ImageView | _createImageView (vk::Image image, vk::Format format, vk::ImageAspectFlags aspectFlags) |
| A helper function for creating a Vulkan image view object for an image. | |
| void | _transitionImageLayout (vk::Image image, vk::Format format, vk::ImageLayout oldLayout, vk::ImageLayout newLayout) |
| A helper function for changing the layout of an image. | |
| vk::Buffer | _createBuffer (size_t size, vk::BufferUsageFlags usage) |
| create a vk::Buffer object | |
| vk::DeviceMemory | _allocBufferMemory (vk::Buffer buf, vk::MemoryPropertyFlags props) |
| A helper function for allocating and binding device memory for a buffer. | |
| void | _copyBuffer (vk::Buffer dstBuf, vk::Buffer srcBuf, size_t offset, size_t size) |
| copy data from one buffer to another using the GPU | |
| void | _copyBufferToImage (vk::Image dstImg, vk::Buffer srcBuf, size_t size, uint32_t wid, uint32_t ht=1, uint32_t depth=1) |
| copy data from a buffer to an image | |
| void | _initDebug () |
| void | _cleanupDebug () |
Protected Attributes | |
| std::string | _name |
| the application name | |
| vk::DebugUtilsMessageSeverityFlagsEXT | _messages |
| set to the message severity level | |
| bool | _debug |
| set when validation layers should be enabled | |
| vk::Instance | _instance |
| the Vulkan instance used by the application | |
| vk::PhysicalDevice | _gpu |
| the graphics card (aka device) that we are using | |
| vk::PhysicalDeviceProperties * | _propsCache |
| vk::PhysicalDeviceFeatures * | _featuresCache |
| a cache of the physical device properties | |
| vk::Device | _device |
| the logical device that we are using to render | |
| Queues< uint32_t > | _qIdxs |
| the queue family indices | |
| Queues< vk::Queue > | _queues |
| the device queues that we are using | |
| vk::CommandPool | _cmdPool |
| pool for allocating command buffers | |
| VkDebugUtilsMessengerEXT | _debugMessenger |
Friends | |
| class | Window |
| class | Buffer |
| class | MemoryObj |
| class | __detail::TextureBase |
| class | Texture1D |
| class | Texture2D |
| class | DepthBuffer |
the base class for applications
| cs237::Application::Application | ( | std::vector< std::string > const & | args, |
| std::string const & | name = "CS237 App" |
||
| ) |
constructor for application base class
| args | vector of the command-line arguments |
| name | optional name of the application |
|
virtual |
|
protected |
A helper function for allocating and binding device memory for a buffer.
| buf | the buffer to allocate memory for |
| props | requred memory properties |
|
protected |
A helper function for allocating and binding device memory for an image.
| img | the image to allocate memory for |
| props | requred memory properties |
|
protected |
|
protected |
copy data from one buffer to another using the GPU
| dstBuf | the destination buffer |
| srcBuf | the source buffer |
| offset | the offset in the destination buffer to copy to |
| size | the size (in bytes) of data to copy |
|
protected |
copy data from a buffer to an image
| dstImg | the destination image |
| srcBuf | the source buffer |
| size | the size (in bytes) of data to copy |
| wid | the image width |
| ht | the image height (default 1) |
| depth | the image depth (default 1) |
|
protected |
create a vk::Buffer object
| size | the size of the buffer in bytes |
| usage | the usage of the buffer |
|
inlineprotected |
A helper function for creating a Vulkan image that can be used for textures or depth buffers.
| wid | the image width |
| ht | the image height |
| format | the pixel format for the image |
| tiling | the tiling method for the pixels (device optimal vs linear) |
| usage | flags specifying the usage of the image |
| mipLvls | number of mipmap levels for the image |
|
protected |
A helper function for creating a Vulkan image that can be used for textures or depth buffers.
| wid | the image width |
| ht | the image height |
| format | the pixel format for the image |
| tiling | the tiling method for the pixels (device optimal vs linear) |
| usage | flags specifying the usage of the image |
| layout | the image layout |
| mipLvls | number of mipmap levels for the image (default = 1) |
|
protected |
A helper function for creating a Vulkan image view object for an image.
|
protected |
A helper function to create and initialize the Vulkan instance used by the application.
|
protected |
A helper function to create the logical device during initialization.
This function initializes the _device, _qIdxs, and _queues instance variables.
|
protected |
A helper function to identify the best depth/stencil-buffer attachment format for the device.
| depth | set to true if requesting depth-buffer support |
| stencil | set to true if requesting stencil-buffer support |
depth and stencil are both false or if there s no depth-buffer support
|
protected |
A helper function to identify the best image format supported by the device from an ordered list of candidate formats.
| candidates | list of candidates in order of preference |
| tiling | how pixels are to be tiled in the image (linear vs optimal) |
| features | required features for the format |
|
protected |
A helper function to identify the index of a device memory type that has the required type and properties.
| reqTypeBits | bit mask that specifies the possible memory types |
| reqProps | memory property bit mask |
|
protected |
function that gets the physical-device features and caches the pointer in the _featuresCache field.
|
protected |
function that gets the physical-device properties and caches the pointer in the _propsCache field.
|
protected |
A helper function to identify the queue-family indices for the physical device that we are using.
true if the device supports all of the required queue types and false otherwise.If this function returns true, then the _qIdxs instance variable will be initialized to the queue family indices that were detected.
|
protected |
allocate the command pool for the application
|
protected |
|
protected |
A helper function to select the GPU to use.
| reqFeatures | points to a structure specifying the required features of the selected device. |
|
protected |
A helper function for changing the layout of an image.
|
inline |
begin recording commands in the given command buffer
| cmdBuf | the command buffer to use for recording commands |
| oneTime | true if this command buffer is only going to be used once |
| vk::Sampler cs237::Application::createDepthSampler | ( | SamplerInfo const & | info | ) |
Create a depth-texture sampler as specified.
| info | a simplified sampler specification |
| vk::Pipeline cs237::Application::createPipeline | ( | cs237::Shaders * | shaders, |
| vk::PipelineVertexInputStateCreateInfo const & | vertexInfo, | ||
| vk::PrimitiveTopology | prim, | ||
| bool | primRestart, | ||
| vk::ArrayProxy< vk::Viewport > const & | viewports, | ||
| vk::ArrayProxy< vk::Rect2D > const & | scissors, | ||
| bool | depthClamp, | ||
| vk::PolygonMode | polyMode, | ||
| vk::CullModeFlags | cullMode, | ||
| vk::FrontFace | front, | ||
| vk::PipelineLayout | layout, | ||
| vk::RenderPass | renderPass, | ||
| uint32_t | subPass, | ||
| vk::ArrayProxy< vk::DynamicState > const & | dynamic | ||
| ) |
Allocate a graphics pipeline.
| shaders | shaders for the pipeline |
| vertexInfo | vertex info |
| prim | primitive topology |
| primRestart | true if primitive restart should be enabled |
| viewports | vector of viewports; ignored if the viewport state is dynamic |
| scissors | vector of scissor rectangles; ignored if the scissor state is dynamic |
| depthClamp | true if depth clamping is enabled |
| polyMode | polygon mode |
| cullMode | primitive culling mode |
| front | the winding order that defines the front face of a triangle |
| layout | the pipeline layout |
| renderPass | a render pass that is compatible with the render pass to be used |
| subPass | the index of the subpass in the render pass where the pipeline will be used |
| dynamic | vector that specifies which parts of the pipeline can be dynamically set during the |
This function creates a pipeline with the following properties:
LESS is the depth-compare operation
|
inline |
Allocate a graphics pipeline using common defaults.
| shaders | shaders for the pipeline |
| vertexInfo | vertex info |
| prim | primitive topology |
| viewports | vector of viewports; ignored if the viewport state is dynamic |
| scissors | vector of scissor rectangles; ignored if the scissor state is dynamic |
| polyMode | polygon mode |
| cullMode | primitive culling mode |
| front | the winding order that defines the front face of a triangle |
| layout | the pipeline layout |
| renderPass | a render pass that is compatible with the render pass to be used |
| subPass | the index of the subpass in the render pass where the pipeline will be used |
| dynamic | vector that specifies which parts of the pipeline can be dynamically set during the |
This function creates a pipeline with the following properties:
LESS is the depth-compare operation
|
inline |
Create a pipeline layout.
| descSets | the descriptor sets for the pipeline |
| pcrs | the push-constant ranged for the pipeline |
Note that the Vulkan specification recommends using multiple descriptor sets when you have uniforms that are updated at different frequencies (e.g., per-scene vs. per-object). It also recommends putting the least frequently changing descriptor sets at the beginning.
|
inline |
Create a pipeline layout for a single descriptor set.
| descSet | the single descriptor sets for the pipeline |
| vk::Sampler cs237::Application::createSampler | ( | SamplerInfo const & | info | ) |
Create a texture sampler as specified.
| info | a simplified sampler specification |
|
inline |
is the program in debug mode?
|
inline |
get the logical device
|
inline |
end the recording of commands in the give command buffer
| cmdBuf | the command buffer that we are recording in |
|
inline |
access function for the physical device features
|
inline |
access function for the properties of an image format
|
inline |
free the command buffer
| cmdBuf | the command buffer to free |
|
inline |
access function for the physical device limits
|
inline |
return the application name
|
inline |
create and initialize a command buffer
|
inline |
get the physical-device properties pointer
|
pure virtual |
main function for running the application
|
inline |
end the commands and submit the buffer to the graphics queue.
| cmdBuf | the command buffer to submit |
|
inline |
Get the list of supported Vulkan device extensions for the selected physical device.
|
inlinestatic |
Get the list of supported Vulkan instance extensions.
|
inlinestatic |
Get the list of supported layers.
|
inline |
is the program in verbose mode?
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
pool for allocating command buffers
|
protected |
set when validation layers should be enabled
|
protected |
|
protected |
the logical device that we are using to render
|
mutableprotected |
a cache of the physical device properties
|
protected |
the graphics card (aka device) that we are using
|
protected |
the Vulkan instance used by the application
|
protected |
set to the message severity level
|
protected |
the application name
|
mutableprotected |
|
protected |
the queue family indices
|
protected |
the device queues that we are using