Add renderer blend state contract
This commit is contained in:
@@ -2273,6 +2273,13 @@ int record_render(int argc, char** argv)
|
||||
}
|
||||
|
||||
const auto shader_status = context.bind_shader(shader);
|
||||
const auto blend_status = context.set_blend_state(pp::renderer::BlendState {
|
||||
.enabled = true,
|
||||
.source_color = pp::renderer::BlendFactor::source_alpha,
|
||||
.destination_color = pp::renderer::BlendFactor::one_minus_source_alpha,
|
||||
.source_alpha = pp::renderer::BlendFactor::one,
|
||||
.destination_alpha = pp::renderer::BlendFactor::one_minus_source_alpha,
|
||||
});
|
||||
const auto bind_texture_status = context.bind_texture(0, texture);
|
||||
const auto mesh_status = context.bind_mesh(mesh);
|
||||
const auto draw_status = context.draw();
|
||||
@@ -2282,6 +2289,10 @@ int record_render(int argc, char** argv)
|
||||
print_error("record-render", shader_status.message);
|
||||
return 2;
|
||||
}
|
||||
if (!blend_status.ok()) {
|
||||
print_error("record-render", blend_status.message);
|
||||
return 2;
|
||||
}
|
||||
if (!bind_texture_status.ok()) {
|
||||
print_error("record-render", bind_texture_status.message);
|
||||
return 2;
|
||||
@@ -2337,6 +2348,7 @@ int record_render(int argc, char** argv)
|
||||
}
|
||||
|
||||
std::size_t draw_commands = 0;
|
||||
std::size_t blend_commands = 0;
|
||||
std::size_t bind_texture_commands = 0;
|
||||
std::size_t upload_commands = 0;
|
||||
std::size_t readback_commands = 0;
|
||||
@@ -2353,6 +2365,8 @@ int record_render(int argc, char** argv)
|
||||
for (const auto& command : commands) {
|
||||
if (command.kind == pp::renderer::RecordedRenderCommandKind::draw) {
|
||||
++draw_commands;
|
||||
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::set_blend_state) {
|
||||
++blend_commands;
|
||||
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::bind_texture) {
|
||||
++bind_texture_commands;
|
||||
const auto bound_bytes = pp::renderer::texture_byte_size(command.texture_desc);
|
||||
@@ -2384,6 +2398,7 @@ int record_render(int argc, char** argv)
|
||||
<< ",\"format\":\"rgba8\"}"
|
||||
<< ",\"commands\":" << commands.size()
|
||||
<< ",\"drawCommands\":" << draw_commands
|
||||
<< ",\"blendCommands\":" << blend_commands
|
||||
<< ",\"bindTextureCommands\":" << bind_texture_commands
|
||||
<< ",\"boundTextureBytes\":" << bound_texture_bytes
|
||||
<< ",\"uploadCommands\":" << upload_commands
|
||||
|
||||
Reference in New Issue
Block a user