+ if(state.vertex_setup)
+ {
+ if(const VertexArray *array = state.vertex_setup->get_vertex_array())
+ array->refresh(frame_index);
+ if(const VertexArray *array = state.vertex_setup->get_instance_array())
+ array->refresh(frame_index);
+ }
+ ps.set_vertex_setup(state.vertex_setup);
+
+ ps.set_front_face(state.front_face);
+ ps.set_face_cull(state.face_cull);
+
+ if(state.texture_count<texture_stack.size())
+ flush_resources(texture_stack, state.texture_count);
+
+ for(const BoundResource<SampledTexture> &t: texture_stack)
+ if(t.resource.texture && t.replaced<0)
+ {
+ if(t.binding<0 || shprog_changed)
+ t.binding = state.shprog->get_uniform_binding(t.tag);
+ if(t.binding>=0)
+ {
+ if(t.resource.sampler)
+ ps.set_texture(t.binding, t.resource.texture, t.resource.level, t.resource.sampler);
+ else
+ ps.set_storage_texture(t.binding, t.resource.texture);
+ }
+ }
+
+ static const DepthTest default_depth_test;
+ ps.set_depth_test(state.depth_test ? *state.depth_test : default_depth_test);
+ static const StencilTest default_stencil_test;
+ ps.set_stencil_test(state.stencil_test ? *state.stencil_test : default_stencil_test);
+ static const Blend default_blend;
+ ps.set_blend(state.blend ? *state.blend : default_blend);