1#pragma once
2
3#include <nn/gfx/detail/gfx_CommandBuffer-api.nvn.8.h>
4#include <nn/gfx/gfx_Common.h>
5
6namespace nn::gfx {
7class CommandBufferInfo;
8
9template <class TTarget>
10class TCommandBuffer : public detail::CommandBufferImpl<TTarget> {
11 NN_NO_COPY(TCommandBuffer);
12
13 typedef void (*OutOfMemoryEventCallback)(TCommandBuffer<TTarget>*, const OutOfMemoryEventArg&);
14
15public:
16 typedef CommandBufferInfo InfoType;
17
18 TCommandBuffer() {}
19
20 static size_t GetCommandMemoryAlignment(TDevice<TTarget>*);
21 static size_t GetControlMemoryAlignment(TDevice<TTarget>*);
22 void Initialize(TDevice<TTarget>*, const InfoType&);
23 void Finalize(TDevice<TTarget>*);
24 void AddCommandMemory(TMemoryPool<TTarget>*, ptrdiff_t, size_t);
25 void AddControlMemory(void*, size_t);
26 void SetOutOfCommandMemoryEventCallback(OutOfMemoryEventCallback);
27 void SetOutOfControlMemoryEventCallback(OutOfMemoryEventCallback);
28 void Reset();
29 void Begin();
30 void End();
31 void Dispatch(int, int, int);
32 void Draw(PrimitiveTopology, int, int);
33 void Draw(PrimitiveTopology, int, int, int, int);
34 void DrawIndexed(PrimitiveTopology, IndexFormat, const GpuAddress&, int, int);
35 void DrawIndexed(PrimitiveTopology, IndexFormat, const GpuAddress&, int, int, int, int);
36 void DispatchIndirect(const GpuAddress&);
37 void DrawIndirect(PrimitiveTopology, const GpuAddress&);
38 void DrawIndexedIndirect(PrimitiveTopology, IndexFormat, const GpuAddress&, const GpuAddress&);
39 void SetPipeline(const TPipeline<TTarget>*);
40 void SetRenderTargets(int, const TColorTargetView<TTarget>* const*,
41 const TDepthStencilView<TTarget>*);
42 void SetVertexBuffer(int, const GpuAddress&, ptrdiff_t, size_t);
43 void SetViewportScissorState(const TViewportScissorState<TTarget>*);
44 void CopyBuffer(TBuffer<TTarget>*, ptrdiff_t, const TBuffer<TTarget>*, ptrdiff_t, size_t);
45 void CopyImage(TTexture<TTarget>*, const TextureSubresource&, int, int, int,
46 const TTexture<TTarget>*, const TextureCopyRegion&);
47 void CopyBufferToImage(TTexture<TTarget>*, const TBuffer<TTarget>*,
48 const BufferTextureCopyRegion&);
49 void CopyBufferToImage(TTexture<TTarget>*, const TextureCopyRegion&, const TBuffer<TTarget>*,
50 ptrdiff_t);
51 void CopyImageToBuffer(TBuffer<TTarget>*, const TTexture<TTarget>*,
52 const BufferTextureCopyRegion&);
53 void CopyImageToBuffer(TBuffer<TTarget>*, ptrdiff_t, const TTexture<TTarget>*,
54 const TextureCopyRegion&);
55 void BlitImage(TTexture<TTarget>*, const TextureCopyRegion&, const TTexture<TTarget>*,
56 const TextureCopyRegion&, int);
57 void ClearBuffer(TBuffer<TTarget>*, ptrdiff_t, size_t, uint32_t);
58 void ClearColor(TColorTargetView<TTarget>*, float, float, float, float,
59 const TextureArrayRange*);
60 void ClearColorTarget(TColorTargetView<TTarget>*, const ClearColorValue&,
61 const TextureArrayRange*);
62 void ClearDepthStencil(TDepthStencilView<TTarget>*, float, int, DepthStencilClearMode,
63 const TextureArrayRange*);
64 void Resolve(TTexture<TTarget>*, int, int, const TColorTargetView<TTarget>*,
65 const TextureArrayRange*);
66 void FlushMemory(int);
67 void InvalidateMemory(int);
68 void CallCommandBuffer(const TCommandBuffer<TTarget>*);
69 void CopyCommandBuffer(const TCommandBuffer<TTarget>*);
70 void SetBufferStateTransition(TBuffer<TTarget>*, int, int, int, int);
71 void SetTextureStateTransition(TTexture<TTarget>*, TextureSubresourceRange*, int, int, int,
72 int);
73 void SetDescriptorPool(const TDescriptorPool<TTarget>*);
74 void SetRootSignature(PipelineType, TRootSignature<TTarget>*);
75 void SetRootBufferDescriptorTable(PipelineType, int, const DescriptorSlot&);
76 void SetRootTextureAndSamplerDescriptorTable(PipelineType, int, const DescriptorSlot&,
77 const DescriptorSlot&);
78 void SetRootConstantBuffer(PipelineType, int, const GpuAddress&, size_t);
79 void SetRootUnorderedAccessBuffer(PipelineType, int, const GpuAddress&, size_t);
80 void SetRootTextureAndSampler(PipelineType, int, const TTextureView<TTarget>*,
81 const TSampler<TTarget>*);
82 void BeginQuery(QueryTarget);
83 void EndQuery(const GpuAddress&, QueryTarget);
84 void SetDepthBounds(float, float);
85 void SetLineWidth(float);
86 void SetViewports(int, int, const ViewportStateInfo*);
87 void SetScissors(int, int, const ScissorStateInfo*);
88 void WriteTimestamp(const GpuAddress&);
89 void UpdateBuffer(const GpuAddress&, size_t, ptrdiff_t, size_t, const void*);
90 void SetConstantBuffer(int, ShaderStage, const DescriptorSlot&);
91 void SetConstantBuffer(int, ShaderStage, const GpuAddress&, size_t);
92 void SetUnorderedAccessBuffer(int, ShaderStage, const DescriptorSlot&);
93 void SetUnorderedAccessBuffer(int, ShaderStage, const GpuAddress&, size_t);
94 void SetTextureAndSampler(int, ShaderStage, const DescriptorSlot&, const DescriptorSlot&);
95 void SetTextureAndSampler(int, ShaderStage, const TTextureView<TTarget>*,
96 const TSampler<TTarget>*);
97 void SetTexture(int, ShaderStage, const DescriptorSlot&);
98 void SetImage(int, ShaderStage, const DescriptorSlot&);
99 void SetImage(int, ShaderStage, const TTextureView<TTarget>*);
100 void SetShader(const TShader<TTarget>*, int);
101 void SetRasterizerState(const TRasterizerState<TTarget>*);
102 void SetBlendState(const TBlendState<TTarget>*);
103 void SetDepthStencilState(const TDepthStencilState<TTarget>*);
104 void SetVertexState(const TVertexState<TTarget>*);
105 void SetTessellationState(const TTessellationState<TTarget>*);
106 void SetUserPtr(void*);
107 void* GetUserPtr();
108 const void* GetUserPtr() const;
109
110 typedef void (*Gl4UserCommandCallbackType)(const void*);
111 void Gl4SetUserCommand(Gl4UserCommandCallbackType, const void*);
112 void Gl4SetUserCommandDynamic(Gl4UserCommandCallbackType, const void*, size_t);
113};
114
115} // namespace nn::gfx