Fixing struct chaining as well as sampler LoD clamping
This commit is contained in:
@@ -72,7 +72,7 @@ struct SamplerCreateInfo {
|
||||
uint32 compareEnable = 0;
|
||||
Gfx::SeCompareOp compareOp = Gfx::SE_COMPARE_OP_NEVER;
|
||||
float minLod = 0.0f;
|
||||
float maxLod = 0.0f;
|
||||
float maxLod = 10000.0f;
|
||||
Gfx::SeBorderColor borderColor = Gfx::SE_BORDER_COLOR_FLOAT_OPAQUE_BLACK;
|
||||
uint32 unnormalizedCoordinates = 0;
|
||||
std::string name;
|
||||
|
||||
@@ -754,6 +754,7 @@ void Graphics::pickPhysicalDevice() {
|
||||
vkGetPhysicalDeviceProperties2(physicalDevice, &props.get());
|
||||
features.get<VkPhysicalDeviceFeatures2>().features = {
|
||||
.geometryShader = true,
|
||||
.sampleRateShading = true,
|
||||
.fillModeNonSolid = true,
|
||||
.wideLines = true,
|
||||
.pipelineStatisticsQuery = true,
|
||||
@@ -771,13 +772,13 @@ void Graphics::pickPhysicalDevice() {
|
||||
features.get<VkPhysicalDeviceVulkan12Features>().storageBuffer8BitAccess = true;
|
||||
features.get<VkPhysicalDeviceVulkan12Features>().shaderInt8 = true;
|
||||
|
||||
features.get<VkPhysicalDeviceAccelerationStructureFeaturesKHR>().accelerationStructure = true;
|
||||
rayTracingFeatures.get<VkPhysicalDeviceAccelerationStructureFeaturesKHR>().accelerationStructure = true;
|
||||
|
||||
features.get<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>().rayTracingPipeline = true;
|
||||
rayTracingFeatures.get<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>().rayTracingPipeline = true;
|
||||
|
||||
features.get<VkPhysicalDeviceMeshShaderFeaturesEXT>().meshShader = true;
|
||||
features.get<VkPhysicalDeviceMeshShaderFeaturesEXT>().taskShader = true;
|
||||
features.get<VkPhysicalDeviceMeshShaderFeaturesEXT>().meshShaderQueries = true;
|
||||
meshFeatures.get<VkPhysicalDeviceMeshShaderFeaturesEXT>().meshShader = true;
|
||||
meshFeatures.get<VkPhysicalDeviceMeshShaderFeaturesEXT>().taskShader = true;
|
||||
meshFeatures.get<VkPhysicalDeviceMeshShaderFeaturesEXT>().meshShaderQueries = true;
|
||||
bool rayTracingPipelineSupport = false;
|
||||
bool accelerationStructureSupport = false;
|
||||
bool hostOperationsSupport = false;
|
||||
@@ -891,6 +892,7 @@ void Graphics::createDevice(GraphicsInitializer initializer) {
|
||||
initializer.deviceExtensions.add(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
|
||||
if (supportMeshShading()) {
|
||||
initializer.deviceExtensions.add(VK_EXT_MESH_SHADER_EXTENSION_NAME);
|
||||
features.get<VkPhysicalDeviceVulkan12Features>().pNext = &meshFeatures.get();
|
||||
}
|
||||
if (supportRayTracing()) {
|
||||
// ray tracing itself
|
||||
@@ -904,6 +906,11 @@ void Graphics::createDevice(GraphicsInitializer initializer) {
|
||||
initializer.deviceExtensions.add(VK_KHR_SPIRV_1_4_EXTENSION_NAME);
|
||||
// required for spirv_1_4
|
||||
initializer.deviceExtensions.add(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME);
|
||||
if (supportMeshShading()) {
|
||||
meshFeatures.get().pNext = &rayTracingFeatures.get();
|
||||
} else {
|
||||
features.get<VkPhysicalDeviceVulkan12Features>().pNext = &rayTracingFeatures.get();
|
||||
}
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
initializer.deviceExtensions.add("VK_KHR_portability_subset");
|
||||
|
||||
@@ -193,14 +193,15 @@ class Graphics : public Gfx::Graphics {
|
||||
Helper<VkPhysicalDeviceAccelerationStructurePropertiesKHR, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR>>
|
||||
props;
|
||||
|
||||
StructChain<Helper<VkPhysicalDeviceFeatures2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2>,
|
||||
Helper<VkPhysicalDeviceVulkan11Features, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES>,
|
||||
Helper<VkPhysicalDeviceVulkan12Features, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES>>
|
||||
features;
|
||||
StructChain<Helper<VkPhysicalDeviceMeshShaderFeaturesEXT, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT>> meshFeatures;
|
||||
StructChain<
|
||||
Helper<VkPhysicalDeviceFeatures2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2>,
|
||||
Helper<VkPhysicalDeviceVulkan11Features, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES>,
|
||||
Helper<VkPhysicalDeviceVulkan12Features, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES>,
|
||||
Helper<VkPhysicalDeviceMeshShaderFeaturesEXT, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT>,
|
||||
Helper<VkPhysicalDeviceAccelerationStructureFeaturesKHR, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR>,
|
||||
Helper<VkPhysicalDeviceRayTracingPipelineFeaturesKHR, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR>>
|
||||
features;
|
||||
rayTracingFeatures;
|
||||
|
||||
VkDebugUtilsMessengerEXT callback;
|
||||
Map<uint32, OFramebuffer> allocatedFramebuffers;
|
||||
|
||||
@@ -28,23 +28,24 @@ VkImageAspectFlags getAspectFromFormat(Gfx::SeFormat format) {
|
||||
}
|
||||
}
|
||||
|
||||
TextureView::TextureView(PTextureHandle source, VkImageView view) : source(source), view(view) {}
|
||||
TextureView::TextureView(PTextureHandle source, uint32 width, uint32 height, uint32 numLayers, uint32 numMipLevels, VkImageView view)
|
||||
: width(width), height(height), numLayers(numLayers), numMipLevels(numMipLevels), source(source), view(view) {}
|
||||
|
||||
TextureView::~TextureView() {}
|
||||
|
||||
Gfx::SeFormat TextureView::getFormat() const { return source->format; }
|
||||
|
||||
uint32 TextureView::getWidth() const { return source->width; }
|
||||
uint32 TextureView::getWidth() const { return width; }
|
||||
|
||||
uint32 TextureView::getHeight() const { return source->height; }
|
||||
uint32 TextureView::getHeight() const { return height; }
|
||||
|
||||
uint32 TextureView::getDepth() const { return source->depth; }
|
||||
|
||||
uint32 TextureView::getNumLayers() const { return source->layerCount; }
|
||||
uint32 TextureView::getNumLayers() const { return numLayers; }
|
||||
|
||||
Gfx::SeSampleCountFlags TextureView::getNumSamples() const { return source->samples; }
|
||||
|
||||
uint32 TextureView::getMipLevels() const { return source->mipLevels; }
|
||||
uint32 TextureView::getMipLevels() const { return numMipLevels; }
|
||||
|
||||
Gfx::SeImageLayout TextureView::getLayout() const { return source->layout; }
|
||||
|
||||
@@ -60,13 +61,13 @@ void TextureView::changeLayout(Gfx::SeImageLayout newLayout, VkAccessFlags srcAc
|
||||
|
||||
void TextureView::setLayout(Gfx::SeImageLayout layout) { source->layout = layout; }
|
||||
|
||||
Gfx::OTextureView TextureHandle::createTextureView(uint32 baseMipLevel, uint32 levelCount, uint32 baseArrayLayer, uint32 layerCount) {
|
||||
Gfx::OTextureView TextureHandle::createTextureView(uint32 baseMipLevel, uint32 viewLevelCount, uint32 baseArrayLayer, uint32 viewLayerCount) {
|
||||
VkImageView view;
|
||||
VkImageViewType type = viewType;
|
||||
if (type == VK_IMAGE_VIEW_TYPE_CUBE || type == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) {
|
||||
if (layerCount == 1) {
|
||||
if (viewLayerCount == 1) {
|
||||
type = VK_IMAGE_VIEW_TYPE_2D;
|
||||
} else if (layerCount % 6 != 0) {
|
||||
} else if (viewLayerCount % 6 != 0) {
|
||||
type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
|
||||
}
|
||||
}
|
||||
@@ -81,13 +82,15 @@ Gfx::OTextureView TextureHandle::createTextureView(uint32 baseMipLevel, uint32 l
|
||||
{
|
||||
.aspectMask = aspect,
|
||||
.baseMipLevel = baseMipLevel,
|
||||
.levelCount = levelCount,
|
||||
.levelCount = viewLevelCount,
|
||||
.baseArrayLayer = baseArrayLayer,
|
||||
.layerCount = layerCount,
|
||||
.layerCount = viewLayerCount,
|
||||
},
|
||||
};
|
||||
vkCreateImageView(graphics->getDevice(), &createInfo, nullptr, &view);
|
||||
return new TextureView(this, view);
|
||||
uint32 viewWidth = width * std::pow(0.5, baseMipLevel);
|
||||
uint32 viewHeight = height * std::pow(0.5, baseMipLevel);
|
||||
return new TextureView(this, viewWidth, viewHeight, viewLayerCount, viewLevelCount, view);
|
||||
}
|
||||
|
||||
TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage)
|
||||
@@ -213,24 +216,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
||||
graphics->getDestructionManager()->queueResourceForDestruction(std::move(stagingAlloc));
|
||||
}
|
||||
}
|
||||
VkImageView view;
|
||||
VkImageViewCreateInfo viewInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.image = image,
|
||||
.viewType = viewType,
|
||||
.format = cast(format),
|
||||
.subresourceRange =
|
||||
{
|
||||
.aspectMask = aspect,
|
||||
.levelCount = mipLevels,
|
||||
.layerCount = layerCount,
|
||||
},
|
||||
};
|
||||
|
||||
VK_CHECK(vkCreateImageView(graphics->getDevice(), &viewInfo, nullptr, &view));
|
||||
imageView = new TextureView(this, view);
|
||||
imageView = createTextureView(0, mipLevels, 0, layerCount);
|
||||
}
|
||||
|
||||
TextureHandle::~TextureHandle() {
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Vulkan {
|
||||
DECLARE_REF(TextureHandle)
|
||||
class TextureView : public Gfx::TextureView {
|
||||
public:
|
||||
TextureView(PTextureHandle source, VkImageView view);
|
||||
TextureView(PTextureHandle source, uint32 width, uint32 height, uint32 numLayers, uint32 numMipLevels, VkImageView view);
|
||||
virtual ~TextureView();
|
||||
virtual Gfx::SeFormat getFormat() const override;
|
||||
virtual uint32 getWidth() const override;
|
||||
@@ -28,6 +28,10 @@ public:
|
||||
PTextureHandle getSource() const { return source; }
|
||||
void setLayout(Gfx::SeImageLayout layout);
|
||||
private:
|
||||
uint32 width;
|
||||
uint32 height;
|
||||
uint32 numLayers;
|
||||
uint32 numMipLevels;
|
||||
PTextureHandle source;
|
||||
VkImageView view;
|
||||
friend class TextureBase;
|
||||
|
||||
Reference in New Issue
Block a user