X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frender%2Frenderer.cpp;h=5262d09a90ee2862e6c0db07dcd02e71044241fd;hp=ce0b3447b2b02a43df1029db2b358cd4f8aa2cb8;hb=HEAD;hpb=cebf1330ef6773b7b4496dc279ec02a7ca4351bb diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index ce0b3447..7e010b3f 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -71,7 +71,7 @@ void Renderer::push_state() void Renderer::pop_state() { - if(state_stack.size()==1) + if(state_stack.size()<=1) throw stack_underflow("Renderer::pop_state"); uintptr_t old_pipeline = current_state->pipeline_key; @@ -279,21 +279,25 @@ void Renderer::clear(const ClearValue *values) void Renderer::draw(const Batch &batch) { apply_state(); - batch.refresh(frame_index); - PipelineState &ps = get_pipeline_state(); - ps.set_primitive_type(batch.get_type()); - commands.use_pipeline(&ps); + apply_batch(batch); commands.draw(batch); } void Renderer::draw_instanced(const Batch &batch, unsigned count) { apply_state(); + apply_batch(batch); + commands.draw_instanced(batch, count); +} + +void Renderer::apply_batch(const Batch &batch) +{ batch.refresh(frame_index); PipelineState &ps = get_pipeline_state(); ps.set_primitive_type(batch.get_type()); + if(batch.get_type()==PATCHES) + ps.set_patch_size(batch.get_patch_size()); commands.use_pipeline(&ps); - commands.draw_instanced(batch, count); } void Renderer::dispatch(unsigned count_x, unsigned count_y, unsigned count_z) @@ -304,21 +308,16 @@ void Renderer::dispatch(unsigned count_x, unsigned count_y, unsigned count_z) commands.dispatch(count_x, count_y, count_z); } -void Renderer::resolve_multisample(Framebuffer &target) +void Renderer::resolve_multisample() { const State &state = get_state(); if(!state.framebuffer) throw invalid_operation("Renderer::resolve_multisample"); - unsigned width = state.framebuffer->get_width(); - unsigned height = state.framebuffer->get_height(); - if(target.get_width()!=width || target.get_height()!=height) - throw incompatible_data("Renderer::resolve_multisample"); - apply_framebuffer(); commands.use_pipeline(&get_pipeline_state()); - commands.resolve_multisample(target); + commands.resolve_multisample(); } void Renderer::begin_query(const QueryPool &pool, unsigned index)