diff options
-rw-r--r-- | pipeline.cpp | 11 | ||||
-rw-r--r-- | video.cpp | 4 | ||||
-rw-r--r-- | video.hpp | 12 |
3 files changed, 22 insertions, 5 deletions
diff --git a/pipeline.cpp b/pipeline.cpp index 8867a8d..8750db0 100644 --- a/pipeline.cpp +++ b/pipeline.cpp @@ -185,7 +185,12 @@ void Pipeline_Builder::texture( td->texture = t; } -void Pipeline_Builder::cbuffer(int binding, Buffer_Id id) { +void Pipeline_Builder::cbuffer( + int binding, + Buffer_Id id, + int offset, + int size +) { Descriptor* d; Constant_Buffer_Descriptor* cd; assert(pip->descriptor_count < pipeline_max_descriptors); @@ -194,6 +199,8 @@ void Pipeline_Builder::cbuffer(int binding, Buffer_Id id) { d->slot = binding; d->type = Descriptor::Type::constant_buffer; cd->buffer = id; + cd->offset = offset; + cd->size = size; } void Pipeline_Builder::vertex_format(Vertex_Format_Id vf) { @@ -237,6 +244,8 @@ Pipeline& Pipeline_Builder::build() { 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); } break; } } @@ -2760,8 +2760,8 @@ void Descriptor_Set_Vk::init( Buffer_Vk& b = *(Buffer_Vk*)&dev->get_buffer(cd->buffer); assert(cd->buffer); buf.buffer = b.buf; - buf.offset = 0; - buf.range = b.size; + buf.offset = cd->offset; + buf.range = cd->size? cd->size: b.size; wd.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; wd.pBufferInfo = &buf; } break; @@ -44,7 +44,7 @@ struct Sampler_Id : public Primitive_Id<uint32_t> { using Primitive_Id<uint32_t>::Primitive_Id; }; -#define descriptor_payload_size 8 +#define descriptor_payload_size 16 struct Descriptor { enum class Type { @@ -61,6 +61,7 @@ struct Texture_Descriptor { }; struct Constant_Buffer_Descriptor { + int offset, size; Buffer_Id buffer; }; @@ -146,6 +147,8 @@ struct Pipeline { Constant_Buffer_Descriptor* cb = (Constant_Buffer_Descriptor*)b.payload; if (ca->buffer != cb->buffer) return false; + if (ca->size != cb->size) return false; + if (ca->offset != cb->offset) return false; } break; } } @@ -254,7 +257,12 @@ struct Pipeline_Builder { void shader(Shader_Id s); void vertex_format(Vertex_Format_Id vf); void texture(int binding, Texture_Id t, Sampler_Id s); - void cbuffer(int binding, Buffer_Id id); + void cbuffer( + int binding, + Buffer_Id id, + int offset = 0, + int size = 0 + ); Pipeline& build(); void validate(); }; |