void Canvas::text_transparent(PixelScalar x, PixelScalar y, const TCHAR *text) { assert(text != NULL); assert(ValidateUTF8(text)); #ifdef HAVE_GLES assert(x_offset == OpenGL::translate_x); assert(y_offset == OpenGL::translate_y); #endif if (font == NULL) return; GLTexture *texture = TextCache::Get(font, text); if (texture == NULL) return; GLEnable scope(GL_TEXTURE_2D); texture->Bind(); GLLogicOp logic_op(GL_AND_INVERTED); /* cut out the shape in black */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); texture->Draw(x, y); if (text_color != COLOR_BLACK) { /* draw the text color on top */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); logic_op.set(GL_OR); text_color.Set(); texture->Draw(x, y); } }
/** * Specify a logic pixel operation for color index rendering. * * \param opcode operation. * * Verifies that \p opcode is a valid enum and updates * gl_colorbuffer_attrib::LogicOp. * On a change, flushes the vertices and notifies the driver via the * dd_function_table::LogicOpcode callback. */ void GLAPIENTRY _mesa_LogicOp( GLenum opcode ) { GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glLogicOp(%s)\n", _mesa_enum_to_string(opcode)); switch (opcode) { case GL_CLEAR: case GL_SET: case GL_COPY: case GL_COPY_INVERTED: case GL_NOOP: case GL_INVERT: case GL_AND: case GL_NAND: case GL_OR: case GL_NOR: case GL_XOR: case GL_EQUIV: case GL_AND_REVERSE: case GL_AND_INVERTED: case GL_OR_REVERSE: case GL_OR_INVERTED: break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glLogicOp" ); return; } logic_op(ctx, opcode); }
void MaskedIcon::draw(Canvas &canvas, int x, int y) const { assert(defined()); #ifdef ENABLE_OPENGL if (size.cx == 0) /* hack: do the postponed layout calcuation now */ const_cast<MaskedIcon *>(this)->CalculateLayout((bool)size.cy); GLTexture &texture = *bitmap.native(); GLEnable scope(GL_TEXTURE_2D); texture.bind(); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); GLLogicOp logic_op(GL_OR); texture.draw(x - origin.x, y - origin.y, size.cx, size.cy, 0, 0, size.cx, size.cy); logic_op.set(GL_AND); texture.draw(x - origin.x, y - origin.y, size.cx, size.cy, size.cx, 0, size.cx, size.cy); #else canvas.copy_or(x - origin.x, y - origin.y, size.cx, size.cy, bitmap, 0, 0); canvas.copy_and(x - origin.x, y - origin.y, size.cx, size.cy, bitmap, size.cx, 0); #endif }
void Canvas::text_clipped(int x, int y, unsigned width, const TCHAR *text) { #ifdef HAVE_GLES assert(x_offset == OpenGL::translate_x); assert(y_offset == OpenGL::translate_y); #endif if (font == NULL) return; GLTexture *texture = TextCache::get(font, COLOR_BLACK, COLOR_WHITE, text); if (texture == NULL) return; GLEnable scope(GL_TEXTURE_2D); texture->bind(); GLLogicOp logic_op(GL_AND_INVERTED); unsigned height = texture->get_height(); if (texture->get_width() < width) width = texture->get_width(); /* cut out the shape in black */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); texture->draw(x, y, width, height, 0, 0, width, height); if (text_color != COLOR_BLACK) { /* draw the text color on top */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); logic_op.set(GL_OR); text_color.set(); texture->draw(x, y, width, height, 0, 0, width, height); } }
// _iand, _land, _ior, _lor, _ixor, _lxor void LIRGenerator::do_LogicOp(LogicOp* x) { LIRItem left(x->x(), this); LIRItem right(x->y(), this); left.load_item(); right.load_nonconstant(); LIR_Opr reg = rlock_result(x); logic_op(x->op(), reg, left.result(), right.result()); }
void Canvas::StretchNotOr(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const Bitmap &src, PixelScalar src_x, PixelScalar src_y, UPixelScalar src_width, UPixelScalar src_height) { GLLogicOp logic_op(GL_OR_INVERTED); Stretch(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y, src_width, src_height); }
void Canvas::CopyNot(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const Bitmap &src, PixelScalar src_x, PixelScalar src_y) { assert(src.IsDefined()); GLLogicOp logic_op(GL_COPY_INVERTED); copy(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y); }
void Canvas::CopyAnd(int dest_x, int dest_y, unsigned dest_width, unsigned dest_height, const Bitmap &src, int src_x, int src_y) { assert(src.IsDefined()); GLLogicOp logic_op(GL_AND); Copy(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y); }
void Canvas::copy_not(int dest_x, int dest_y, unsigned dest_width, unsigned dest_height, const Bitmap &src, int src_x, int src_y) { assert(src.defined()); GLLogicOp logic_op(GL_COPY_INVERTED); copy(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y); }
// _iand, _land, _ior, _lor, _ixor, _lxor void LIRGenerator::do_LogicOp(LogicOp* x) { // when an operand with use count 1 is the left operand, then it is // likely that no move for 2-operand-LIR-form is necessary if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) { x->swap_operands(); } LIRItem left(x->x(), this); LIRItem right(x->y(), this); left.load_item(); right.load_nonconstant(); LIR_Opr reg = rlock_result(x); logic_op(x->op(), reg, left.result(), right.result()); }
void Canvas::text(PixelScalar x, PixelScalar y, const TCHAR *text) { assert(text != NULL); assert(ValidateUTF8(text)); #ifdef HAVE_GLES assert(x_offset == OpenGL::translate_x); assert(y_offset == OpenGL::translate_y); #endif if (font == NULL) return; GLTexture *texture = TextCache::Get(font, text); if (texture == NULL) return; if (background_mode == OPAQUE) /* draw the opaque background */ DrawFilledRectangle(x, y, x + texture->GetWidth(), y + texture->GetHeight(), background_color); GLEnable scope(GL_TEXTURE_2D); texture->Bind(); GLLogicOp logic_op(GL_AND_INVERTED); if (background_mode != OPAQUE || background_color != COLOR_BLACK) { /* cut out the shape in black */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); texture->Draw(x, y); } if (text_color != COLOR_BLACK) { /* draw the text color on top */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); logic_op.set(GL_OR); text_color.Set(); texture->Draw(x, y); } }
void MaskedIcon::Draw(Canvas &canvas, PixelScalar x, PixelScalar y) const { assert(IsDefined()); #ifdef ENABLE_OPENGL if (size.cx == 0) /* hack: do the postponed layout calcuation now */ const_cast<MaskedIcon *>(this)->CalculateLayout((bool)size.cy); GLTexture &texture = *bitmap.GetNative(); GLEnable scope(GL_TEXTURE_2D); texture.Bind(); OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); GLLogicOp logic_op(GL_OR); texture.Draw(x - origin.x, y - origin.y, size.cx, size.cy, 0, 0, size.cx, size.cy); logic_op.set(GL_AND); texture.Draw(x - origin.x, y - origin.y, size.cx, size.cy, size.cx, 0, size.cx, size.cy); #else #ifdef USE_GDI /* our icons are monochrome bitmaps, and GDI uses current colors of the destination HDC when blitting from a monochrome HDC */ canvas.SetTextColor(COLOR_BLACK); canvas.SetBackgroundColor(COLOR_WHITE); #endif canvas.copy_or(x - origin.x, y - origin.y, size.cx, size.cy, bitmap, 0, 0); canvas.copy_and(x - origin.x, y - origin.y, size.cx, size.cy, bitmap, size.cx, 0); #endif }
void Canvas::text(int x, int y, const TCHAR *text) { #ifdef HAVE_GLES assert(x_offset == OpenGL::translate_x); assert(y_offset == OpenGL::translate_y); #endif if (font == NULL) return; GLTexture *texture = TextCache::get(font, COLOR_BLACK, COLOR_WHITE, text); if (texture == NULL) return; if (background_mode == OPAQUE) /* draw the opaque background */ fill_rectangle(x, y, x + texture->get_width(), y + texture->get_height(), background_color); GLEnable scope(GL_TEXTURE_2D); texture->bind(); GLLogicOp logic_op(GL_AND_INVERTED); if (background_mode != OPAQUE || background_color != COLOR_BLACK) { /* cut out the shape in black */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); texture->draw(x, y); } if (text_color != COLOR_BLACK) { /* draw the text color on top */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); logic_op.set(GL_OR); text_color.set(); texture->draw(x, y); } }
void Canvas::StretchMono(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const Bitmap &src, PixelScalar src_x, PixelScalar src_y, UPixelScalar src_width, UPixelScalar src_height, Color fg_color, Color bg_color) { /* note that this implementation ignores the background color; it is not mandatory, and we can assume that the background is already set; it is only being passed to this function because the GDI implementation will be faster when erasing the background again */ GLTexture &texture = *src.GetNative(); GLEnable scope(GL_TEXTURE_2D); texture.Bind(); OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); if (fg_color == COLOR_WHITE) { /* white text requested: use this trivial implementation */ GLLogicOp logic_op(GL_OR_INVERTED); texture.Draw(dest_x, dest_y, dest_width, dest_height, src_x, src_y, src_width, src_height); return; } /* apply the mask, pixels will be black then */ GLLogicOp logic_op(GL_AND); if (bg_color != COLOR_BLACK) texture.Draw(dest_x, dest_y, dest_width, dest_height, src_x, src_y, src_width, src_height); if (fg_color != COLOR_BLACK) { /* draw */ #ifndef HAVE_GLES if (fg_color != COLOR_WHITE) { /* XXX OpenGL/ES doesn't support GL_OPERAND0_RGB; we can't print colored mono images currently */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE); OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); const GLfloat color[] = { GLfloat(fg_color.Red() / 256.), GLfloat(fg_color.Green() / 256.), GLfloat(fg_color.Blue() / 256.), GLfloat(1.0), }; OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT); OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color); logic_op.set(GL_OR); } else #endif logic_op.set(GL_OR_INVERTED); texture.Draw(dest_x, dest_y, dest_width, dest_height, src_x, src_y, src_width, src_height); } }
void GLAPIENTRY _mesa_LogicOp_no_error(GLenum opcode) { GET_CURRENT_CONTEXT(ctx); logic_op(ctx, opcode); }
void GLGSRender::begin() { rsx::thread::begin(); if (skip_frame) return; if (conditional_render_enabled && conditional_render_test_failed) return; init_buffers(); if (!framebuffer_status_valid) return; std::chrono::time_point<steady_clock> then = steady_clock::now(); bool color_mask_b = rsx::method_registers.color_mask_b(); bool color_mask_g = rsx::method_registers.color_mask_g(); bool color_mask_r = rsx::method_registers.color_mask_r(); bool color_mask_a = rsx::method_registers.color_mask_a(); gl_state.color_mask(color_mask_r, color_mask_g, color_mask_b, color_mask_a); gl_state.depth_mask(rsx::method_registers.depth_write_enabled()); gl_state.stencil_mask(rsx::method_registers.stencil_mask()); if (gl_state.enable(rsx::method_registers.depth_test_enabled(), GL_DEPTH_TEST)) { gl_state.depth_func(comparison_op(rsx::method_registers.depth_func())); } if (glDepthBoundsEXT && (gl_state.enable(rsx::method_registers.depth_bounds_test_enabled(), GL_DEPTH_BOUNDS_TEST_EXT))) { gl_state.depth_bounds(rsx::method_registers.depth_bounds_min(), rsx::method_registers.depth_bounds_max()); } gl_state.depth_range(rsx::method_registers.clip_min(), rsx::method_registers.clip_max()); gl_state.enable(rsx::method_registers.dither_enabled(), GL_DITHER); if (gl_state.enable(rsx::method_registers.blend_enabled(), GL_BLEND)) { glBlendFuncSeparate(blend_factor(rsx::method_registers.blend_func_sfactor_rgb()), blend_factor(rsx::method_registers.blend_func_dfactor_rgb()), blend_factor(rsx::method_registers.blend_func_sfactor_a()), blend_factor(rsx::method_registers.blend_func_dfactor_a())); auto blend_colors = rsx::get_constant_blend_colors(); glBlendColor(blend_colors[0], blend_colors[1], blend_colors[2], blend_colors[3]); glBlendEquationSeparate(blend_equation(rsx::method_registers.blend_equation_rgb()), blend_equation(rsx::method_registers.blend_equation_a())); } if (gl_state.enable(rsx::method_registers.stencil_test_enabled(), GL_STENCIL_TEST)) { glStencilFunc(comparison_op(rsx::method_registers.stencil_func()), rsx::method_registers.stencil_func_ref(), rsx::method_registers.stencil_func_mask()); glStencilOp(stencil_op(rsx::method_registers.stencil_op_fail()), stencil_op(rsx::method_registers.stencil_op_zfail()), stencil_op(rsx::method_registers.stencil_op_zpass())); if (rsx::method_registers.two_sided_stencil_test_enabled()) { glStencilMaskSeparate(GL_BACK, rsx::method_registers.back_stencil_mask()); glStencilFuncSeparate(GL_BACK, comparison_op(rsx::method_registers.back_stencil_func()), rsx::method_registers.back_stencil_func_ref(), rsx::method_registers.back_stencil_func_mask()); glStencilOpSeparate(GL_BACK, stencil_op(rsx::method_registers.back_stencil_op_fail()), stencil_op(rsx::method_registers.back_stencil_op_zfail()), stencil_op(rsx::method_registers.back_stencil_op_zpass())); } } gl_state.enablei(rsx::method_registers.blend_enabled_surface_1(), GL_BLEND, 1); gl_state.enablei(rsx::method_registers.blend_enabled_surface_2(), GL_BLEND, 2); gl_state.enablei(rsx::method_registers.blend_enabled_surface_3(), GL_BLEND, 3); if (gl_state.enable(rsx::method_registers.logic_op_enabled(), GL_COLOR_LOGIC_OP)) { gl_state.logic_op(logic_op(rsx::method_registers.logic_operation())); } gl_state.line_width(rsx::method_registers.line_width()); gl_state.enable(rsx::method_registers.line_smooth_enabled(), GL_LINE_SMOOTH); gl_state.enable(rsx::method_registers.poly_offset_point_enabled(), GL_POLYGON_OFFSET_POINT); gl_state.enable(rsx::method_registers.poly_offset_line_enabled(), GL_POLYGON_OFFSET_LINE); gl_state.enable(rsx::method_registers.poly_offset_fill_enabled(), GL_POLYGON_OFFSET_FILL); gl_state.polygon_offset(rsx::method_registers.poly_offset_scale(), rsx::method_registers.poly_offset_bias()); if (gl_state.enable(rsx::method_registers.cull_face_enabled(), GL_CULL_FACE)) { gl_state.cull_face(cull_face(rsx::method_registers.cull_face_mode())); } gl_state.front_face(front_face(rsx::method_registers.front_face_mode())); //TODO //NV4097_SET_ANISO_SPREAD //NV4097_SET_SPECULAR_ENABLE //NV4097_SET_TWO_SIDE_LIGHT_EN //NV4097_SET_FLAT_SHADE_OP //NV4097_SET_EDGE_FLAG //NV4097_SET_COLOR_KEY_COLOR //NV4097_SET_SHADER_CONTROL //NV4097_SET_ZMIN_MAX_CONTROL //NV4097_SET_ANTI_ALIASING_CONTROL //NV4097_SET_CLIP_ID_TEST_ENABLE std::chrono::time_point<steady_clock> now = steady_clock::now(); m_begin_time += (u32)std::chrono::duration_cast<std::chrono::microseconds>(now - then).count(); }
void GLGSRender::begin() { rsx::thread::begin(); init_buffers(); std::chrono::time_point<std::chrono::system_clock> then = std::chrono::system_clock::now(); bool color_mask_b = rsx::method_registers.color_mask_b(); bool color_mask_g = rsx::method_registers.color_mask_g(); bool color_mask_r = rsx::method_registers.color_mask_r(); bool color_mask_a = rsx::method_registers.color_mask_a(); __glcheck glColorMask(color_mask_r, color_mask_g, color_mask_b, color_mask_a); __glcheck glDepthMask(rsx::method_registers.depth_write_enabled()); __glcheck glStencilMask(rsx::method_registers.stencil_mask()); if (__glcheck enable(rsx::method_registers.depth_test_enabled(), GL_DEPTH_TEST)) { __glcheck glDepthFunc(comparison_op(rsx::method_registers.depth_func())); __glcheck glDepthMask(rsx::method_registers.depth_write_enabled()); } if (glDepthBoundsEXT && (__glcheck enable(rsx::method_registers.depth_bounds_test_enabled(), GL_DEPTH_BOUNDS_TEST_EXT))) { __glcheck glDepthBoundsEXT(rsx::method_registers.depth_bounds_min(), rsx::method_registers.depth_bounds_max()); } __glcheck glDepthRange(rsx::method_registers.clip_min(), rsx::method_registers.clip_max()); __glcheck enable(rsx::method_registers.dither_enabled(), GL_DITHER); if (__glcheck enable(rsx::method_registers.blend_enabled(), GL_BLEND)) { __glcheck glBlendFuncSeparate(blend_factor(rsx::method_registers.blend_func_sfactor_rgb()), blend_factor(rsx::method_registers.blend_func_dfactor_rgb()), blend_factor(rsx::method_registers.blend_func_sfactor_a()), blend_factor(rsx::method_registers.blend_func_dfactor_a())); if (rsx::method_registers.surface_color() == rsx::surface_color_format::w16z16y16x16) //TODO: check another color formats { u16 blend_color_r = rsx::method_registers.blend_color_16b_r(); u16 blend_color_g = rsx::method_registers.blend_color_16b_g(); u16 blend_color_b = rsx::method_registers.blend_color_16b_b(); u16 blend_color_a = rsx::method_registers.blend_color_16b_a(); __glcheck glBlendColor(blend_color_r / 65535.f, blend_color_g / 65535.f, blend_color_b / 65535.f, blend_color_a / 65535.f); } else { u8 blend_color_r = rsx::method_registers.blend_color_8b_r(); u8 blend_color_g = rsx::method_registers.blend_color_8b_g(); u8 blend_color_b = rsx::method_registers.blend_color_8b_b(); u8 blend_color_a = rsx::method_registers.blend_color_8b_a(); __glcheck glBlendColor(blend_color_r / 255.f, blend_color_g / 255.f, blend_color_b / 255.f, blend_color_a / 255.f); } __glcheck glBlendEquationSeparate(blend_equation(rsx::method_registers.blend_equation_rgb()), blend_equation(rsx::method_registers.blend_equation_a())); } if (__glcheck enable(rsx::method_registers.stencil_test_enabled(), GL_STENCIL_TEST)) { __glcheck glStencilFunc(comparison_op(rsx::method_registers.stencil_func()), rsx::method_registers.stencil_func_ref(), rsx::method_registers.stencil_func_mask()); __glcheck glStencilOp(stencil_op(rsx::method_registers.stencil_op_fail()), stencil_op(rsx::method_registers.stencil_op_zfail()), stencil_op(rsx::method_registers.stencil_op_zpass())); if (rsx::method_registers.two_sided_stencil_test_enabled()) { __glcheck glStencilMaskSeparate(GL_BACK, rsx::method_registers.back_stencil_mask()); __glcheck glStencilFuncSeparate(GL_BACK, comparison_op(rsx::method_registers.back_stencil_func()), rsx::method_registers.back_stencil_func_ref(), rsx::method_registers.back_stencil_func_mask()); __glcheck glStencilOpSeparate(GL_BACK, stencil_op(rsx::method_registers.back_stencil_op_fail()), stencil_op(rsx::method_registers.back_stencil_op_zfail()), stencil_op(rsx::method_registers.back_stencil_op_zpass())); } } __glcheck enable(rsx::method_registers.blend_enabled_surface_1(), GL_BLEND, 1); __glcheck enable(rsx::method_registers.blend_enabled_surface_2(), GL_BLEND, 2); __glcheck enable(rsx::method_registers.blend_enabled_surface_3(), GL_BLEND, 3); if (__glcheck enable(rsx::method_registers.logic_op_enabled(), GL_COLOR_LOGIC_OP)) { __glcheck glLogicOp(logic_op(rsx::method_registers.logic_operation())); } __glcheck glLineWidth(rsx::method_registers.line_width()); __glcheck enable(rsx::method_registers.line_smooth_enabled(), GL_LINE_SMOOTH); //TODO //NV4097_SET_ANISO_SPREAD __glcheck enable(rsx::method_registers.poly_offset_point_enabled(), GL_POLYGON_OFFSET_POINT); __glcheck enable(rsx::method_registers.poly_offset_line_enabled(), GL_POLYGON_OFFSET_LINE); __glcheck enable(rsx::method_registers.poly_offset_fill_enabled(), GL_POLYGON_OFFSET_FILL); __glcheck glPolygonOffset(rsx::method_registers.poly_offset_scale(), rsx::method_registers.poly_offset_bias()); //NV4097_SET_SPECULAR_ENABLE //NV4097_SET_TWO_SIDE_LIGHT_EN //NV4097_SET_FLAT_SHADE_OP //NV4097_SET_EDGE_FLAG auto set_clip_plane_control = [&](int index, rsx::user_clip_plane_op control) { int value = 0; int location; if (m_program->uniforms.has_location("uc_m" + std::to_string(index), &location)) { switch (control) { default: LOG_ERROR(RSX, "bad clip plane control (0x%x)", (u8)control); case rsx::user_clip_plane_op::disable: value = 0; break; case rsx::user_clip_plane_op::greater_or_equal: value = 1; break; case rsx::user_clip_plane_op::less_than: value = -1; break; } __glcheck m_program->uniforms[location] = value; } __glcheck enable(value, GL_CLIP_DISTANCE0 + index); }; load_program(); set_clip_plane_control(0, rsx::method_registers.clip_plane_0_enabled()); set_clip_plane_control(1, rsx::method_registers.clip_plane_1_enabled()); set_clip_plane_control(2, rsx::method_registers.clip_plane_2_enabled()); set_clip_plane_control(3, rsx::method_registers.clip_plane_3_enabled()); set_clip_plane_control(4, rsx::method_registers.clip_plane_4_enabled()); set_clip_plane_control(5, rsx::method_registers.clip_plane_5_enabled()); if (__glcheck enable(rsx::method_registers.cull_face_enabled(), GL_CULL_FACE)) { __glcheck glCullFace(cull_face(rsx::method_registers.cull_face_mode())); } __glcheck glFrontFace(front_face(rsx::method_registers.front_face_mode())); __glcheck enable(rsx::method_registers.poly_smooth_enabled(), GL_POLYGON_SMOOTH); //NV4097_SET_COLOR_KEY_COLOR //NV4097_SET_SHADER_CONTROL //NV4097_SET_ZMIN_MAX_CONTROL //NV4097_SET_ANTI_ALIASING_CONTROL //NV4097_SET_CLIP_ID_TEST_ENABLE std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now(); m_begin_time += (u32)std::chrono::duration_cast<std::chrono::microseconds>(now - then).count(); m_draw_calls++; }
void luaV_execute (lua_State *L, int nexeccalls) { LClosure *cl; StkId base; TValue *k; const Instruction *pc; reentry: /* entry point */ lua_assert(isLua(L->ci)); pc = L->savedpc; cl = &clvalue(L->ci->func)->l; base = L->base; k = cl->p->k; /* main loop of interpreter */ for (;;) { const Instruction i = *pc++; StkId ra; if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { traceexec(L, pc); if (L->status == LUA_YIELD) { /* did hook yield? */ L->savedpc = pc - 1; return; } base = L->base; } /* warning!! several calls may realloc the stack and invalidate `ra' */ ra = RA(i); lua_assert(base == L->base && L->base == L->ci->base); lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); switch (GET_OPCODE(i)) { case OP_MOVE: { setobjs2s(L, ra, RB(i)); continue; } case OP_LOADK: { setobj2s(L, ra, KBx(i)); continue; } case OP_LOADBOOL: { setbvalue(ra, GETARG_B(i)); if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ continue; } case OP_LOADNIL: { TValue *rb = RB(i); do { setnilvalue(rb--); } while (rb >= ra); continue; } case OP_GETUPVAL: { int b = GETARG_B(i); setobj2s(L, ra, cl->upvals[b]->v); continue; } case OP_GETGLOBAL: { TValue g; TValue *rb = KBx(i); sethvalue(L, &g, cl->env); lua_assert(ttisstring(rb)); Protect(luaV_gettable(L, &g, rb, ra)); continue; } case OP_GETTABLE: { Protect(luaV_gettable(L, RB(i), RKC(i), ra)); continue; } case OP_SETGLOBAL: { TValue g; sethvalue(L, &g, cl->env); lua_assert(ttisstring(KBx(i))); Protect(luaV_settable(L, &g, KBx(i), ra)); continue; } case OP_SETUPVAL: { UpVal *uv = cl->upvals[GETARG_B(i)]; setobj(L, uv->v, ra); luaC_barrier(L, uv, ra); continue; } case OP_SETTABLE: { Protect(luaV_settable(L, ra, RKB(i), RKC(i))); continue; } case OP_NEWTABLE: { int b = GETARG_B(i); int c = GETARG_C(i); sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); Protect(luaC_checkGC(L)); continue; } case OP_SELF: { StkId rb = RB(i); setobjs2s(L, ra+1, rb); Protect(luaV_gettable(L, rb, RKC(i), ra)); continue; } case OP_ADD: { arith_op(luai_numadd, TM_ADD); continue; } case OP_SUB: { arith_op(luai_numsub, TM_SUB); continue; } case OP_MUL: { arith_op(luai_nummul, TM_MUL); continue; } case OP_DIV: { arith_op(luai_numdiv, TM_DIV); continue; } case OP_MOD: { arith_op(luai_nummod, TM_MOD); continue; } case OP_POW: { arith_op(luai_numpow, TM_POW); continue; } case OP_UNM: { TValue *rb = RB(i); if (ttisnumber(rb)) { lua_Number nb = nvalue(rb); setnvalue(ra, luai_numunm(nb)); } else { Protect(Arith(L, ra, rb, rb, TM_UNM)); } continue; } #if defined(LUA_BITWISE_OPERATORS) case OP_BOR: { logic_op(luai_logor, TM_BOR); continue; } case OP_BAND: { logic_op(luai_logand, TM_BAND); continue; } case OP_BXOR: { logic_op(luai_logxor, TM_BXOR); continue; } case OP_BLSHFT: { logic_op(luai_loglshft, TM_BLSHFT); continue; } case OP_BRSHFT: { logic_op(luai_logrshft, TM_BRSHFT); continue; } case OP_BNOT: { TValue *rb = RB(i); if (ttisnumber(rb)) { lua_Integer r; lua_Number nb = nvalue(rb); luai_lognot(r, nb); setnvalue(ra, r); } else { Protect(Logic(L, ra, rb, rb, TM_BNOT)); } continue; } case OP_INTDIV: { arith_op(luai_numintdiv, TM_DIV); continue; } #endif case OP_NOT: { int res = l_isfalse(RB(i)); /* next assignment may change this value */ setbvalue(ra, res); continue; } case OP_LEN: { const TValue *rb = RB(i); switch (ttype(rb)) { case LUA_TTABLE: { setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); break; } case LUA_TSTRING: { setnvalue(ra, cast_num(tsvalue(rb)->len)); break; } default: { /* try metamethod */ Protect( if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) luaG_typeerror(L, rb, "get length of"); ) } } continue; } case OP_CONCAT: { int b = GETARG_B(i); int c = GETARG_C(i); Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); setobjs2s(L, RA(i), base+b); continue; } case OP_JMP: { dojump(L, pc, GETARG_sBx(i)); continue; } case OP_EQ: { TValue *rb = RKB(i); TValue *rc = RKC(i); Protect( if (equalobj(L, rb, rc) == GETARG_A(i)) dojump(L, pc, GETARG_sBx(*pc)); ) pc++; continue; } case OP_LT: { Protect( if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) dojump(L, pc, GETARG_sBx(*pc)); ) pc++; continue; } case OP_LE: { Protect( if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) dojump(L, pc, GETARG_sBx(*pc)); ) pc++; continue; }
void LIR_Assembler::emit_op2(LIR_Op2* op) { switch (op->code()) { case lir_cmp: if (op->info() != NULL) { assert(op->in_opr1()->is_address() || op->in_opr2()->is_address(), "shouldn't be codeemitinfo for non-address operands"); add_debug_info_for_null_check_here(op->info()); // exception possible } comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op); break; case lir_cmp_l2i: case lir_cmp_fd2i: case lir_ucmp_fd2i: comp_fl2i(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op); break; case lir_cmove: cmove(op->condition(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->type()); break; case lir_shl: case lir_shr: case lir_ushr: if (op->in_opr2()->is_constant()) { shift_op(op->code(), op->in_opr1(), op->in_opr2()->as_constant_ptr()->as_jint(), op->result_opr()); } else { shift_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->tmp1_opr()); } break; case lir_add: case lir_sub: case lir_mul: case lir_mul_strictfp: case lir_div: case lir_div_strictfp: case lir_rem: assert(op->fpu_pop_count() < 2, ""); arith_op( op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->info(), op->fpu_pop_count() == 1); break; case lir_abs: case lir_sqrt: case lir_sin: case lir_tan: case lir_cos: case lir_log10: intrinsic_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op); break; case lir_logic_and: case lir_logic_or: case lir_logic_xor: logic_op( op->code(), op->in_opr1(), op->in_opr2(), op->result_opr()); break; case lir_throw: throw_op(op->in_opr1(), op->in_opr2(), op->info()); break; case lir_xadd: case lir_xchg: atomic_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->tmp1_opr()); break; default: Unimplemented(); break; } }
void LIR_Assembler::emit_op2(LIR_Op2* op) { switch (op->code()) { case lir_cmp: comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op); break; case lir_cmp_l2i: case lir_cmp_fd2i: case lir_ucmp_fd2i: comp_fl2i(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op); break; case lir_cmove: cmove(op->condition(),op->in_opr1(),op->in_opr2(),op->tmp_opr(),op->result_opr()); break; case lir_shl: case lir_shr: case lir_ushr: if (op->in_opr2()->is_constant()) { shift_op(op->code(), op->in_opr1(), op->in_opr2()->as_constant_ptr()->as_jint(), op->result_opr()); } else { shift_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->tmp_opr()); } break; case lir_add: case lir_sub: case lir_mul: case lir_mul_strictfp: case lir_div: case lir_div_strictfp: case lir_rem: arith_op( op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->info()); break; case lir_abs: case lir_sqrt: case lir_sin: case lir_tan: case lir_cos: case lir_log: case lir_log10: intrinsic_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op); break; case lir_logic_and: case lir_logic_or: case lir_logic_xor: logic_op( op->code(), op->in_opr1(), op->in_opr2(), op->result_opr()); break; case lir_throw: case lir_unwind: throw_op(op->in_opr2(),op->in_opr1(),op->info(),op->code()==lir_unwind); break; default: Unimplemented(); break; } }