Add SetBlendColor command

This commit is contained in:
Austin Eng 2017-08-01 14:22:52 -04:00 committed by Austin Eng
parent 476e5cbe30
commit fb4265387c
7 changed files with 75 additions and 0 deletions

View File

@ -441,6 +441,15 @@
{"name": "reference", "type": "uint32_t"} {"name": "reference", "type": "uint32_t"}
] ]
}, },
{
"name": "set blend color",
"args": [
{"name": "r", "type": "float"},
{"name": "g", "type": "float"},
{"name": "b", "type": "float"},
{"name": "a", "type": "float"}
]
},
{ {
"name": "set bind group", "name": "set bind group",
"args": [ "args": [
@ -688,6 +697,9 @@
{"value": 1, "name":"linear"} {"value": 1, "name":"linear"}
] ]
}, },
"float": {
"category": "native"
},
"framebuffer": { "framebuffer": {
"category": "object" "category": "object"
}, },

View File

@ -236,6 +236,12 @@ namespace backend {
cmd->~SetStencilReferenceCmd(); cmd->~SetStencilReferenceCmd();
} }
break; break;
case Command::SetBlendColor:
{
SetBlendColorCmd* cmd = commands->NextCommand<SetBlendColorCmd>();
cmd->~SetBlendColorCmd();
}
break;
case Command::SetBindGroup: case Command::SetBindGroup:
{ {
SetBindGroupCmd* cmd = commands->NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = commands->NextCommand<SetBindGroupCmd>();
@ -345,6 +351,10 @@ namespace backend {
commands->NextCommand<SetStencilReferenceCmd>(); commands->NextCommand<SetStencilReferenceCmd>();
break; break;
case Command::SetBlendColor:
commands->NextCommand<SetBlendColorCmd>();
break;
case Command::SetBindGroup: case Command::SetBindGroup:
commands->NextCommand<SetBindGroupCmd>(); commands->NextCommand<SetBindGroupCmd>();
break; break;
@ -570,6 +580,16 @@ namespace backend {
} }
break; break;
case Command::SetBlendColor:
{
iterator.NextCommand<SetBlendColorCmd>();
if (!state->HaveRenderPass()) {
HandleError("Can't set blend color without an active render pass");
return false;
}
}
break;
case Command::SetBindGroup: case Command::SetBindGroup:
{ {
SetBindGroupCmd* cmd = iterator.NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = iterator.NextCommand<SetBindGroupCmd>();
@ -779,6 +799,15 @@ namespace backend {
cmd->reference = reference; cmd->reference = reference;
} }
void CommandBufferBuilder::SetBlendColor(float r, float g, float b, float a) {
SetBlendColorCmd* cmd = allocator.Allocate<SetBlendColorCmd>(Command::SetBlendColor);
new(cmd) SetBlendColorCmd;
cmd->r = r;
cmd->g = g;
cmd->b = b;
cmd->a = a;
}
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");

View File

@ -81,6 +81,7 @@ namespace backend {
void SetComputePipeline(ComputePipelineBase* pipeline); void SetComputePipeline(ComputePipelineBase* pipeline);
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 SetBindGroup(uint32_t groupIndex, BindGroupBase* group); void SetBindGroup(uint32_t groupIndex, BindGroupBase* group);
void SetIndexBuffer(BufferBase* buffer, uint32_t offset, nxt::IndexFormat format); void SetIndexBuffer(BufferBase* buffer, uint32_t offset, nxt::IndexFormat format);

View File

@ -44,6 +44,7 @@ namespace backend {
SetRenderPipeline, SetRenderPipeline,
SetPushConstants, SetPushConstants,
SetStencilReference, SetStencilReference,
SetBlendColor,
SetBindGroup, SetBindGroup,
SetIndexBuffer, SetIndexBuffer,
SetVertexBuffers, SetVertexBuffers,
@ -139,6 +140,10 @@ namespace backend {
uint32_t reference; uint32_t reference;
}; };
struct SetBlendColorCmd {
float r, g, b, a;
};
struct SetBindGroupCmd { struct SetBindGroupCmd {
uint32_t index; uint32_t index;
Ref<BindGroupBase> group; Ref<BindGroupBase> group;

View File

@ -485,6 +485,14 @@ namespace d3d12 {
} }
break; break;
case Command::SetBlendColor:
{
SetBlendColorCmd* cmd = commands.NextCommand<SetBlendColorCmd>();
ASSERT(lastRenderPipeline);
commandList->OMSetBlendFactor(static_cast<const FLOAT*>(&cmd->r));
}
break;
case Command::SetBindGroup: case Command::SetBindGroup:
{ {
SetBindGroupCmd* cmd = commands.NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = commands.NextCommand<SetBindGroupCmd>();

View File

@ -402,6 +402,20 @@ namespace metal {
} }
break; break;
case Command::SetBlendColor:
{
SetBlendColorCmd* cmd = commands.NextCommand<SetBlendColorCmd>();
ASSERT(encoders.render);
[encoders.render
setBlendColorRed:cmd->r
green:cmd->g
blue:cmd->b
alpha:cmd->a ];
}
break;
case Command::SetBindGroup: case Command::SetBindGroup:
{ {
SetBindGroupCmd* cmd = commands.NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = commands.NextCommand<SetBindGroupCmd>();

View File

@ -336,6 +336,12 @@ namespace opengl {
} }
break; break;
case Command::SetBlendColor:
{
commands.NextCommand<SetBlendColorCmd>();
}
break;
case Command::SetBindGroup: case Command::SetBindGroup:
{ {
SetBindGroupCmd* cmd = commands.NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = commands.NextCommand<SetBindGroupCmd>();