2026-07-22 18:09:06 +02:00
|
|
|
|
//SPDX-License-Identifier: LGPL-3.0-only
|
|
|
|
|
|
//SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
2026-05-02 21:08:20 +02:00
|
|
|
|
|
|
|
|
|
|
module;
|
|
|
|
|
|
#include "vulkan/vulkan.h"
|
|
|
|
|
|
module Crafter.Graphics:UI_impl;
|
|
|
|
|
|
import :UI;
|
|
|
|
|
|
import :ComputeShader;
|
|
|
|
|
|
import :Device;
|
|
|
|
|
|
import :Window;
|
|
|
|
|
|
import :DescriptorHeapVulkan;
|
|
|
|
|
|
import :ImageVulkan;
|
|
|
|
|
|
import :VulkanBuffer;
|
|
|
|
|
|
import :FontAtlas;
|
|
|
|
|
|
import :Font;
|
2026-05-18 04:58:52 +02:00
|
|
|
|
import :GraphicsTypes;
|
2026-05-02 21:08:20 +02:00
|
|
|
|
import std;
|
|
|
|
|
|
|
|
|
|
|
|
using namespace Crafter;
|
|
|
|
|
|
|
|
|
|
|
|
// ─── Initialize ─────────────────────────────────────────────────────────
|
|
|
|
|
|
|
2026-05-18 04:58:52 +02:00
|
|
|
|
void UIRenderer::Initialize(Window& window, GraphicsDescriptorHeap& heap, GraphicsCommandBuffer initCmd,
|
2026-05-02 21:08:20 +02:00
|
|
|
|
std::filesystem::path quadsSpv,
|
|
|
|
|
|
std::filesystem::path circlesSpv,
|
|
|
|
|
|
std::filesystem::path imagesSpv,
|
2026-06-16 17:03:24 +00:00
|
|
|
|
std::filesystem::path textSpv,
|
|
|
|
|
|
std::filesystem::path fusedSpv) {
|
2026-05-02 21:08:20 +02:00
|
|
|
|
window_ = &window;
|
|
|
|
|
|
heap_ = &heap;
|
|
|
|
|
|
|
2026-06-16 17:03:24 +00:00
|
|
|
|
// Load the four standard pipelines plus the fused uber-kernel (issue #47).
|
feat(vulkan): run the compute/UI path without VK_EXT_descriptor_heap
Device::Initialize required twelve device extensions with no capability
check. Mesa Turnip (Adreno) lacks six of them: VK_EXT_descriptor_heap,
VK_KHR_shader_untyped_pointers, VK_EXT_device_fault and the three ray
tracing extensions. vkCreateDevice failed there, so not even a UI-only
program could start, although the UI path is compute-only and needs
nothing else that Turnip is missing.
The descriptor heap, ray tracing and device fault are now optional
groups, detected at start-up from the extension list and the feature
bits (Device::descriptorHeapSupported, rayTracingSupported,
deviceFaultSupported). Ray tracing needs the heap; on a device without
it the ray tracing entry points throw a message naming the cause.
Without the heap the same bindless slots live in one update-after-bind
descriptor set per frame, owned by DescriptorHeapVulkan: binding 0
storage images, 1 sampled images, 2 samplers, 3 storage buffers. Slot
allocation, the slot handles, UIDispatchHeader and the UIRenderer API
are unchanged; buffer slots simply stop being offset. Window::Render
binds that frame's set where it binds the heap, every compute pipeline
shares the heap object's pipeline layout, and push data travels as push
constants.
Each UI kernel is built twice from one source. ui-shared.glsl declares
its resources through UI_HEAP_* macros that expand to descriptor_heap
or, with CRAFTER_GRAPHICS_DESCRIPTOR_SETS defined, to set/binding.
<name>.comp.spv and <name>.comp.sets.spv ship side by side and
ComputeShader::Load picks one. The heap build of every shader is
byte-identical to before.
Breaking:
- ComputeShader::Load takes the heap as a second argument.
- DescriptorHeapVulkan is no longer copyable or movable.
- Custom UI shaders declare heap resources with the UI_HEAP_* macros
and are registered twice in project.cpp (see the README).
- project.cpp uses Shader::defines and Shader::variant, so it needs a
crafter-build that has them (Crafter.Build master, fe38cc1 or later).
Also:
- maintenance5 is enabled as a feature, not only as an extension:
every VulkanBuffer already relied on VkBufferUsageFlags2CreateInfo.
- Barrier stage masks drop RAY_TRACING_SHADER on devices without ray
tracing, and ImageVulkan::Create resolves its default consumer stage
to COMPUTE_SHADER there.
- Window refuses a swapchain whose image count is not numFrames
instead of writing past images[]. The limitation itself is #160.
- CRAFTER_GRAPHICS_NO_DESCRIPTOR_HEAP forces the fallback on a driver
that has the heap, so it can be exercised on a desktop GPU.
Verified on an RTX 4090 in both modes under the validation layer, and
on a Fairphone 6 (Turnip, Adreno 810, postmarketOS), where the fallback
is the only path.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 17:28:46 +02:00
|
|
|
|
drawQuads.Load(quadsSpv, heap);
|
|
|
|
|
|
drawCircles.Load(circlesSpv, heap);
|
|
|
|
|
|
drawImages.Load(imagesSpv, heap);
|
|
|
|
|
|
drawText.Load(textSpv, heap);
|
|
|
|
|
|
drawFused.Load(fusedSpv, heap);
|
2026-05-02 21:08:20 +02:00
|
|
|
|
|
|
|
|
|
|
// Allocate one image slot for the swapchain output. Each per-frame heap
|
|
|
|
|
|
// copy will hold ITS frame's image at this slot.
|
|
|
|
|
|
auto outRange = heap_->AllocateImageSlots(1);
|
2026-05-05 00:02:04 +02:00
|
|
|
|
outImageSlot_ = ImageSlot{heap_, outRange.firstElement};
|
2026-05-02 21:08:20 +02:00
|
|
|
|
|
|
|
|
|
|
WriteSwapchainDescriptors();
|
|
|
|
|
|
|
|
|
|
|
|
// Optional font-atlas registration (user must have called atlas->Initialize
|
|
|
|
|
|
// already before reaching here, so atlas->image is live).
|
|
|
|
|
|
if (fontAtlas != nullptr) {
|
|
|
|
|
|
auto atlasImg = heap_->AllocateImageSlots(1);
|
2026-05-05 00:02:04 +02:00
|
|
|
|
fontAtlasImageSlot_ = ImageSlot{heap_, atlasImg.firstElement};
|
2026-05-02 21:08:20 +02:00
|
|
|
|
fontAtlasSamplerSlot_ = RegisterLinearClampSampler();
|
|
|
|
|
|
WriteFontAtlasDescriptor();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-16 18:29:24 +00:00
|
|
|
|
// No whole-heap flush here: WriteSwapchainDescriptors / WriteFontAtlasDescriptor
|
|
|
|
|
|
// / RegisterSampler each flush their own written byte range above, so the GPU
|
|
|
|
|
|
// already sees everything written during setup.
|
2026-05-02 21:08:20 +02:00
|
|
|
|
|
2026-05-12 00:24:48 +02:00
|
|
|
|
// Re-bind the swapchain image descriptors after every resize. Window
|
|
|
|
|
|
// already drained the queue and rebuilt the imageViews[] before
|
|
|
|
|
|
// firing the event, so vkWriteResourceDescriptorsEXT is safe here.
|
2026-06-16 18:29:24 +00:00
|
|
|
|
// WriteSwapchainDescriptors flushes its own range, so no extra flush needed.
|
2026-05-12 00:24:48 +02:00
|
|
|
|
resizeSub_.SetEvent(&window.onResize, [this]() {
|
|
|
|
|
|
WriteSwapchainDescriptors();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-05-02 21:08:20 +02:00
|
|
|
|
(void)initCmd; // reserved for future image-layout tweaks
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ─── per-frame Record ───────────────────────────────────────────────────
|
|
|
|
|
|
|
2026-05-18 04:58:52 +02:00
|
|
|
|
void UIRenderer::Record(GraphicsCommandBuffer cmd, std::uint32_t frameIdx, Window& window) {
|
2026-05-02 21:08:20 +02:00
|
|
|
|
// Reset per-frame state.
|
|
|
|
|
|
firstDispatchThisFrame_ = true;
|
|
|
|
|
|
|
|
|
|
|
|
// If text is in use, flush any glyphs that user-side ShapeText calls
|
|
|
|
|
|
// produced during a previous frame's onBuild. (Ensure() during the
|
|
|
|
|
|
// current onBuild also marks the atlas dirty; that's flushed on the
|
|
|
|
|
|
// NEXT Record. For v1 this is fine because the current frame's text
|
|
|
|
|
|
// dispatch reads whatever's already been uploaded, and brand-new glyphs
|
|
|
|
|
|
// missing from the atlas this frame will simply render blank for one
|
|
|
|
|
|
// frame and resolve next frame. To get them this frame, the user can
|
|
|
|
|
|
// call atlas->Update(cmd) themselves at the top of onBuild.)
|
|
|
|
|
|
if (fontAtlas != nullptr && fontAtlas->dirty) {
|
|
|
|
|
|
fontAtlas->Update(cmd);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onBuild.Invoke({cmd, frameIdx});
|
|
|
|
|
|
|
|
|
|
|
|
(void)window;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ─── group-count helper ────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
// Number of 8-pixel tiles needed to cover `dim` pixels (rounded up).
|
|
|
|
|
|
inline std::uint32_t TilesFor(std::uint32_t dim) {
|
|
|
|
|
|
return (dim + 7u) / 8u;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ─── standard-shader convenience dispatches ─────────────────────────────
|
|
|
|
|
|
//
|
|
|
|
|
|
// All four standard shaders use the same pixel-tile dispatch model: one
|
|
|
|
|
|
// workgroup per 8×8 screen tile, each thread iterates every item in order
|
|
|
|
|
|
// inside the workgroup, accumulating into a local register. This guarantees
|
|
|
|
|
|
// "items in the buffer render in order" (later items overdraw earlier ones)
|
|
|
|
|
|
// without inter-workgroup races on imageLoad/imageStore — the bug that the
|
|
|
|
|
|
// per-item dispatch model had.
|
|
|
|
|
|
|
2026-05-18 04:58:52 +02:00
|
|
|
|
void UIRenderer::DispatchQuads(GraphicsCommandBuffer cmd, std::uint32_t bufferSlot,
|
2026-05-02 21:08:20 +02:00
|
|
|
|
std::uint32_t itemCount,
|
|
|
|
|
|
std::array<float,4> clipRectPx) {
|
|
|
|
|
|
if (itemCount == 0) return;
|
|
|
|
|
|
struct PC { UIDispatchHeader hdr; } pc { FillHeader(bufferSlot, itemCount, clipRectPx) };
|
|
|
|
|
|
Dispatch(cmd, drawQuads, &pc, sizeof(pc),
|
|
|
|
|
|
TilesFor(window_->width), TilesFor(window_->height), 1u);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 04:58:52 +02:00
|
|
|
|
void UIRenderer::DispatchCircles(GraphicsCommandBuffer cmd, std::uint32_t bufferSlot,
|
2026-05-02 21:08:20 +02:00
|
|
|
|
std::uint32_t itemCount,
|
|
|
|
|
|
std::array<float,4> clipRectPx) {
|
|
|
|
|
|
if (itemCount == 0) return;
|
|
|
|
|
|
struct PC { UIDispatchHeader hdr; } pc { FillHeader(bufferSlot, itemCount, clipRectPx) };
|
|
|
|
|
|
Dispatch(cmd, drawCircles, &pc, sizeof(pc),
|
|
|
|
|
|
TilesFor(window_->width), TilesFor(window_->height), 1u);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 04:58:52 +02:00
|
|
|
|
void UIRenderer::DispatchImages(GraphicsCommandBuffer cmd, std::uint32_t bufferSlot,
|
2026-05-02 21:08:20 +02:00
|
|
|
|
std::uint32_t itemCount,
|
|
|
|
|
|
std::array<float,4> clipRectPx) {
|
|
|
|
|
|
if (itemCount == 0) return;
|
|
|
|
|
|
struct PC { UIDispatchHeader hdr; } pc { FillHeader(bufferSlot, itemCount, clipRectPx) };
|
|
|
|
|
|
Dispatch(cmd, drawImages, &pc, sizeof(pc),
|
|
|
|
|
|
TilesFor(window_->width), TilesFor(window_->height), 1u);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 04:58:52 +02:00
|
|
|
|
void UIRenderer::DispatchText(GraphicsCommandBuffer cmd, std::uint32_t bufferSlot,
|
2026-05-02 21:08:20 +02:00
|
|
|
|
std::uint32_t itemCount,
|
|
|
|
|
|
std::array<float,4> clipRectPx) {
|
|
|
|
|
|
if (itemCount == 0) return;
|
2026-05-05 00:02:04 +02:00
|
|
|
|
if (!fontAtlasImageSlot_) {
|
2026-05-02 21:08:20 +02:00
|
|
|
|
throw std::runtime_error("UIRenderer::DispatchText: no FontAtlas registered (set fontAtlas before Initialize)");
|
|
|
|
|
|
}
|
|
|
|
|
|
// Flush any glyphs that ShapeText calls (during this onBuild) just
|
|
|
|
|
|
// rasterised, so the dispatch below sees them.
|
|
|
|
|
|
if (fontAtlas != nullptr && fontAtlas->dirty) {
|
|
|
|
|
|
fontAtlas->Update(cmd);
|
|
|
|
|
|
}
|
|
|
|
|
|
struct PC {
|
|
|
|
|
|
UIDispatchHeader hdr;
|
|
|
|
|
|
std::uint32_t fontTextureSlot;
|
|
|
|
|
|
std::uint32_t fontSamplerSlot;
|
|
|
|
|
|
std::uint32_t _p0;
|
|
|
|
|
|
std::uint32_t _p1;
|
|
|
|
|
|
} pc {
|
|
|
|
|
|
FillHeader(bufferSlot, itemCount, clipRectPx),
|
|
|
|
|
|
fontAtlasImageSlot_,
|
|
|
|
|
|
fontAtlasSamplerSlot_,
|
|
|
|
|
|
0, 0
|
|
|
|
|
|
};
|
|
|
|
|
|
Dispatch(cmd, drawText, &pc, sizeof(pc),
|
|
|
|
|
|
TilesFor(window_->width), TilesFor(window_->height), 1u);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-16 17:03:24 +00:00
|
|
|
|
// ─── fused dispatch (issue #47) ─────────────────────────────────────────
|
|
|
|
|
|
//
|
|
|
|
|
|
// One uber-kernel composites quads → circles → images → text into the output
|
|
|
|
|
|
// image with a single load and a single store. Routed through the generic
|
|
|
|
|
|
// Dispatch() so it still gets the standard write-after-write barrier when it
|
|
|
|
|
|
// is not the first dispatch of the frame, and a following dispatch barriers
|
|
|
|
|
|
// against it — the only barriers it removes are the INTRA-fuse ones a run of
|
|
|
|
|
|
// Dispatch* calls would have inserted between its categories.
|
|
|
|
|
|
|
|
|
|
|
|
void UIRenderer::DispatchFused(GraphicsCommandBuffer cmd,
|
|
|
|
|
|
const FusedBatch& quads,
|
|
|
|
|
|
const FusedBatch& circles,
|
|
|
|
|
|
const FusedBatch& images,
|
|
|
|
|
|
const FusedBatch& text) {
|
|
|
|
|
|
// Nothing to draw → no dispatch (and, crucially, no barrier bump).
|
|
|
|
|
|
if (quads.itemCount == 0 && circles.itemCount == 0 &&
|
|
|
|
|
|
images.itemCount == 0 && text.itemCount == 0) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (text.itemCount != 0 && !fontAtlasImageSlot_) {
|
|
|
|
|
|
throw std::runtime_error("UIRenderer::DispatchFused: text batch given but no FontAtlas registered (set fontAtlas before Initialize)");
|
|
|
|
|
|
}
|
|
|
|
|
|
// Flush any glyphs ShapeText rasterised during this onBuild, mirroring
|
|
|
|
|
|
// DispatchText — only relevant when there is text to draw.
|
|
|
|
|
|
if (text.itemCount != 0 && fontAtlas != nullptr && fontAtlas->dirty) {
|
|
|
|
|
|
fontAtlas->Update(cmd);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UIFusedHeader pc{};
|
|
|
|
|
|
pc.itemBuffers[0] = quads.bufferSlot;
|
|
|
|
|
|
pc.itemBuffers[1] = circles.bufferSlot;
|
|
|
|
|
|
pc.itemBuffers[2] = images.bufferSlot;
|
|
|
|
|
|
pc.itemBuffers[3] = text.bufferSlot;
|
|
|
|
|
|
pc.itemCounts[0] = quads.itemCount;
|
|
|
|
|
|
pc.itemCounts[1] = circles.itemCount;
|
|
|
|
|
|
pc.itemCounts[2] = images.itemCount;
|
|
|
|
|
|
pc.itemCounts[3] = text.itemCount;
|
|
|
|
|
|
pc.outImage = outImageSlot_;
|
|
|
|
|
|
pc.fontTexture = fontAtlasImageSlot_;
|
|
|
|
|
|
pc.fontSampler = fontAtlasSamplerSlot_;
|
2026-06-16 17:09:06 +00:00
|
|
|
|
// Per-category clip-active bits, reusing the same surface-coverage test the
|
|
|
|
|
|
// standard path uses (ClipFlags). A category whose clip already covers the
|
|
|
|
|
|
// surface clears its bit so the kernel skips that category's per-pixel clip
|
|
|
|
|
|
// compares (the common full-surface case) — pixel-identical either way.
|
|
|
|
|
|
auto clipBit = [&](const FusedBatch& b, std::uint32_t bit) -> std::uint32_t {
|
|
|
|
|
|
return (ClipFlags(b.clipRectPx, window_->width, window_->height, 0) & kUIFlagClip) ? bit : 0u;
|
|
|
|
|
|
};
|
|
|
|
|
|
pc.flags = clipBit(quads, 0x1u) | clipBit(circles, 0x2u)
|
|
|
|
|
|
| clipBit(images, 0x4u) | clipBit(text, 0x8u);
|
2026-06-16 17:03:24 +00:00
|
|
|
|
pc.surfaceWidth = window_->width;
|
|
|
|
|
|
pc.surfaceHeight = window_->height;
|
|
|
|
|
|
pc.frameIdx = window_->currentBuffer;
|
|
|
|
|
|
pc._pad = 0;
|
|
|
|
|
|
std::copy(quads.clipRectPx.begin(), quads.clipRectPx.end(), pc.clipQuads);
|
|
|
|
|
|
std::copy(circles.clipRectPx.begin(), circles.clipRectPx.end(), pc.clipCircles);
|
|
|
|
|
|
std::copy(images.clipRectPx.begin(), images.clipRectPx.end(), pc.clipImages);
|
|
|
|
|
|
std::copy(text.clipRectPx.begin(), text.clipRectPx.end(), pc.clipText);
|
|
|
|
|
|
|
|
|
|
|
|
Dispatch(cmd, drawFused, &pc, sizeof(pc),
|
|
|
|
|
|
TilesFor(window_->width), TilesFor(window_->height), 1u);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-02 21:08:20 +02:00
|
|
|
|
// ─── generic Dispatch (with barrier) ────────────────────────────────────
|
|
|
|
|
|
|
2026-05-18 05:39:17 +02:00
|
|
|
|
void UIRenderer::Dispatch(GraphicsCommandBuffer cmd, const GraphicsComputeShader& shader,
|
2026-05-02 21:08:20 +02:00
|
|
|
|
const void* push, std::uint32_t pushBytes,
|
|
|
|
|
|
std::uint32_t gx, std::uint32_t gy, std::uint32_t gz) {
|
|
|
|
|
|
if (!firstDispatchThisFrame_) {
|
2026-06-16 16:53:51 +00:00
|
|
|
|
// Every UI pass read-modify-writes the same swapchain storage image
|
|
|
|
|
|
// (later passes overdraw earlier ones), so each dispatch must observe
|
|
|
|
|
|
// the previous dispatch's writes. The only resource the hazard touches
|
|
|
|
|
|
// is that one image, so scope the dependency to its subresource with a
|
|
|
|
|
|
// VkImageMemoryBarrier rather than a queue-wide VkMemoryBarrier: same
|
|
|
|
|
|
// correctness, but only this image's shader caches are flushed —
|
|
|
|
|
|
// unrelated buffers/images are no longer invalidated. The image stays
|
|
|
|
|
|
// in VK_IMAGE_LAYOUT_GENERAL (bound as a storage image), so this is a
|
|
|
|
|
|
// pure memory dependency, no layout transition.
|
|
|
|
|
|
//
|
|
|
|
|
|
// The execution dependency is still COMPUTE->COMPUTE over the whole
|
|
|
|
|
|
// queue, so the passes do NOT overlap — this is a narrower cache flush
|
|
|
|
|
|
// only. Eliminating the barriers entirely requires fusing the passes
|
|
|
|
|
|
// into one dispatch (tracked in #47); do not attempt that here.
|
|
|
|
|
|
VkImageMemoryBarrier ib {
|
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
|
|
|
|
|
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
|
|
|
|
|
|
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
|
|
|
|
|
|
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
|
|
|
|
|
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
|
|
|
|
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
|
|
|
|
|
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
|
|
|
|
|
.image = window_->images[window_->currentBuffer],
|
|
|
|
|
|
.subresourceRange = {
|
|
|
|
|
|
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
|
|
|
|
|
.baseMipLevel = 0,
|
|
|
|
|
|
.levelCount = 1,
|
|
|
|
|
|
.baseArrayLayer = 0,
|
|
|
|
|
|
.layerCount = 1,
|
|
|
|
|
|
},
|
2026-05-02 21:08:20 +02:00
|
|
|
|
};
|
|
|
|
|
|
vkCmdPipelineBarrier(cmd,
|
|
|
|
|
|
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
|
|
|
|
|
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
2026-06-16 16:53:51 +00:00
|
|
|
|
0, 0, nullptr, 0, nullptr, 1, &ib);
|
2026-05-02 21:08:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
firstDispatchThisFrame_ = false;
|
|
|
|
|
|
shader.Dispatch(cmd, push, pushBytes, gx, gy, gz);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ─── descriptor writes ─────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
void UIRenderer::WriteSwapchainDescriptors() {
|
feat(vulkan): run the compute/UI path without VK_EXT_descriptor_heap
Device::Initialize required twelve device extensions with no capability
check. Mesa Turnip (Adreno) lacks six of them: VK_EXT_descriptor_heap,
VK_KHR_shader_untyped_pointers, VK_EXT_device_fault and the three ray
tracing extensions. vkCreateDevice failed there, so not even a UI-only
program could start, although the UI path is compute-only and needs
nothing else that Turnip is missing.
The descriptor heap, ray tracing and device fault are now optional
groups, detected at start-up from the extension list and the feature
bits (Device::descriptorHeapSupported, rayTracingSupported,
deviceFaultSupported). Ray tracing needs the heap; on a device without
it the ray tracing entry points throw a message naming the cause.
Without the heap the same bindless slots live in one update-after-bind
descriptor set per frame, owned by DescriptorHeapVulkan: binding 0
storage images, 1 sampled images, 2 samplers, 3 storage buffers. Slot
allocation, the slot handles, UIDispatchHeader and the UIRenderer API
are unchanged; buffer slots simply stop being offset. Window::Render
binds that frame's set where it binds the heap, every compute pipeline
shares the heap object's pipeline layout, and push data travels as push
constants.
Each UI kernel is built twice from one source. ui-shared.glsl declares
its resources through UI_HEAP_* macros that expand to descriptor_heap
or, with CRAFTER_GRAPHICS_DESCRIPTOR_SETS defined, to set/binding.
<name>.comp.spv and <name>.comp.sets.spv ship side by side and
ComputeShader::Load picks one. The heap build of every shader is
byte-identical to before.
Breaking:
- ComputeShader::Load takes the heap as a second argument.
- DescriptorHeapVulkan is no longer copyable or movable.
- Custom UI shaders declare heap resources with the UI_HEAP_* macros
and are registered twice in project.cpp (see the README).
- project.cpp uses Shader::defines and Shader::variant, so it needs a
crafter-build that has them (Crafter.Build master, fe38cc1 or later).
Also:
- maintenance5 is enabled as a feature, not only as an extension:
every VulkanBuffer already relied on VkBufferUsageFlags2CreateInfo.
- Barrier stage masks drop RAY_TRACING_SHADER on devices without ray
tracing, and ImageVulkan::Create resolves its default consumer stage
to COMPUTE_SHADER there.
- Window refuses a swapchain whose image count is not numFrames
instead of writing past images[]. The limitation itself is #160.
- CRAFTER_GRAPHICS_NO_DESCRIPTOR_HEAP forces the fallback on a driver
that has the heap, so it can be exercised on a desktop GPU.
Verified on an RTX 4090 in both modes under the validation layer, and
on a Fairphone 6 (Turnip, Adreno 810, postmarketOS), where the fallback
is the only path.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 17:28:46 +02:00
|
|
|
|
if (!Device::descriptorHeapSupported) {
|
|
|
|
|
|
// Sets mode: each frame's descriptor set holds ITS swapchain image at
|
|
|
|
|
|
// outImageSlot_, through a view the heap object creates and owns.
|
|
|
|
|
|
for (std::uint8_t f = 0; f < Window::numFrames; ++f) {
|
|
|
|
|
|
heap_->WriteImageSet(f, outImageSlot_, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
|
|
|
|
|
window_->imageViews[f], VK_IMAGE_LAYOUT_GENERAL);
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-02 21:08:20 +02:00
|
|
|
|
// Each per-frame heap holds ITS swapchain image at outImageSlot_.
|
|
|
|
|
|
std::array<VkImageDescriptorInfoEXT, Window::numFrames> infos{};
|
|
|
|
|
|
std::array<VkResourceDescriptorInfoEXT, Window::numFrames> resources{};
|
|
|
|
|
|
std::array<VkHostAddressRangeEXT, Window::numFrames> destinations{};
|
|
|
|
|
|
|
|
|
|
|
|
for (std::uint32_t f = 0; f < Window::numFrames; ++f) {
|
|
|
|
|
|
infos[f] = {
|
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_IMAGE_DESCRIPTOR_INFO_EXT,
|
|
|
|
|
|
.pView = &window_->imageViews[f],
|
|
|
|
|
|
.layout = VK_IMAGE_LAYOUT_GENERAL,
|
|
|
|
|
|
};
|
|
|
|
|
|
resources[f] = {
|
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_RESOURCE_DESCRIPTOR_INFO_EXT,
|
|
|
|
|
|
.type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
|
|
|
|
|
.data = { .pImage = &infos[f] },
|
|
|
|
|
|
};
|
|
|
|
|
|
destinations[f] = {
|
|
|
|
|
|
.address = heap_->resourceHeap[f].value
|
|
|
|
|
|
+ heap_->ImageByteOffset(outImageSlot_),
|
|
|
|
|
|
.size = Device::descriptorHeapProperties.imageDescriptorSize,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
Device::vkWriteResourceDescriptorsEXT(
|
|
|
|
|
|
Device::device, Window::numFrames, resources.data(), destinations.data()
|
|
|
|
|
|
);
|
2026-06-16 18:29:24 +00:00
|
|
|
|
// Only the one image descriptor at outImageSlot_ changed in each per-frame
|
|
|
|
|
|
// heap (same slot offset in every frame), so flush just that byte range
|
|
|
|
|
|
// rather than the whole multi-KB heap.
|
|
|
|
|
|
const std::uint32_t off = heap_->ImageByteOffset(outImageSlot_);
|
|
|
|
|
|
const std::uint32_t sz = Device::descriptorHeapProperties.imageDescriptorSize;
|
|
|
|
|
|
for (auto& h : heap_->resourceHeap) h.FlushDevice(off, sz);
|
2026-05-02 21:08:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UIRenderer::WriteFontAtlasDescriptor() {
|
|
|
|
|
|
atlasViewCreateInfo_ = {
|
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
|
|
|
|
|
.image = fontAtlas->image.image,
|
|
|
|
|
|
.viewType = VK_IMAGE_VIEW_TYPE_2D,
|
|
|
|
|
|
.format = VK_FORMAT_R8_UNORM,
|
|
|
|
|
|
.components = {
|
|
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
|
|
|
|
},
|
|
|
|
|
|
.subresourceRange = {
|
|
|
|
|
|
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
|
|
|
|
|
.baseMipLevel = 0,
|
|
|
|
|
|
.levelCount = 1,
|
|
|
|
|
|
.baseArrayLayer = 0,
|
|
|
|
|
|
.layerCount = 1,
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
WriteSampledImageDescriptor(fontAtlasImageSlot_,
|
|
|
|
|
|
atlasViewCreateInfo_,
|
|
|
|
|
|
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UIRenderer::WriteSampledImageDescriptor(std::uint16_t slot,
|
|
|
|
|
|
const VkImageViewCreateInfo& viewInfo,
|
|
|
|
|
|
VkImageLayout layout) {
|
feat(vulkan): run the compute/UI path without VK_EXT_descriptor_heap
Device::Initialize required twelve device extensions with no capability
check. Mesa Turnip (Adreno) lacks six of them: VK_EXT_descriptor_heap,
VK_KHR_shader_untyped_pointers, VK_EXT_device_fault and the three ray
tracing extensions. vkCreateDevice failed there, so not even a UI-only
program could start, although the UI path is compute-only and needs
nothing else that Turnip is missing.
The descriptor heap, ray tracing and device fault are now optional
groups, detected at start-up from the extension list and the feature
bits (Device::descriptorHeapSupported, rayTracingSupported,
deviceFaultSupported). Ray tracing needs the heap; on a device without
it the ray tracing entry points throw a message naming the cause.
Without the heap the same bindless slots live in one update-after-bind
descriptor set per frame, owned by DescriptorHeapVulkan: binding 0
storage images, 1 sampled images, 2 samplers, 3 storage buffers. Slot
allocation, the slot handles, UIDispatchHeader and the UIRenderer API
are unchanged; buffer slots simply stop being offset. Window::Render
binds that frame's set where it binds the heap, every compute pipeline
shares the heap object's pipeline layout, and push data travels as push
constants.
Each UI kernel is built twice from one source. ui-shared.glsl declares
its resources through UI_HEAP_* macros that expand to descriptor_heap
or, with CRAFTER_GRAPHICS_DESCRIPTOR_SETS defined, to set/binding.
<name>.comp.spv and <name>.comp.sets.spv ship side by side and
ComputeShader::Load picks one. The heap build of every shader is
byte-identical to before.
Breaking:
- ComputeShader::Load takes the heap as a second argument.
- DescriptorHeapVulkan is no longer copyable or movable.
- Custom UI shaders declare heap resources with the UI_HEAP_* macros
and are registered twice in project.cpp (see the README).
- project.cpp uses Shader::defines and Shader::variant, so it needs a
crafter-build that has them (Crafter.Build master, fe38cc1 or later).
Also:
- maintenance5 is enabled as a feature, not only as an extension:
every VulkanBuffer already relied on VkBufferUsageFlags2CreateInfo.
- Barrier stage masks drop RAY_TRACING_SHADER on devices without ray
tracing, and ImageVulkan::Create resolves its default consumer stage
to COMPUTE_SHADER there.
- Window refuses a swapchain whose image count is not numFrames
instead of writing past images[]. The limitation itself is #160.
- CRAFTER_GRAPHICS_NO_DESCRIPTOR_HEAP forces the fallback on a driver
that has the heap, so it can be exercised on a desktop GPU.
Verified on an RTX 4090 in both modes under the validation layer, and
on a Fairphone 6 (Turnip, Adreno 810, postmarketOS), where the fallback
is the only path.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 17:28:46 +02:00
|
|
|
|
if (!Device::descriptorHeapSupported) {
|
|
|
|
|
|
heap_->WriteImageSets(slot, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, viewInfo, layout);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-02 21:08:20 +02:00
|
|
|
|
std::array<VkImageDescriptorInfoEXT, Window::numFrames> infos{};
|
|
|
|
|
|
std::array<VkResourceDescriptorInfoEXT, Window::numFrames> resources{};
|
|
|
|
|
|
std::array<VkHostAddressRangeEXT, Window::numFrames> destinations{};
|
|
|
|
|
|
|
|
|
|
|
|
for (std::uint32_t f = 0; f < Window::numFrames; ++f) {
|
|
|
|
|
|
infos[f] = {
|
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_IMAGE_DESCRIPTOR_INFO_EXT,
|
|
|
|
|
|
.pView = &viewInfo,
|
|
|
|
|
|
.layout = layout,
|
|
|
|
|
|
};
|
|
|
|
|
|
resources[f] = {
|
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_RESOURCE_DESCRIPTOR_INFO_EXT,
|
|
|
|
|
|
.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
|
|
|
|
|
.data = { .pImage = &infos[f] },
|
|
|
|
|
|
};
|
|
|
|
|
|
destinations[f] = {
|
|
|
|
|
|
.address = heap_->resourceHeap[f].value + heap_->ImageByteOffset(slot),
|
|
|
|
|
|
.size = Device::descriptorHeapProperties.imageDescriptorSize,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
Device::vkWriteResourceDescriptorsEXT(
|
|
|
|
|
|
Device::device, Window::numFrames, resources.data(), destinations.data()
|
|
|
|
|
|
);
|
2026-06-16 18:29:24 +00:00
|
|
|
|
// One image descriptor written per heap, at the same slot offset — flush
|
|
|
|
|
|
// just that range rather than the whole heap.
|
|
|
|
|
|
const std::uint32_t off = heap_->ImageByteOffset(slot);
|
|
|
|
|
|
const std::uint32_t sz = Device::descriptorHeapProperties.imageDescriptorSize;
|
|
|
|
|
|
for (auto& h : heap_->resourceHeap) h.FlushDevice(off, sz);
|
2026-05-02 21:08:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
feat(vulkan): run the compute/UI path without VK_EXT_descriptor_heap
Device::Initialize required twelve device extensions with no capability
check. Mesa Turnip (Adreno) lacks six of them: VK_EXT_descriptor_heap,
VK_KHR_shader_untyped_pointers, VK_EXT_device_fault and the three ray
tracing extensions. vkCreateDevice failed there, so not even a UI-only
program could start, although the UI path is compute-only and needs
nothing else that Turnip is missing.
The descriptor heap, ray tracing and device fault are now optional
groups, detected at start-up from the extension list and the feature
bits (Device::descriptorHeapSupported, rayTracingSupported,
deviceFaultSupported). Ray tracing needs the heap; on a device without
it the ray tracing entry points throw a message naming the cause.
Without the heap the same bindless slots live in one update-after-bind
descriptor set per frame, owned by DescriptorHeapVulkan: binding 0
storage images, 1 sampled images, 2 samplers, 3 storage buffers. Slot
allocation, the slot handles, UIDispatchHeader and the UIRenderer API
are unchanged; buffer slots simply stop being offset. Window::Render
binds that frame's set where it binds the heap, every compute pipeline
shares the heap object's pipeline layout, and push data travels as push
constants.
Each UI kernel is built twice from one source. ui-shared.glsl declares
its resources through UI_HEAP_* macros that expand to descriptor_heap
or, with CRAFTER_GRAPHICS_DESCRIPTOR_SETS defined, to set/binding.
<name>.comp.spv and <name>.comp.sets.spv ship side by side and
ComputeShader::Load picks one. The heap build of every shader is
byte-identical to before.
Breaking:
- ComputeShader::Load takes the heap as a second argument.
- DescriptorHeapVulkan is no longer copyable or movable.
- Custom UI shaders declare heap resources with the UI_HEAP_* macros
and are registered twice in project.cpp (see the README).
- project.cpp uses Shader::defines and Shader::variant, so it needs a
crafter-build that has them (Crafter.Build master, fe38cc1 or later).
Also:
- maintenance5 is enabled as a feature, not only as an extension:
every VulkanBuffer already relied on VkBufferUsageFlags2CreateInfo.
- Barrier stage masks drop RAY_TRACING_SHADER on devices without ray
tracing, and ImageVulkan::Create resolves its default consumer stage
to COMPUTE_SHADER there.
- Window refuses a swapchain whose image count is not numFrames
instead of writing past images[]. The limitation itself is #160.
- CRAFTER_GRAPHICS_NO_DESCRIPTOR_HEAP forces the fallback on a driver
that has the heap, so it can be exercised on a desktop GPU.
Verified on an RTX 4090 in both modes under the validation layer, and
on a Fairphone 6 (Turnip, Adreno 810, postmarketOS), where the fallback
is the only path.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 17:28:46 +02:00
|
|
|
|
void UIRenderer::WriteBufferDescriptor(std::uint16_t slot, VkBuffer buffer, VkDeviceAddress address, std::uint32_t size) {
|
|
|
|
|
|
if (!Device::descriptorHeapSupported) {
|
|
|
|
|
|
// A descriptor set names the buffer by handle; the heap below names
|
|
|
|
|
|
// it by device address.
|
|
|
|
|
|
heap_->WriteBufferSets(slot, buffer);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-02 21:08:20 +02:00
|
|
|
|
std::array<VkDeviceAddressRangeEXT, Window::numFrames> ranges{};
|
|
|
|
|
|
std::array<VkResourceDescriptorInfoEXT, Window::numFrames> resources{};
|
|
|
|
|
|
std::array<VkHostAddressRangeEXT, Window::numFrames> destinations{};
|
|
|
|
|
|
|
|
|
|
|
|
for (std::uint32_t f = 0; f < Window::numFrames; ++f) {
|
|
|
|
|
|
ranges[f] = { .address = address, .size = size };
|
|
|
|
|
|
resources[f] = {
|
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_RESOURCE_DESCRIPTOR_INFO_EXT,
|
|
|
|
|
|
.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
|
|
|
|
|
.data = { .pAddressRange = &ranges[f] },
|
|
|
|
|
|
};
|
|
|
|
|
|
destinations[f] = {
|
|
|
|
|
|
.address = heap_->resourceHeap[f].value + heap_->BufferByteOffset(slot),
|
|
|
|
|
|
.size = Device::descriptorHeapProperties.bufferDescriptorSize,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
Device::vkWriteResourceDescriptorsEXT(
|
|
|
|
|
|
Device::device, Window::numFrames, resources.data(), destinations.data()
|
|
|
|
|
|
);
|
2026-06-16 18:29:24 +00:00
|
|
|
|
// One buffer descriptor written per heap, at the same slot offset — flush
|
|
|
|
|
|
// just that range rather than the whole heap.
|
|
|
|
|
|
const std::uint32_t off = heap_->BufferByteOffset(slot);
|
|
|
|
|
|
const std::uint32_t sz = Device::descriptorHeapProperties.bufferDescriptorSize;
|
|
|
|
|
|
for (auto& h : heap_->resourceHeap) h.FlushDevice(off, sz);
|
2026-05-02 21:08:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-05 00:02:04 +02:00
|
|
|
|
SamplerSlot UIRenderer::RegisterSampler(const VkSamplerCreateInfo& info) {
|
2026-05-02 21:08:20 +02:00
|
|
|
|
auto range = heap_->AllocateSamplerSlots(1);
|
feat(vulkan): run the compute/UI path without VK_EXT_descriptor_heap
Device::Initialize required twelve device extensions with no capability
check. Mesa Turnip (Adreno) lacks six of them: VK_EXT_descriptor_heap,
VK_KHR_shader_untyped_pointers, VK_EXT_device_fault and the three ray
tracing extensions. vkCreateDevice failed there, so not even a UI-only
program could start, although the UI path is compute-only and needs
nothing else that Turnip is missing.
The descriptor heap, ray tracing and device fault are now optional
groups, detected at start-up from the extension list and the feature
bits (Device::descriptorHeapSupported, rayTracingSupported,
deviceFaultSupported). Ray tracing needs the heap; on a device without
it the ray tracing entry points throw a message naming the cause.
Without the heap the same bindless slots live in one update-after-bind
descriptor set per frame, owned by DescriptorHeapVulkan: binding 0
storage images, 1 sampled images, 2 samplers, 3 storage buffers. Slot
allocation, the slot handles, UIDispatchHeader and the UIRenderer API
are unchanged; buffer slots simply stop being offset. Window::Render
binds that frame's set where it binds the heap, every compute pipeline
shares the heap object's pipeline layout, and push data travels as push
constants.
Each UI kernel is built twice from one source. ui-shared.glsl declares
its resources through UI_HEAP_* macros that expand to descriptor_heap
or, with CRAFTER_GRAPHICS_DESCRIPTOR_SETS defined, to set/binding.
<name>.comp.spv and <name>.comp.sets.spv ship side by side and
ComputeShader::Load picks one. The heap build of every shader is
byte-identical to before.
Breaking:
- ComputeShader::Load takes the heap as a second argument.
- DescriptorHeapVulkan is no longer copyable or movable.
- Custom UI shaders declare heap resources with the UI_HEAP_* macros
and are registered twice in project.cpp (see the README).
- project.cpp uses Shader::defines and Shader::variant, so it needs a
crafter-build that has them (Crafter.Build master, fe38cc1 or later).
Also:
- maintenance5 is enabled as a feature, not only as an extension:
every VulkanBuffer already relied on VkBufferUsageFlags2CreateInfo.
- Barrier stage masks drop RAY_TRACING_SHADER on devices without ray
tracing, and ImageVulkan::Create resolves its default consumer stage
to COMPUTE_SHADER there.
- Window refuses a swapchain whose image count is not numFrames
instead of writing past images[]. The limitation itself is #160.
- CRAFTER_GRAPHICS_NO_DESCRIPTOR_HEAP forces the fallback on a driver
that has the heap, so it can be exercised on a desktop GPU.
Verified on an RTX 4090 in both modes under the validation layer, and
on a Fairphone 6 (Turnip, Adreno 810, postmarketOS), where the fallback
is the only path.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 17:28:46 +02:00
|
|
|
|
if (!Device::descriptorHeapSupported) {
|
|
|
|
|
|
// The handle owns the slot before the sampler is created, so a
|
|
|
|
|
|
// failed vkCreateSampler returns it to the freelist.
|
|
|
|
|
|
SamplerSlot slot{heap_, range.firstElement};
|
|
|
|
|
|
heap_->WriteSamplerSets(range.firstElement, info);
|
|
|
|
|
|
return slot;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-02 21:08:20 +02:00
|
|
|
|
std::array<VkSamplerCreateInfo, Window::numFrames> infos{};
|
|
|
|
|
|
std::array<VkHostAddressRangeEXT, Window::numFrames> destinations{};
|
|
|
|
|
|
for (std::uint32_t f = 0; f < Window::numFrames; ++f) {
|
|
|
|
|
|
infos[f] = info;
|
|
|
|
|
|
destinations[f] = {
|
|
|
|
|
|
.address = heap_->samplerHeap[f].value + heap_->SamplerByteOffset(range.firstElement),
|
|
|
|
|
|
.size = Device::descriptorHeapProperties.samplerDescriptorSize,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
Device::vkWriteSamplerDescriptorsEXT(
|
|
|
|
|
|
Device::device, Window::numFrames, infos.data(), destinations.data()
|
|
|
|
|
|
);
|
2026-06-16 18:29:24 +00:00
|
|
|
|
// One sampler descriptor written per heap, at the same slot offset — flush
|
|
|
|
|
|
// just that range rather than the whole sampler heap.
|
|
|
|
|
|
const std::uint32_t off = heap_->SamplerByteOffset(range.firstElement);
|
|
|
|
|
|
const std::uint32_t sz = Device::descriptorHeapProperties.samplerDescriptorSize;
|
|
|
|
|
|
for (auto& h : heap_->samplerHeap) h.FlushDevice(off, sz);
|
2026-05-05 00:02:04 +02:00
|
|
|
|
return SamplerSlot{heap_, range.firstElement};
|
2026-05-02 21:08:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-05 00:02:04 +02:00
|
|
|
|
SamplerSlot UIRenderer::RegisterLinearClampSampler() {
|
2026-05-02 21:08:20 +02:00
|
|
|
|
VkSamplerCreateInfo s {
|
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
|
|
|
|
|
.magFilter = VK_FILTER_LINEAR,
|
|
|
|
|
|
.minFilter = VK_FILTER_LINEAR,
|
|
|
|
|
|
.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR,
|
|
|
|
|
|
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
|
|
|
|
|
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
|
|
|
|
|
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
|
|
|
|
|
.maxAnisotropy = 1.0f,
|
|
|
|
|
|
.minLod = 0.0f,
|
|
|
|
|
|
.maxLod = VK_LOD_CLAMP_NONE,
|
|
|
|
|
|
};
|
|
|
|
|
|
return RegisterSampler(s);
|
|
|
|
|
|
}
|
|
|
|
|
|
|