Beispiel #1
0
int
main(void)
{
   Intr_Init();
   Intr_SetFaultHandlers(SVGA_DefaultFaultHandler);
   SVGA_Init();
   GMR_Init();
   Heap_Reset();
   SVGA_SetMode(0, 0, 32);
   Screen_Init();

   SVGAScreenObject myScreen = {
      .structSize = sizeof(SVGAScreenObject),
      .id = 0,
      .flags = SVGA_SCREEN_HAS_ROOT | SVGA_SCREEN_IS_PRIMARY,
      .size = { 1600, 1200 },
      .root = { -1234, 5678 },
   };
   Screen_Define(&myScreen);

   const uint32 gmrId = 0;
   uint32 numPages = 1 + (myScreen.size.width * myScreen.size.height *
                          sizeof(uint32)) / PAGE_SIZE;

   PPN pages = GMR_DefineEvenPages(gmrId, numPages);

   const uint32 bitsPerPixel = 32;
   const uint32 colorDepth = 24;
   const uint32 bytesPerLine = myScreen.size.width * sizeof(uint32);

   const SVGAGMRImageFormat format = {{{
      .bitsPerPixel = bitsPerPixel,
      .colorDepth = colorDepth,
   }}};
Beispiel #2
0
void
SVGA3DUtil_InitFullscreen(uint32 cid,     // IN
                          uint32 width,   // IN
                          uint32 height)  // IN
{
   SVGA3dRenderState *rs;

   gFullscreen.screen.x = 0;
   gFullscreen.screen.y = 0;
   gFullscreen.screen.w = width;
   gFullscreen.screen.h = height;

   Intr_Init();
   Intr_SetFaultHandlers(SVGA_DefaultFaultHandler);

   SVGA_Init();
   SVGA_SetMode(width, height, 32);
   VMBackdoor_MouseInit(TRUE);
   SVGA3D_Init();

   gFullscreen.colorImage.sid = SVGA3DUtil_DefineSurface2D(width, height,
                                                           SVGA3D_X8R8G8B8);

   gFullscreen.depthImage.sid = SVGA3DUtil_DefineSurface2D(width, height,
                                                           SVGA3D_Z_D16);

   SVGA3D_DefineContext(cid);

   SVGA3D_SetRenderTarget(cid, SVGA3D_RT_COLOR0, &gFullscreen.colorImage);
   SVGA3D_SetRenderTarget(cid, SVGA3D_RT_DEPTH, &gFullscreen.depthImage);

   SVGA3D_SetViewport(cid, &gFullscreen.screen);
   SVGA3D_SetZRange(cid, 0.0f, 1.0f);

   /*
    * The device defaults to flat shading, but to retain compatibility
    * across OpenGL and Direct3D it may be much slower in this
    * mode. Usually we don't want flat shading, so go ahead and switch
    * into smooth shading mode.
    *
    * Note that this is a per-context render state.
    *
    * XXX: There is also a bug in VMware Workstation 6.5.2 which shows
    *      up if you're in flat shading mode and you're using a drawing
    *      command which does not include an SVGA3dVertexDivisor array.
    *      Avoiding flat shading is one workaround, another is to include
    *      a dummy SVGA3dVertexDivisor array on every draw.
    */

   SVGA3D_BeginSetRenderState(cid, &rs, 1);
   {
      rs[0].state     = SVGA3D_RS_SHADEMODE;
      rs[0].uintValue = SVGA3D_SHADEMODE_SMOOTH;
   }
   SVGA_FIFOCommitAll();
}
Beispiel #3
0
APTR SVGA_SetDisplayMode(VgaGfxBase *VgaGfxBase, UINT32 nWidth, UINT32 nHeight, UINT32 nBpp)
{
	SVGA_FifoStop(VgaGfxBase);
	SVGA_SetMode(VgaGfxBase, nWidth, nHeight, nBpp);
	SVGA_FifoInit(VgaGfxBase);

	memset(VgaGfxBase->fbDma, 0, nHeight * VgaGfxBase->bytesPerRow);
//	FifoUpdateFullscreen();
	SVGA_FifoStart(VgaGfxBase);
	return VgaGfxBase->fbDma;
}
Beispiel #4
0
int
main(void)
{
   static VMTCLOState tclo;
   Bool resendCapabilities = FALSE;

   Intr_Init();
   Intr_SetFaultHandlers(SVGA_DefaultFaultHandler);
   SVGA_Init();
   SVGA_SetMode(640, 480, 32);

   /* Use the PIT to set TCLO polling rate. */
   Timer_InitPIT(PIT_HZ / 30);
   Intr_SetMask(0, TRUE);

   sendCapabilities();

   while (1) {
      Intr_Halt();

      if (!VMBackdoor_PollTCLO(&tclo, FALSE)) {

         if (resendCapabilities) {
            resendCapabilities = FALSE;
            sendCapabilities();
         }
         continue;
      }

      if (VMBackdoor_CheckPrefixTCLO(&tclo, "Capabilities_Register")) {
         /* Send the capabilities after we get a chance to send the reply. */
         resendCapabilities = TRUE;
         VMBackdoor_ReplyTCLO(&tclo, TCLO_SUCCESS);

      } else if (VMBackdoor_CheckPrefixTCLO(&tclo, "Resolution_Set")) {
         int width = VMBackdoor_IntParamTCLO(&tclo, 1);
         int height = VMBackdoor_IntParamTCLO(&tclo, 2);

         resize(width, height);

         VMBackdoor_ReplyTCLO(&tclo, TCLO_SUCCESS);

      } else {
         /* Unknown command */
         VMBackdoor_ReplyTCLO(&tclo, TCLO_UNKNOWN_CMD);
      }
   }

   return 0;
}
Beispiel #5
0
int
main(void)
{
   static FPSCounterState fps;
   uint32 frameFence = 0;
   uint32 nextFence;

   Intr_Init();
   Intr_SetFaultHandlers(SVGA_DefaultFaultHandler);
   SVGA_Init();
   GMR_Init();
   Heap_Reset();
   SVGA_SetMode(0, 0, 32);
   SVGA3D_Init();
   Screen_Init();
   ScreenDraw_Init(0);

   initScreens();
   setup3D();

   /*
    * One big circle, and a smaller one that overlaps the top-right
    * corner.  (This tests positive and negative clipping extremes.)
    */
   prepareCircle(&circles[0], 650, 400, 300);
   prepareCircle(&circles[1], 1000, 50, 250);

   while (1) {
      if (SVGA3DUtil_UpdateFPSCounter(&fps)) {
         Console_MoveTo(900, 730);
         Console_Format("%s    ", fps.text);
      }

      drawCube();

      /*
       * Flow control- one frame in the FIFO at a time.
       */
      nextFence = SVGA_InsertFence();
      SVGA_SyncToFence(frameFence);
      frameFence = nextFence;

      present();
   }

   return 0;
}
Beispiel #6
0
void
resize(int width, int height)
{
   /*
    * To make it obvious that we're switching modes, alternate colors
    * each time.
    */
   static uint32 color = 0x888888;

   color ^= 0x004000;

   SVGA_SyncToFence(SVGA_InsertFence());

   SVGA_SetMode(width, height, 32);
   memset32(gSVGA.fbMem, color, width * height);
   SVGA_Update(0, 0, width, height);
}
Beispiel #7
0
////////////////////////////////////////////////////////////////////////////////
// Includes
////////////////////////////////////////////////////////////////////////////////
int vga_vmware_set_mode(vga_handle_t *dev, int width, int height, int bpp)
{
	SVGA_SetMode((vgavmware_handle_t *)dev, width, height, bpp);
	return 1;
}
Beispiel #8
0
int
main(void)
{
   uint32 frame = 0;
   uint32 lastTick = 0;

   Intr_Init();
   Intr_SetFaultHandlers(SVGA_DefaultFaultHandler);

   Timer_InitPIT(PIT_HZ / FRAME_RATE);
   Intr_SetMask(PIT_IRQ, TRUE);
   Intr_SetHandler(IRQ_VECTOR(PIT_IRQ), timerISR);

   SVGA_Init();
   GMR_Init();
   Heap_Reset();
   SVGA_SetMode(0, 0, 32);
   Screen_Init();
   ScreenDraw_Init(GMRID_SCREEN_DRAW);

   allocNoise();

   /*
    * Define a screen.
     */

   SVGAScreenObject myScreen = {
      .structSize = sizeof(SVGAScreenObject),
      .id = SCREEN_ID,
      .flags = SVGA_SCREEN_HAS_ROOT | SVGA_SCREEN_IS_PRIMARY,
      .size = { 800, 600 },
      .root = { 0, 0 },
   };
   Screen_Define(&myScreen);

   /*
    * Draw some explanatory text.
    */

   char docString[] =
      "Annotated Blit Sample:"
      "\n\n"
      "You should see two moving rectangles. The left one is animated "
      "using a fill-annotated blit. The blit itself contains random "
      "noise, but the annotation is a blue fill. If your host is "
      "using the annotation, you will see the blue. If not, you'll "
      "see noise. Either one is correct, but it is often more efficient "
      "to use the fill."
      "\n\n"
      "The right one is a copy-annotated blit. The blit data is again "
      "random noise, and the copy is a screen-to-screen copy which "
      "moves the rectangle from its old position to the new position. "
      "We drew a checkerboard pattern to the screen once, and that "
      "pattern should be preserved indefinitely if the annotation is "
      "being executed correctly."
      "\n\n"
      "Both rectangles should have a 1-pixel solid white border, and "
      "in both cases we use a fill-annotated blit to clear the screen "
      "behind each rectangle. This annotation doesn't lie, its blit data "
      "matches the advertised fill color.";

   ScreenDraw_SetScreen(myScreen.id, myScreen.size.width, myScreen.size.height);
   Console_Clear();
   ScreenDraw_WrapText(docString, 770);
   Console_WriteString(docString);

   /*
    * Animate the two rectangles indefinitely, sleeping between frames.
    */

   while (1) {
      SVGASignedRect oldRect1, oldRect2;
      SVGASignedRect newRect1, newRect2;

      /*
       * Move them around in a circle.
       */

      float theta = frame * 0.01;

      newRect1.left = 190 + cosf(theta) * 60;
      newRect1.top = 350 + sinf(theta) * 60;
      newRect1.right = newRect1.left + 80;
      newRect1.bottom = newRect1.top + 120;

      newRect2.left = 530 + sinf(theta) * 60;
      newRect2.top = 350 + cosf(theta) * 60;
      newRect2.right = newRect2.left + 80;
      newRect2.bottom = newRect2.top + 120;

      /*
       * Update the position of each.
       */

      updateFillRect(frame ? &oldRect1 : NULL, &newRect1);
      updateCopyRect(frame ? &oldRect2 : NULL, &newRect2);

      oldRect1 = newRect1;
      oldRect2 = newRect2;

      /*
       * Wait for the next timer tick.
       */

      while (timerTick == lastTick) {
         Intr_Halt();
      }
      lastTick = timerTick;
      frame++;
   }

   return 0;
}