Add createSamplers for GEVulkanDriver
This commit is contained in:
parent
8e64c69c5d
commit
3ccdfaf70d
@ -11,6 +11,7 @@
|
||||
#include "../source/Irrlicht/CNullDriver.h"
|
||||
#include "SIrrCreationParameters.h"
|
||||
#include "SColor.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -19,6 +20,11 @@ using namespace video;
|
||||
|
||||
namespace GE
|
||||
{
|
||||
enum GEVulkanSampler : unsigned
|
||||
{
|
||||
GVS_MIN,
|
||||
GVS_NEAREST = GVS_MIN
|
||||
};
|
||||
class GEVulkanDriver : public video::CNullDriver
|
||||
{
|
||||
public:
|
||||
@ -261,6 +267,12 @@ namespace GE
|
||||
|
||||
virtual void enableScissorTest(const core::rect<s32>& r) {}
|
||||
virtual void disableScissorTest() {}
|
||||
VkSampler getSampler(GEVulkanSampler s) const
|
||||
{
|
||||
if (m_vk.samplers.find(s) == m_vk.samplers.end())
|
||||
return VK_NULL_HANDLE;
|
||||
return m_vk.samplers.at(s);
|
||||
}
|
||||
|
||||
private:
|
||||
struct SwapChainSupportDetails
|
||||
@ -316,6 +328,7 @@ namespace GE
|
||||
std::vector<VkFence> in_flight_fences;
|
||||
VkCommandPool command_pool;
|
||||
std::vector<VkCommandBuffer> command_buffers;
|
||||
std::map<GEVulkanSampler, VkSampler> samplers;
|
||||
VK()
|
||||
{
|
||||
instance = VK_NULL_HANDLE;
|
||||
@ -326,6 +339,8 @@ namespace GE
|
||||
}
|
||||
~VK()
|
||||
{
|
||||
for (auto& sampler : samplers)
|
||||
vkDestroySampler(device, sampler.second, NULL);
|
||||
if (!command_buffers.empty())
|
||||
{
|
||||
vkFreeCommandBuffers(device, command_pool,
|
||||
@ -383,6 +398,7 @@ namespace GE
|
||||
void createSyncObjects();
|
||||
void createCommandPool();
|
||||
void createCommandBuffers();
|
||||
void createSamplers();
|
||||
std::string getVulkanVersionString() const;
|
||||
std::string getDriverVersionString() const;
|
||||
};
|
||||
|
@ -488,6 +488,7 @@ GEVulkanDriver::GEVulkanDriver(const SIrrlichtCreationParameters& params,
|
||||
createSyncObjects();
|
||||
createCommandPool();
|
||||
createCommandBuffers();
|
||||
createSamplers();
|
||||
os::Printer::log("Vulkan version", getVulkanVersionString().c_str());
|
||||
os::Printer::log("Vulkan vendor", getVendorInfo().c_str());
|
||||
os::Printer::log("Vulkan renderer", m_properties.deviceName);
|
||||
@ -978,6 +979,34 @@ void GEVulkanDriver::createCommandBuffers()
|
||||
m_vk.command_buffers = buffers;
|
||||
} // createCommandBuffers
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void GEVulkanDriver::createSamplers()
|
||||
{
|
||||
VkSampler sampler = VK_NULL_HANDLE;
|
||||
bool supported_anisotropy = m_features.samplerAnisotropy == VK_TRUE;
|
||||
// GVS_NEAREST
|
||||
VkSamplerCreateInfo sampler_info = {};
|
||||
sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||
sampler_info.magFilter = VK_FILTER_NEAREST;
|
||||
sampler_info.minFilter = VK_FILTER_NEAREST;
|
||||
sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
sampler_info.anisotropyEnable = supported_anisotropy;
|
||||
sampler_info.maxAnisotropy = 1.0;
|
||||
sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
|
||||
sampler_info.unnormalizedCoordinates = VK_FALSE;
|
||||
sampler_info.compareEnable = VK_FALSE;
|
||||
sampler_info.compareOp = VK_COMPARE_OP_ALWAYS;
|
||||
sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
|
||||
VkResult result = vkCreateSampler(m_vk.device, &sampler_info, NULL,
|
||||
&sampler);
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkCreateSampler failed for GVS_NEAREST");
|
||||
m_vk.samplers[GVS_NEAREST] = sampler;
|
||||
} // createSamplers
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void GEVulkanDriver::OnResize(const core::dimension2d<u32>& size)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user