Add renderer sampler state contract

This commit is contained in:
2026-06-02 15:56:26 +02:00
parent b68ddc42c6
commit 952a00e7d3
9 changed files with 322 additions and 53 deletions

View File

@@ -2298,6 +2298,14 @@ int record_render(int argc, char** argv)
.compare = pp::renderer::CompareOp::less_or_equal,
});
const auto bind_texture_status = context.bind_texture(0, texture);
const auto bind_sampler_status = context.bind_sampler(0, pp::renderer::SamplerDesc {
.min_filter = pp::renderer::SamplerFilter::linear,
.mag_filter = pp::renderer::SamplerFilter::linear,
.mip_filter = pp::renderer::SamplerFilter::linear,
.address_u = pp::renderer::SamplerAddressMode::clamp_to_edge,
.address_v = pp::renderer::SamplerAddressMode::clamp_to_edge,
.address_w = pp::renderer::SamplerAddressMode::clamp_to_edge,
});
const auto mesh_status = context.bind_mesh(mesh);
const auto draw_status = context.draw();
context.end_render_pass();
@@ -2318,6 +2326,10 @@ int record_render(int argc, char** argv)
print_error("record-render", bind_texture_status.message);
return 2;
}
if (!bind_sampler_status.ok()) {
print_error("record-render", bind_sampler_status.message);
return 2;
}
if (!mesh_status.ok()) {
print_error("record-render", mesh_status.message);
return 2;
@@ -2373,6 +2385,7 @@ int record_render(int argc, char** argv)
std::size_t blend_commands = 0;
std::size_t depth_commands = 0;
std::size_t bind_texture_commands = 0;
std::size_t bind_sampler_commands = 0;
std::size_t upload_commands = 0;
std::size_t readback_commands = 0;
std::size_t capture_commands = 0;
@@ -2400,6 +2413,8 @@ int record_render(int argc, char** argv)
if (bound_bytes.ok()) {
bound_texture_bytes += bound_bytes.value();
}
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::bind_sampler) {
++bind_sampler_commands;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::upload_texture) {
++upload_commands;
upload_bytes += command.upload_bytes;
@@ -2429,6 +2444,7 @@ int record_render(int argc, char** argv)
<< ",\"blendCommands\":" << blend_commands
<< ",\"depthCommands\":" << depth_commands
<< ",\"bindTextureCommands\":" << bind_texture_commands
<< ",\"bindSamplerCommands\":" << bind_sampler_commands
<< ",\"boundTextureBytes\":" << bound_texture_bytes
<< ",\"uploadCommands\":" << upload_commands
<< ",\"uploadBytes\":" << upload_bytes