Loading...
Searching...
No Matches
GPUStridedCopy.hpp
1#pragma once
2#include <Gfx/Graph/RenderState.hpp>
3
4#include <score_plugin_gfx_export.h>
5
6#include <private/qrhi_p.h>
7
8namespace score::gfx
9{
10
26class SCORE_PLUGIN_GFX_TEST_EXPORT GPUStridedCopy
27{
28public:
29 struct Params
30 {
31 QRhiBuffer* src{};
32 QRhiBuffer* dst{};
33 uint32_t count{}; // number of elements
34 uint32_t element_bytes{}; // bytes copied per element
35 uint32_t src_offset_bytes{};
36 uint32_t src_stride_bytes{};
37 uint32_t dst_offset_bytes{};
38 uint32_t dst_stride_bytes{};
39 };
40
42 {
43 QRhiShaderResourceBindings* srb{};
44 QRhiBuffer* paramsUBO{};
45 // The buffers srb was last created against, by globalResourceId: a buffer
46 // freed and reallocated can come back at the same address.
47 quint64 src_id{};
48 quint64 dst_id{};
49 };
50
53 static bool eligible(const Params& p) noexcept;
54
55 bool init(RenderState& state);
56 void release();
57
58 PreparedOp prepare(QRhi& rhi, const Params& p);
59 static void releaseOp(PreparedOp& op);
60
61 void updateParams(QRhiResourceUpdateBatch& res, PreparedOp& op, const Params& p);
62 void dispatch(QRhiCommandBuffer& cb, const PreparedOp& op, const Params& p);
63
64 static constexpr int LocalSize = 256;
65
66private:
67 struct Dims
68 {
69 int x{}, y{};
70 };
71 Dims dims(uint64_t invocations) const noexcept;
72
73 QRhiComputePipeline* m_pipeline{};
74 QShader m_shader;
75 int m_maxWorkgroupsPerDim{65535};
76};
77
78}
Copies count elements between two GPU buffers with different strides, in one compute dispatch.
Definition GPUStridedCopy.hpp:27
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Definition GPUStridedCopy.hpp:30
Definition GPUStridedCopy.hpp:42
Global state associated to a rendering context.
Definition RenderState.hpp:40