mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-25 07:53:32 +00:00
Add and Implement CommandBuffer::SetScissorRect
This commit is contained in:
parent
234111c379
commit
a3c89cc27a
@ -485,6 +485,15 @@
|
|||||||
{"name": "pipeline", "type": "render pipeline"}
|
{"name": "pipeline", "type": "render pipeline"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "set scissor rect",
|
||||||
|
"args": [
|
||||||
|
{"name": "x", "type": "uint32_t"},
|
||||||
|
{"name": "y", "type": "uint32_t"},
|
||||||
|
{"name": "width", "type": "uint32_t"},
|
||||||
|
{"name": "height", "type": "uint32_t"}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "set vertex buffers",
|
"name": "set vertex buffers",
|
||||||
"args": [
|
"args": [
|
||||||
|
@ -219,6 +219,10 @@ namespace backend {
|
|||||||
SetStencilReferenceCmd* cmd = commands->NextCommand<SetStencilReferenceCmd>();
|
SetStencilReferenceCmd* cmd = commands->NextCommand<SetStencilReferenceCmd>();
|
||||||
cmd->~SetStencilReferenceCmd();
|
cmd->~SetStencilReferenceCmd();
|
||||||
} break;
|
} break;
|
||||||
|
case Command::SetScissorRect: {
|
||||||
|
SetScissorRectCmd* cmd = commands->NextCommand<SetScissorRectCmd>();
|
||||||
|
cmd->~SetScissorRectCmd();
|
||||||
|
} break;
|
||||||
case Command::SetBlendColor: {
|
case Command::SetBlendColor: {
|
||||||
SetBlendColorCmd* cmd = commands->NextCommand<SetBlendColorCmd>();
|
SetBlendColorCmd* cmd = commands->NextCommand<SetBlendColorCmd>();
|
||||||
cmd->~SetBlendColorCmd();
|
cmd->~SetBlendColorCmd();
|
||||||
@ -322,6 +326,10 @@ namespace backend {
|
|||||||
commands->NextCommand<SetStencilReferenceCmd>();
|
commands->NextCommand<SetStencilReferenceCmd>();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Command::SetScissorRect:
|
||||||
|
commands->NextCommand<SetScissorRectCmd>();
|
||||||
|
break;
|
||||||
|
|
||||||
case Command::SetBlendColor:
|
case Command::SetBlendColor:
|
||||||
commands->NextCommand<SetBlendColorCmd>();
|
commands->NextCommand<SetBlendColorCmd>();
|
||||||
break;
|
break;
|
||||||
@ -537,6 +545,14 @@ namespace backend {
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case Command::SetScissorRect: {
|
||||||
|
mIterator.NextCommand<SetScissorRectCmd>();
|
||||||
|
if (!mState->HaveRenderSubpass()) {
|
||||||
|
HandleError("Can't set scissor rect without an active render subpass");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
case Command::SetBindGroup: {
|
case Command::SetBindGroup: {
|
||||||
SetBindGroupCmd* cmd = mIterator.NextCommand<SetBindGroupCmd>();
|
SetBindGroupCmd* cmd = mIterator.NextCommand<SetBindGroupCmd>();
|
||||||
if (!mState->SetBindGroup(cmd->index, cmd->group.Get())) {
|
if (!mState->SetBindGroup(cmd->index, cmd->group.Get())) {
|
||||||
@ -784,6 +800,18 @@ namespace backend {
|
|||||||
cmd->a = a;
|
cmd->a = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommandBufferBuilder::SetScissorRect(uint32_t x,
|
||||||
|
uint32_t y,
|
||||||
|
uint32_t width,
|
||||||
|
uint32_t height) {
|
||||||
|
SetScissorRectCmd* cmd = mAllocator.Allocate<SetScissorRectCmd>(Command::SetScissorRect);
|
||||||
|
new (cmd) SetScissorRectCmd;
|
||||||
|
cmd->x = x;
|
||||||
|
cmd->y = y;
|
||||||
|
cmd->width = width;
|
||||||
|
cmd->height = height;
|
||||||
|
}
|
||||||
|
|
||||||
void CommandBufferBuilder::SetBindGroup(uint32_t groupIndex, BindGroupBase* group) {
|
void CommandBufferBuilder::SetBindGroup(uint32_t groupIndex, BindGroupBase* group) {
|
||||||
if (groupIndex >= kMaxBindGroups) {
|
if (groupIndex >= kMaxBindGroups) {
|
||||||
HandleError("Setting bind group over the max");
|
HandleError("Setting bind group over the max");
|
||||||
|
@ -111,6 +111,7 @@ namespace backend {
|
|||||||
void SetRenderPipeline(RenderPipelineBase* pipeline);
|
void SetRenderPipeline(RenderPipelineBase* pipeline);
|
||||||
void SetStencilReference(uint32_t reference);
|
void SetStencilReference(uint32_t reference);
|
||||||
void SetBlendColor(float r, float g, float b, float a);
|
void SetBlendColor(float r, float g, float b, float a);
|
||||||
|
void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
|
||||||
void SetBindGroup(uint32_t groupIndex, BindGroupBase* group);
|
void SetBindGroup(uint32_t groupIndex, BindGroupBase* group);
|
||||||
void SetIndexBuffer(BufferBase* buffer, uint32_t offset);
|
void SetIndexBuffer(BufferBase* buffer, uint32_t offset);
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ namespace backend {
|
|||||||
SetRenderPipeline,
|
SetRenderPipeline,
|
||||||
SetPushConstants,
|
SetPushConstants,
|
||||||
SetStencilReference,
|
SetStencilReference,
|
||||||
|
SetScissorRect,
|
||||||
SetBlendColor,
|
SetBlendColor,
|
||||||
SetBindGroup,
|
SetBindGroup,
|
||||||
SetIndexBuffer,
|
SetIndexBuffer,
|
||||||
@ -135,6 +136,10 @@ namespace backend {
|
|||||||
uint32_t reference;
|
uint32_t reference;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SetScissorRectCmd {
|
||||||
|
uint32_t x, y, width, height;
|
||||||
|
};
|
||||||
|
|
||||||
struct SetBlendColorCmd {
|
struct SetBlendColorCmd {
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
};
|
};
|
||||||
|
@ -528,6 +528,17 @@ namespace backend { namespace d3d12 {
|
|||||||
commandList->OMSetStencilRef(cmd->reference);
|
commandList->OMSetStencilRef(cmd->reference);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case Command::SetScissorRect: {
|
||||||
|
SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
|
||||||
|
D3D12_RECT rect;
|
||||||
|
rect.left = cmd->x;
|
||||||
|
rect.bottom = cmd->y;
|
||||||
|
rect.right = cmd->x + cmd->width;
|
||||||
|
rect.top = cmd->y + cmd->height;
|
||||||
|
|
||||||
|
commandList->RSSetScissorRects(1, &rect);
|
||||||
|
} break;
|
||||||
|
|
||||||
case Command::SetBlendColor: {
|
case Command::SetBlendColor: {
|
||||||
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
|
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
|
||||||
ASSERT(lastRenderPipeline);
|
ASSERT(lastRenderPipeline);
|
||||||
|
@ -392,15 +392,25 @@ namespace backend { namespace metal {
|
|||||||
SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
|
SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
|
||||||
|
|
||||||
ASSERT(encoders.render);
|
ASSERT(encoders.render);
|
||||||
|
|
||||||
[encoders.render setStencilReferenceValue:cmd->reference];
|
[encoders.render setStencilReferenceValue:cmd->reference];
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case Command::SetScissorRect: {
|
||||||
|
SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
|
||||||
|
MTLScissorRect rect;
|
||||||
|
rect.x = cmd->x;
|
||||||
|
rect.y = cmd->y;
|
||||||
|
rect.width = cmd->width;
|
||||||
|
rect.height = cmd->height;
|
||||||
|
|
||||||
|
ASSERT(encoders.render);
|
||||||
|
[encoders.render setScissorRect:rect];
|
||||||
|
} break;
|
||||||
|
|
||||||
case Command::SetBlendColor: {
|
case Command::SetBlendColor: {
|
||||||
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
|
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
|
||||||
|
|
||||||
ASSERT(encoders.render);
|
ASSERT(encoders.render);
|
||||||
|
|
||||||
[encoders.render setBlendColorRed:cmd->r green:cmd->g blue:cmd->b alpha:cmd->a];
|
[encoders.render setBlendColorRed:cmd->r green:cmd->g blue:cmd->b alpha:cmd->a];
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -370,6 +370,8 @@ namespace backend { namespace opengl {
|
|||||||
glBlendColor(0, 0, 0, 0);
|
glBlendColor(0, 0, 0, 0);
|
||||||
glViewport(0, 0, currentFramebuffer->GetWidth(),
|
glViewport(0, 0, currentFramebuffer->GetWidth(),
|
||||||
currentFramebuffer->GetHeight());
|
currentFramebuffer->GetHeight());
|
||||||
|
glScissor(0, 0, currentFramebuffer->GetWidth(),
|
||||||
|
currentFramebuffer->GetHeight());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Command::CopyBufferToBuffer: {
|
case Command::CopyBufferToBuffer: {
|
||||||
@ -539,6 +541,11 @@ namespace backend { namespace opengl {
|
|||||||
persistentPipelineState.SetStencilReference(cmd->reference);
|
persistentPipelineState.SetStencilReference(cmd->reference);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case Command::SetScissorRect: {
|
||||||
|
SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
|
||||||
|
glScissor(cmd->x, cmd->y, cmd->width, cmd->height);
|
||||||
|
} break;
|
||||||
|
|
||||||
case Command::SetBlendColor: {
|
case Command::SetBlendColor: {
|
||||||
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
|
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
|
||||||
glBlendColor(cmd->r, cmd->g, cmd->b, cmd->a);
|
glBlendColor(cmd->r, cmd->g, cmd->b, cmd->a);
|
||||||
|
@ -40,6 +40,7 @@ namespace backend { namespace opengl {
|
|||||||
*device = reinterpret_cast<nxtDevice>(new Device);
|
*device = reinterpret_cast<nxtDevice>(new Device);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
|
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +275,17 @@ namespace backend { namespace vulkan {
|
|||||||
cmd->reference);
|
cmd->reference);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case Command::SetScissorRect: {
|
||||||
|
SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
|
||||||
|
VkRect2D rect;
|
||||||
|
rect.offset.x = cmd->x;
|
||||||
|
rect.offset.y = cmd->y;
|
||||||
|
rect.extent.width = cmd->width;
|
||||||
|
rect.extent.height = cmd->height;
|
||||||
|
|
||||||
|
device->fn.CmdSetScissor(commands, 0, 1, &rect);
|
||||||
|
} break;
|
||||||
|
|
||||||
case Command::SetVertexBuffers: {
|
case Command::SetVertexBuffers: {
|
||||||
SetVertexBuffersCmd* cmd = mCommands.NextCommand<SetVertexBuffersCmd>();
|
SetVertexBuffersCmd* cmd = mCommands.NextCommand<SetVertexBuffersCmd>();
|
||||||
auto buffers = mCommands.NextData<Ref<BufferBase>>(cmd->count);
|
auto buffers = mCommands.NextData<Ref<BufferBase>>(cmd->count);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user