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;
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)
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)