diff options
author | quou <quou@disroot.org> | 2024-12-30 12:44:28 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-12-30 14:11:22 +1100 |
commit | e8baea58dd5c92b62c4eef1b5c1ca9648f44e7d7 (patch) | |
tree | e0e9685b8ae53e7984258965b8ad486d1781c8a3 /pipeline.cpp | |
parent | 90eed5c3684a6dd751afc2bcb7ae0ac919c143a8 (diff) |
ui renderer clipping
Diffstat (limited to 'pipeline.cpp')
-rw-r--r-- | pipeline.cpp | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/pipeline.cpp b/pipeline.cpp index 79bfc1d..cccd1c5 100644 --- a/pipeline.cpp +++ b/pipeline.cpp @@ -244,57 +244,61 @@ void Pipeline_Builder::vertex_format(Vertex_Format_Id vf) { } Pipeline& Pipeline_Builder::build() { + validate(); + pip->hash(); + return *pip; +} + +void Pipeline::hash() { #define h(n, v) \ n = fnv1a64_2(n, (uint8_t*)&v, sizeof v) - validate(); - pip->pipeline_hash = fnv1a64(0, 0); - h(pip->pipeline_hash, pip->vertex_format); - h(pip->pipeline_hash, pip->shader); - h(pip->pipeline_hash, pip->descriptor_count); - h(pip->pipeline_hash, pip->viewport[0]); - h(pip->pipeline_hash, pip->viewport[1]); - h(pip->pipeline_hash, pip->viewport[2]); - h(pip->pipeline_hash, pip->viewport[3]); - h(pip->pipeline_hash, pip->scissor[0]); - h(pip->pipeline_hash, pip->scissor[1]); - h(pip->pipeline_hash, pip->scissor[2]); - h(pip->pipeline_hash, pip->scissor[3]); - h(pip->pipeline_hash, pip->depth_test); - h(pip->pipeline_hash, pip->depth_write); - h(pip->pipeline_hash, pip->depth_mode); - h(pip->pipeline_hash, pip->blend_enable); - h(pip->pipeline_hash, pip->blend_mode); - h(pip->pipeline_hash, pip->blend_mode_alpha); - h(pip->pipeline_hash, pip->blend_src); - h(pip->pipeline_hash, pip->blend_dst); - h(pip->pipeline_hash, pip->blend_src_alpha); - h(pip->pipeline_hash, pip->blend_dst_alpha); - h(pip->pipeline_hash, pip->cull_mode); + pipeline_hash = fnv1a64(0, 0); + h(pipeline_hash, vertex_format); + h(pipeline_hash, shader); + h(pipeline_hash, descriptor_count); + h(pipeline_hash, viewport[0]); + h(pipeline_hash, viewport[1]); + h(pipeline_hash, viewport[2]); + h(pipeline_hash, viewport[3]); + h(pipeline_hash, scissor[0]); + h(pipeline_hash, scissor[1]); + h(pipeline_hash, scissor[2]); + h(pipeline_hash, scissor[3]); + h(pipeline_hash, depth_test); + h(pipeline_hash, depth_write); + h(pipeline_hash, depth_mode); + h(pipeline_hash, blend_enable); + h(pipeline_hash, blend_mode); + h(pipeline_hash, blend_mode_alpha); + h(pipeline_hash, blend_src); + h(pipeline_hash, blend_dst); + h(pipeline_hash, blend_src_alpha); + h(pipeline_hash, blend_dst_alpha); + h(pipeline_hash, cull_mode); { - int i, e = pip->descriptor_count; - pip->descriptor_resource_hash = fnv1a64(0, 0); + int i, e = descriptor_count; + descriptor_resource_hash = fnv1a64(0, 0); for (i = 0; i < e; i++) { - Descriptor* d = &pip->descriptors[i]; - h(pip->pipeline_hash, d->type); - h(pip->pipeline_hash, d->slot); - h(pip->descriptor_resource_hash, d->type); - h(pip->descriptor_resource_hash, d->slot); + Descriptor* d = &descriptors[i]; + h(pipeline_hash, d->type); + h(pipeline_hash, d->slot); + h(descriptor_resource_hash, d->type); + h(descriptor_resource_hash, d->slot); switch (d->type) { case Descriptor::Type::texture: { auto td = (Texture_Descriptor*)d->payload; - h(pip->descriptor_resource_hash, td->sampler); - h(pip->descriptor_resource_hash, td->texture); + h(descriptor_resource_hash, td->sampler); + h(descriptor_resource_hash, td->texture); } break; case Descriptor::Type::constant_buffer: { auto cd = (Constant_Buffer_Descriptor*)d->payload; - h(pip->descriptor_resource_hash, cd->buffer); - h(pip->descriptor_resource_hash, cd->size); - h(pip->descriptor_resource_hash, cd->offset); + h(descriptor_resource_hash, cd->buffer); + h(descriptor_resource_hash, cd->size); + h(descriptor_resource_hash, cd->offset); } break; } } } - return *pip; #undef h } |