+ }
+
+ return 1;
+}
+
+GLuint
+fastpath_check_context_blend(GLGlueContext *oldctx, GLGlueContext *newctx)
+{
+ if(!(oldctx->_blend_flag | newctx->_blend_flag)) {
+ return 1;
+ }
+
+ if STATES_COMPARE(gl_blend_color, 4 * sizeof(GLclampf)) {
+ CHECK_GL_ERROR(_orig_fastpath_glBlendColor(newctx->gl_blend_color[0],
+ newctx->gl_blend_color[1],
+ newctx->gl_blend_color[2],
+ newctx->gl_blend_color[3]))
+ }
+
+ if ((oldctx->gl_blend_src_rgb[0] != newctx->gl_blend_src_rgb[0]) ||
+ (oldctx->gl_blend_dst_rgb[0] != newctx->gl_blend_dst_rgb[0]) ||
+ (oldctx->gl_blend_src_alpha[0] != newctx->gl_blend_src_alpha[0]) ||
+ (oldctx->gl_blend_dst_alpha[0] != newctx->gl_blend_dst_alpha[0])) {
+ CHECK_GL_ERROR(_orig_fastpath_glBlendFuncSeparate(newctx->gl_blend_src_rgb[0],
+ newctx->gl_blend_dst_rgb[0],
+ newctx->gl_blend_src_alpha[0],
+ newctx->gl_blend_dst_alpha[0]))
+ }
+
+ if ((oldctx->gl_blend_equation_rgb[0] != newctx->gl_blend_equation_rgb[0]) ||
+ (oldctx->gl_blend_equation_alpha[0] != newctx->gl_blend_equation_alpha[0])) {
+ CHECK_GL_ERROR(_orig_fastpath_glBlendEquationSeparate(
+ newctx->gl_blend_equation_rgb[0],
+ newctx->gl_blend_equation_alpha[0]))
+ }
+
+ return 1;
+}
+
+GLuint
+fastpath_check_context_stencil_1(GLGlueContext *oldctx, GLGlueContext *newctx)
+{
+ if(!(oldctx->_stencil_flag1 | newctx->_stencil_flag1)) {
+ return 1;
+ }
+
+ if ((oldctx->gl_stencil_func[0] != newctx->gl_stencil_func[0]) ||
+ (oldctx->gl_stencil_ref[0] != newctx->gl_stencil_ref[0]) ||
+ (oldctx->gl_stencil_value_mask[0] != newctx->gl_stencil_value_mask[0])) {
+ CHECK_GL_ERROR(_orig_fastpath_glStencilFuncSeparate(GL_FRONT,
+ newctx->gl_stencil_func[0],
+ newctx->gl_stencil_ref[0],
+ newctx->gl_stencil_value_mask[0]))
+ }
+
+ if ((oldctx->gl_stencil_fail[0] != newctx->gl_stencil_fail[0]) ||
+ (oldctx->gl_stencil_pass_depth_fail[0] != newctx->gl_stencil_pass_depth_fail[0]) ||
+ (oldctx->gl_stencil_pass_depth_pass[0] != newctx->gl_stencil_pass_depth_pass[0])) {
+ CHECK_GL_ERROR(_orig_fastpath_glStencilOpSeparate(GL_FRONT,
+ newctx->gl_stencil_fail[0],
+ newctx->gl_stencil_pass_depth_fail[0],
+ newctx->gl_stencil_pass_depth_pass[0]))
+ }
+
+ if STATE_COMPARE(gl_stencil_writemask[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glStencilMaskSeparate(GL_FRONT,
+ newctx->gl_stencil_writemask[0]))
+ }
+
+ return 1;
+}
+
+GLuint
+fastpath_check_context_stencil_2(GLGlueContext *oldctx, GLGlueContext *newctx)
+{
+ if(!(oldctx->_stencil_flag2 | newctx->_stencil_flag2)) {
+ return 1;
+ }
+
+ if ((oldctx->gl_stencil_back_func[0] != newctx->gl_stencil_back_func[0]) ||
+ (oldctx->gl_stencil_back_ref[0] != newctx->gl_stencil_back_ref[0]) ||
+ (oldctx->gl_stencil_back_value_mask[0] != newctx->gl_stencil_back_value_mask[0])) {
+ CHECK_GL_ERROR(_orig_fastpath_glStencilFuncSeparate(GL_BACK,
+ newctx->gl_stencil_back_func[0],
+ newctx->gl_stencil_back_ref[0],
+ newctx->gl_stencil_back_value_mask[0]))
+ }
+
+ if ((oldctx->gl_stencil_back_fail[0] != newctx->gl_stencil_back_fail[0]) ||
+ (oldctx->gl_stencil_back_pass_depth_fail[0] != newctx->gl_stencil_back_pass_depth_fail[0]) ||
+ (oldctx->gl_stencil_back_pass_depth_pass[0] != newctx->gl_stencil_back_pass_depth_pass[0])) {
+ CHECK_GL_ERROR(_orig_fastpath_glStencilOpSeparate(GL_BACK,
+ newctx->gl_stencil_back_fail[0],
+ newctx->gl_stencil_back_pass_depth_fail[0],
+ newctx->gl_stencil_back_pass_depth_pass[0]))
+ }
+
+ if STATE_COMPARE(gl_stencil_back_writemask[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glStencilMaskSeparate(GL_BACK,
+ newctx->gl_stencil_back_writemask[0]))
+ }
+
+ if STATE_COMPARE(gl_stencil_clear_value[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glClearStencil(newctx->gl_stencil_clear_value[0]))
+ }
+
+ return 1;
+}
+
+GLuint
+fastpath_check_context_pixel_1(GLGlueContext *oldctx, GLGlueContext *newctx)
+{
+ if(!(oldctx->_pixel_flag1 | newctx->_pixel_flag1)) {
+ return 1;
+ }
+
+ if STATE_COMPARE(gl_pack_row_length[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_ROW_LENGTH,
+ newctx->gl_pack_row_length[0]))
+ }
+
+ if STATE_COMPARE(gl_pack_skip_rows[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_SKIP_ROWS,
+ newctx->gl_pack_skip_rows[0]))
+ }
+
+ if STATE_COMPARE(gl_pack_skip_pixels[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_SKIP_PIXELS,
+ newctx->gl_pack_skip_pixels[0]))
+ }
+
+ if STATE_COMPARE(gl_pack_alignment[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_ALIGNMENT,
+ newctx->gl_pack_alignment[0]))
+ }
+
+ return 1;
+}
+
+GLuint
+fastpath_check_context_pixel_2(GLGlueContext *oldctx, GLGlueContext *newctx)
+{
+ if(!(oldctx->_pixel_flag2 | newctx->_pixel_flag2)) {
+ return 1;
+ }
+
+ if STATE_COMPARE(gl_unpack_row_length[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_ROW_LENGTH,
+ newctx->gl_unpack_row_length[0]))
+ }
+
+ if STATE_COMPARE(gl_unpack_skip_rows[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_ROWS,
+ newctx->gl_unpack_skip_rows[0]))
+ }
+
+ if STATE_COMPARE(gl_unpack_skip_pixels[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_PIXELS,
+ newctx->gl_unpack_skip_pixels[0]))
+ }
+
+ if STATE_COMPARE(gl_unpack_alignment[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_ALIGNMENT,
+ newctx->gl_unpack_alignment[0]))
+ }
+
+ if STATE_COMPARE(gl_unpack_image_height[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,
+ newctx->gl_unpack_image_height[0]))
+ }
+
+ if STATE_COMPARE(gl_unpack_skip_images[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_IMAGES,
+ newctx->gl_unpack_skip_images[0]))
+ }
+
+ return 1;
+}
+
+GLuint
+fastpath_check_context_misc_1(GLGlueContext *oldctx, GLGlueContext *newctx)
+{
+ if(!(oldctx->_misc_flag1 | newctx->_misc_flag1)) {
+ return 1;
+ }
+
+ if STATE_COMPARE(gl_front_face[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glFrontFace(newctx->gl_front_face[0]))
+ }
+
+ if STATE_COMPARE(gl_line_width[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glLineWidth(newctx->gl_line_width[0]))
+ }
+
+ if ((oldctx->gl_polygon_offset_factor[0] != newctx->gl_polygon_offset_factor[0]) ||
+ (oldctx->gl_polygon_offset_units[0] != newctx->gl_polygon_offset_units[0])) {
+ CHECK_GL_ERROR(_orig_fastpath_glPolygonOffset(
+ newctx->gl_polygon_offset_factor[0],
+ newctx->gl_polygon_offset_units[0]))
+ }
+
+ if ((oldctx->gl_sample_coverage_value[0] != newctx->gl_sample_coverage_value[0]) ||
+ (oldctx->gl_sample_coverage_invert[0] != newctx->gl_sample_coverage_invert[0])) {
+ CHECK_GL_ERROR(_orig_fastpath_glSampleCoverage(
+ newctx->gl_sample_coverage_value[0],
+ newctx->gl_sample_coverage_invert[0]))
+ }
+
+ if STATE_COMPARE(gl_fragment_shader_derivative_hint[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
+ newctx->gl_fragment_shader_derivative_hint[0]))
+ }
+
+ return 1;
+}
+
+GLuint
+fastpath_check_context_misc_2(GLGlueContext *oldctx, GLGlueContext *newctx)
+{
+ if(!(oldctx->_misc_flag2 | newctx->_misc_flag2)) {
+ return 1;
+ }
+
+ if STATES_COMPARE(gl_scissor_box, 4 * sizeof(GLint)) {
+ CHECK_GL_ERROR(_orig_fastpath_glScissor(newctx->gl_scissor_box[0],
+ newctx->gl_scissor_box[1],
+ newctx->gl_scissor_box[2],
+ newctx->gl_scissor_box[3]))
+ }
+
+ return 1;
+}
+
+GLuint
+fastpath_check_context_misc_3(GLGlueContext *oldctx, GLGlueContext *newctx)
+{
+ if(!(oldctx->_misc_flag3 | newctx->_misc_flag3)) {
+ return 1;
+ }
+
+ if STATE_COMPARE(gl_read_buffer[0]) {
+ CHECK_GL_ERROR(_orig_fastpath_glReadBuffer(newctx->gl_read_buffer[0]))
+ }
+
+ if STATES_COMPARE(gl_draw_buffers, oldctx->gl_draw_buffers_num[0] * sizeof(GLenum)) {
+ int drawBuffSize = 16;
+ /* If the context has only default framebuffer, then size of glDrawBuffers can only be 1 */
+ if (fastpath_ostate_has_object_type(&newctx->ostate, GL_OBJECT_TYPE_FRAMEBUFFER) == 0) {
+ drawBuffSize = 1;