2017-04-20 18:38:20 +00:00
|
|
|
// Copyright 2017 The NXT Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2017-07-06 18:41:13 +00:00
|
|
|
#ifndef BACKEND_COMMANDS_H_
|
|
|
|
#define BACKEND_COMMANDS_H_
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2018-05-02 22:10:13 +00:00
|
|
|
#include "backend/RenderPassInfo.h"
|
2017-07-06 18:41:13 +00:00
|
|
|
#include "backend/Texture.h"
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
#include "nxt/nxtcpp.h"
|
|
|
|
|
|
|
|
namespace backend {
|
|
|
|
|
|
|
|
// Definition of the commands that are present in the CommandIterator given by the
|
|
|
|
// CommandBufferBuilder. There are not defined in CommandBuffer.h to break some header
|
|
|
|
// dependencies: Ref<Object> needs Object to be defined.
|
|
|
|
|
|
|
|
enum class Command {
|
2017-07-10 21:07:24 +00:00
|
|
|
BeginComputePass,
|
2017-05-16 21:04:22 +00:00
|
|
|
BeginRenderPass,
|
2017-06-12 22:12:29 +00:00
|
|
|
CopyBufferToBuffer,
|
2017-04-20 18:38:20 +00:00
|
|
|
CopyBufferToTexture,
|
2017-06-26 20:23:03 +00:00
|
|
|
CopyTextureToBuffer,
|
2017-04-20 18:38:20 +00:00
|
|
|
Dispatch,
|
|
|
|
DrawArrays,
|
|
|
|
DrawElements,
|
2017-07-10 21:07:24 +00:00
|
|
|
EndComputePass,
|
2017-05-16 21:04:22 +00:00
|
|
|
EndRenderPass,
|
2017-07-14 14:58:07 +00:00
|
|
|
SetComputePipeline,
|
|
|
|
SetRenderPipeline,
|
2017-04-20 18:38:20 +00:00
|
|
|
SetPushConstants,
|
2017-05-30 22:13:03 +00:00
|
|
|
SetStencilReference,
|
2018-02-13 19:57:13 +00:00
|
|
|
SetScissorRect,
|
2017-08-01 18:22:52 +00:00
|
|
|
SetBlendColor,
|
2017-04-20 18:38:20 +00:00
|
|
|
SetBindGroup,
|
|
|
|
SetIndexBuffer,
|
|
|
|
SetVertexBuffers,
|
|
|
|
TransitionBufferUsage,
|
|
|
|
TransitionTextureUsage,
|
|
|
|
};
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
struct BeginComputePassCmd {};
|
2017-07-10 21:07:24 +00:00
|
|
|
|
2017-05-16 21:04:22 +00:00
|
|
|
struct BeginRenderPassCmd {
|
2018-05-02 22:10:13 +00:00
|
|
|
Ref<RenderPassInfoBase> info;
|
2017-05-16 21:04:22 +00:00
|
|
|
};
|
|
|
|
|
2017-06-26 15:43:51 +00:00
|
|
|
struct BufferCopyLocation {
|
|
|
|
Ref<BufferBase> buffer;
|
|
|
|
uint32_t offset;
|
2017-06-12 22:12:29 +00:00
|
|
|
};
|
|
|
|
|
2017-06-26 15:43:51 +00:00
|
|
|
struct TextureCopyLocation {
|
2017-04-20 18:38:20 +00:00
|
|
|
Ref<TextureBase> texture;
|
|
|
|
uint32_t x, y, z;
|
|
|
|
uint32_t width, height, depth;
|
|
|
|
uint32_t level;
|
|
|
|
};
|
|
|
|
|
2017-06-26 15:43:51 +00:00
|
|
|
struct CopyBufferToBufferCmd {
|
|
|
|
BufferCopyLocation source;
|
|
|
|
BufferCopyLocation destination;
|
|
|
|
uint32_t size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CopyBufferToTextureCmd {
|
|
|
|
BufferCopyLocation source;
|
|
|
|
TextureCopyLocation destination;
|
2017-07-13 14:04:23 +00:00
|
|
|
uint32_t rowPitch;
|
2017-06-26 15:43:51 +00:00
|
|
|
};
|
|
|
|
|
2017-06-26 20:23:03 +00:00
|
|
|
struct CopyTextureToBufferCmd {
|
|
|
|
TextureCopyLocation source;
|
|
|
|
BufferCopyLocation destination;
|
2017-07-13 14:04:23 +00:00
|
|
|
uint32_t rowPitch;
|
2017-06-26 20:23:03 +00:00
|
|
|
};
|
|
|
|
|
2017-04-20 18:38:20 +00:00
|
|
|
struct DispatchCmd {
|
|
|
|
uint32_t x;
|
|
|
|
uint32_t y;
|
|
|
|
uint32_t z;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DrawArraysCmd {
|
|
|
|
uint32_t vertexCount;
|
|
|
|
uint32_t instanceCount;
|
|
|
|
uint32_t firstVertex;
|
|
|
|
uint32_t firstInstance;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DrawElementsCmd {
|
|
|
|
uint32_t indexCount;
|
|
|
|
uint32_t instanceCount;
|
|
|
|
uint32_t firstIndex;
|
|
|
|
uint32_t firstInstance;
|
|
|
|
};
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
struct EndComputePassCmd {};
|
2017-07-10 21:07:24 +00:00
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
struct EndRenderPassCmd {};
|
2017-05-16 21:04:22 +00:00
|
|
|
|
2017-07-14 14:58:07 +00:00
|
|
|
struct SetComputePipelineCmd {
|
|
|
|
Ref<ComputePipelineBase> pipeline;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SetRenderPipelineCmd {
|
|
|
|
Ref<RenderPipelineBase> pipeline;
|
2017-04-20 18:38:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SetPushConstantsCmd {
|
2017-07-20 15:01:37 +00:00
|
|
|
nxt::ShaderStageBit stages;
|
2017-04-20 18:38:20 +00:00
|
|
|
uint32_t offset;
|
|
|
|
uint32_t count;
|
|
|
|
};
|
|
|
|
|
2017-05-30 22:13:03 +00:00
|
|
|
struct SetStencilReferenceCmd {
|
2017-06-01 15:30:03 +00:00
|
|
|
uint32_t reference;
|
2017-05-30 22:13:03 +00:00
|
|
|
};
|
2018-02-13 19:57:13 +00:00
|
|
|
|
|
|
|
struct SetScissorRectCmd {
|
|
|
|
uint32_t x, y, width, height;
|
|
|
|
};
|
2017-05-30 22:13:03 +00:00
|
|
|
|
2017-08-01 18:22:52 +00:00
|
|
|
struct SetBlendColorCmd {
|
|
|
|
float r, g, b, a;
|
|
|
|
};
|
|
|
|
|
2017-04-20 18:38:20 +00:00
|
|
|
struct SetBindGroupCmd {
|
|
|
|
uint32_t index;
|
|
|
|
Ref<BindGroupBase> group;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SetIndexBufferCmd {
|
|
|
|
Ref<BufferBase> buffer;
|
|
|
|
uint32_t offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SetVertexBuffersCmd {
|
|
|
|
uint32_t startSlot;
|
|
|
|
uint32_t count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TransitionBufferUsageCmd {
|
|
|
|
Ref<BufferBase> buffer;
|
|
|
|
nxt::BufferUsageBit usage;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TransitionTextureUsageCmd {
|
|
|
|
Ref<TextureBase> texture;
|
|
|
|
uint32_t startLevel;
|
|
|
|
uint32_t levelCount;
|
|
|
|
nxt::TextureUsageBit usage;
|
|
|
|
};
|
|
|
|
|
|
|
|
// This needs to be called before the CommandIterator is freed so that the Ref<> present in
|
|
|
|
// the commands have a chance to run their destructor and remove internal references.
|
2017-12-04 21:29:41 +00:00
|
|
|
class CommandIterator;
|
2017-04-20 18:38:20 +00:00
|
|
|
void FreeCommands(CommandIterator* commands);
|
2017-06-16 18:26:26 +00:00
|
|
|
void SkipCommand(CommandIterator* commands, Command type);
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
} // namespace backend
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
#endif // BACKEND_COMMANDS_H_
|