Fixing sampler parameters

This commit is contained in:
Dynamitos
2025-04-17 08:36:47 +02:00
parent 1efb696d92
commit 8375a837c8
5 changed files with 75 additions and 41 deletions
+1 -21
View File
@@ -285,27 +285,7 @@ Gfx::PComputePipeline Graphics::createComputePipeline(Gfx::ComputePipelineCreate
}
Gfx::OSampler Graphics::createSampler(const SamplerCreateInfo& createInfo) {
VkSamplerCreateInfo vkInfo = {
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.pNext = nullptr,
.flags = createInfo.flags,
.magFilter = cast(createInfo.magFilter),
.minFilter = cast(createInfo.minFilter),
.mipmapMode = cast(createInfo.mipmapMode),
.addressModeU = cast(createInfo.addressModeU),
.addressModeV = cast(createInfo.addressModeV),
.addressModeW = cast(createInfo.addressModeW),
.mipLodBias = createInfo.mipLodBias,
.anisotropyEnable = createInfo.anisotropyEnable,
.maxAnisotropy = createInfo.maxAnisotropy,
.compareEnable = createInfo.compareEnable,
.compareOp = cast(createInfo.compareOp),
.minLod = createInfo.minLod,
.maxLod = createInfo.maxLod,
.borderColor = cast(createInfo.borderColor),
.unnormalizedCoordinates = createInfo.unnormalizedCoordinates,
};
return new Sampler(this, vkInfo);
return new Sampler(this, createInfo);
}
Gfx::ODescriptorLayout Graphics::createDescriptorLayout(const std::string& name) { return new DescriptorLayout(this, name); }
+24 -4
View File
@@ -110,13 +110,33 @@ void DestructionManager::notifyCommandComplete() {
}
}
SamplerHandle::SamplerHandle(PGraphics graphics, VkSamplerCreateInfo createInfo) : CommandBoundResource(graphics, "Sampler") {
vkCreateSampler(graphics->getDevice(), &createInfo, nullptr, &sampler);
SamplerHandle::SamplerHandle(PGraphics graphics, SamplerCreateInfo createInfo) : CommandBoundResource(graphics, "Sampler") {
VkSamplerCreateInfo vkInfo = {
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.pNext = nullptr,
.flags = createInfo.flags,
.magFilter = cast(createInfo.magFilter),
.minFilter = cast(createInfo.minFilter),
.mipmapMode = cast(createInfo.mipmapMode),
.addressModeU = cast(createInfo.addressModeU),
.addressModeV = cast(createInfo.addressModeV),
.addressModeW = cast(createInfo.addressModeW),
.mipLodBias = createInfo.mipLodBias,
.anisotropyEnable = createInfo.anisotropyEnable,
.maxAnisotropy = createInfo.maxAnisotropy,
.compareEnable = createInfo.compareEnable,
.compareOp = cast(createInfo.compareOp),
.minLod = createInfo.minLod,
.maxLod = createInfo.maxLod,
.borderColor = cast(createInfo.borderColor),
.unnormalizedCoordinates = createInfo.unnormalizedCoordinates,
};
vkCreateSampler(graphics->getDevice(), &vkInfo, nullptr, &sampler);
}
SamplerHandle::~SamplerHandle() { vkDestroySampler(graphics->getDevice(), sampler, nullptr); }
Sampler::Sampler(PGraphics graphics, VkSamplerCreateInfo createInfo)
: graphics(graphics), handle(new SamplerHandle(graphics, createInfo)) {}
Sampler::Sampler(PGraphics graphics, SamplerCreateInfo createInfo)
: Gfx::Sampler(createInfo), graphics(graphics), handle(new SamplerHandle(graphics, createInfo)) {}
Sampler::~Sampler() { graphics->getDestructionManager()->queueResourceForDestruction(std::move(handle)); }
+2 -2
View File
@@ -106,7 +106,7 @@ DEFINE_REF(DestructionManager)
class SamplerHandle : public CommandBoundResource {
public:
SamplerHandle(PGraphics graphics, VkSamplerCreateInfo createInfo);
SamplerHandle(PGraphics graphics, SamplerCreateInfo createInfo);
virtual ~SamplerHandle();
VkSampler sampler;
};
@@ -114,7 +114,7 @@ DEFINE_REF(SamplerHandle)
class Sampler : public Gfx::Sampler {
public:
Sampler(PGraphics graphics, VkSamplerCreateInfo createInfo);
Sampler(PGraphics graphics, SamplerCreateInfo createInfo);
virtual ~Sampler();
PSamplerHandle getHandle() const { return handle; }
VkSampler getSampler() const { return handle->sampler; }