28 double value { std::numeric_limits<double>::quiet_NaN() };
84 const std::array<uint32_t, 3> push { geometry.
length, geometry.
stride, geometry.
offset };
85 const size_t result_bytes =
static_cast<size_t>(geometry.
count) * 2U *
sizeof(uint64_t);
95 .explicit_groups = std::array<uint32_t, 3> { geometry.
count, 1U, 1U },
112 stage.stage_fn = [&context, values, resident = std::move(stage.stage_fn)](
GpuDispatchCore& core) {
127 std::vector<ArgMaxResult> out;
128 out.reserve(segments);
129 for (
size_t s = 0; s < segments && 2U * s + 1U < words.size(); ++s) {
130 out.push_back({ .value = words[2U * s],
131 .index =
static_cast<uint32_t
>(std::bit_cast<uint64_t>(words[2U * s + 1U]) & 0xFFFFFFFFULL) });
Runs a shader on doubles carried as two 32-bit words, with no fp64 on the device.
ShaderSpec build()
Finalise and return the ShaderSpec.
Assemble & pc(std::string name, Kakshya::GpuDataFormat format)
Declare a push constant field with explicit format.
Assemble & ssbo(std::string name, BindingDirection direction, Kakshya::GpuDataFormat format, Kakshya::DataModality modality=Kakshya::DataModality::SCALAR_F32)
Declare an SSBO binding.
Assemble & workgroup(uint32_t x, uint32_t y=1, uint32_t z=1)
Override workgroup size.
Assemble & tmpl(KernelTemplate t)
Set the kernel template.
Fluent assembler producing a ShaderSpec.
std::optional< SharedBufferInfo > shared_buffer_info(uint32_t set, size_t binding_index) const
What the shared buffer at (set, binding_index) declares, or nothing when absent.
void set_output_size(size_t index, size_t byte_size)
Declare the byte capacity of an output binding independently of input data.
void set_push_constants(const void *data, size_t bytes)
Set push constant data from a raw byte pointer.
Non-template base that owns all type-independent GPU dispatch logic.
std::vector< double > download_words(size_t binding, size_t count)
Read a binding back as doubles after a recorded stage.
void stage_words(uint32_t binding, std::span< const double > values, size_t padded_count=0, bool complement=false)
Encode values and stage them as the data of a binding.
Shader context whose numeric input is staged as a uvec2 per double.
@ VEC2_U32
glm::uvec2: a 64-bit value as low word (x) and high word (y), not a sampled image format
@ SegmentedArgMax
The first maximum of each segment of word-pair doubles, one workgroup per segment.
BindingDirection
Data flow direction for a shader binding slot.
constexpr uint32_t no_argmax_index
The index reported for a segment that holds no value to select.
std::vector< ArgMaxResult > read_argmax(WordPairExecutionContext &context, size_t segments)
Read the selections of the segments of the last recorded stage.
DependencyStage segmented_argmax_stage(WordPairExecutionContext &context, const GpuComputeConfig &config, const SegmentGeometry &geometry)
The stage that selects the largest value of every segment of values already on the device.
Portal::Graphics::ShaderSpec segmented_argmax_spec(uint32_t workgroup=256)
The spec of a SegmentedArgMax kernel.
Plain-data description of the compute shader to dispatch.
Complete declarative description of a generated compute shader.
uint32_t index
Position of the first occurrence of the value, or no_argmax_index.
bool found() const noexcept
double value
The largest value, NaN when the segment holds none.
The selected value of one segment and its position inside the segment.
One stage in a record_stages call.
Where the windows of a GPU pass sit in the value array.