示例#1
0
文件: main.c 项目: Lewis-Liu-1/os_diy
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;
}
示例#2
0
文件: main.c 项目: Lewis-Liu-1/os_diy
int
main(void)
{
   SVGA3DUtil_InitFullscreen(CID, 800, 600);
   SVGA3DText_Init();

   vertexSid = SVGA3DUtil_DefineStaticBuffer(vertexData, sizeof vertexData);
   indexSid = SVGA3DUtil_DefineStaticBuffer(indexData, sizeof indexData);

   SVGA3D_DefineShader(CID, MY_VSHADER_ID, SVGA3D_SHADERTYPE_VS,
                       g_vs20_MyVertexShader, sizeof g_vs20_MyVertexShader);
   SVGA3D_DefineShader(CID, MY_PSHADER_ID, SVGA3D_SHADERTYPE_PS,
                       g_ps20_MyPixelShader, sizeof g_ps20_MyPixelShader);

   Matrix_Perspective(perspectiveMat, 45.0f,
                      gSVGA.width / (float)gSVGA.height, 10.0f, 100.0f);

   while (1) {
      if (SVGA3DUtil_UpdateFPSCounter(&gFPS)) {
         Console_Clear();
         Console_Format("Half-precision floating point test.\n"
                        "You should see four identical cubes.\n"
                        "\n"
                        "Top row: Fixed function, Bottom row: Shaders.\n"
                        "Left column: 32-bit float, Right column: 16-bit float.\n"
                        "\n%s",
                        gFPS.text);
         SVGA3DText_Update();
         VMBackdoor_VGAScreenshot();
      }

      SVGA3DUtil_ClearFullscreen(CID, SVGA3D_CLEAR_COLOR | SVGA3D_CLEAR_DEPTH,
                                 0x113366, 1.0f, 0);

      renderCube(-2, 2, FALSE, FALSE);   /* Top-left */
      renderCube(2, 2, FALSE, TRUE);     /* Top-right */
      renderCube(-2, -2, TRUE, FALSE);   /* Bottom-left */
      renderCube(2, -2, TRUE, TRUE);     /* Bottom-right */

      SVGA3DText_Draw();
      SVGA3DUtil_PresentFullscreen();
   }

   return 0;
}
示例#3
0
void
task2_main(void)
{
   uint32 counter = 0;

   while (1) {
      counter++;

      /*
       * Disable interrupts while using the console, since it isn't re-entrant.
       */

      Intr_Disable();
      Console_Format("Task 2 (counter: %d)\n", counter);
      Console_Flush();
      Intr_Enable();
   }
}
示例#4
0
文件: main.c 项目: Lewis-Liu-1/os_diy
int
main(void)
{
   SVGA3DUtil_InitFullscreen(CID, 800, 600);
   SVGA3DText_Init();
   Keyboard_Init();
   APM_Init();

   vertexSid = SVGA3DUtil_DefineStaticBuffer(vertexData, sizeof vertexData);
   indexSid = SVGA3DUtil_DefineStaticBuffer(indexData, sizeof indexData);

   Matrix_Perspective(perspectiveMat, 45.0f,
                      gSVGA.width / (float)gSVGA.height, 0.1f, 100.0f);

   while (!Keyboard_IsKeyPressed(KEY_ESCAPE)) {

      if (SVGA3DUtil_UpdateFPSCounter(&gFPS)) {
         Console_Clear();
         Console_Format("VMware SVGA3D Example:\n"
                        "Spinning cube with static vertex and index buffer.\n"
                        "Drag with left mouse button to rotate.\n"
                        "Press ESC to exit.\n"
                        "\n%s",
                        gFPS.text);
         SVGA3DText_Update();
         VMBackdoor_VGAScreenshot();
      }

      while (VMBackdoor_MouseGetPacket(&lastMouseState));

      SVGA3DUtil_ClearFullscreen(CID, SVGA3D_CLEAR_COLOR | SVGA3D_CLEAR_DEPTH,
                                 0x113366, 1.0f, 0);
      render();
      SVGA3DText_Draw();
      SVGA3DUtil_PresentFullscreen();
   }

   APM_SetPowerState(POWER_OFF);
   return 0;
}
示例#5
0
文件: main.c 项目: Lewis-Liu-1/os_diy
int
main(void)
{
   SVGA3DUtil_InitFullscreen(CID, 800, 600);
   SVGA3DText_Init();

   vertexSid = SVGA3DUtil_DefineSurface2D(MESH_NUM_BYTES, 1, SVGA3D_BUFFER);
   indexSid = createIndexBuffer();

   SVGA3DUtil_AllocDMAPool(&vertexDMA, MESH_NUM_BYTES, 16);

   Matrix_Perspective(perspectiveMat, 45.0f,
                      gSVGA.width / (float)gSVGA.height, 0.1f, 100.0f);

   while (1) {
      if (SVGA3DUtil_UpdateFPSCounter(&gFPS)) {
         Console_Clear();
         Console_Format("VMware SVGA3D Example:\n"
                        "Dynamic vertex buffer stress-test.\n"
                        "This example performs a separate DMA and "
                        "Draw for each row of the mesh.\n\n%s",
                        gFPS.text);
         SVGA3DText_Update();
      }

      SVGA3DUtil_ClearFullscreen(CID, SVGA3D_CLEAR_COLOR | SVGA3D_CLEAR_DEPTH,
                                 0x113366, 1.0f, 0);

      setupFrame();
      render();

      SVGA3DText_Draw();
      SVGA3DUtil_PresentFullscreen();
   }

   return 0;
}
示例#6
0
文件: main.c 项目: Lewis-Liu-1/os_diy
static void
initScreens(void)
{
   static const SVGAScreenObject screen = {
      .structSize = sizeof(SVGAScreenObject),
      .id = 0,
      .flags = SVGA_SCREEN_HAS_ROOT | SVGA_SCREEN_IS_PRIMARY,
      .size = { 1024, 768 },
      .root = { 1000, 2000 },
   };

   Screen_Define(&screen);

   ScreenDraw_SetScreen(screen.id, screen.size.width, screen.size.height);
   Console_Clear();

   Console_Format("Surface-to-Screen Blit Clipping Test\n");
   ScreenDraw_Border(0, 0, screen.size.width, screen.size.height, 0xFF0000, 1);

   Console_MoveTo(20, 45);
   Console_Format("Stair-step clipping (small tiles)");

   Console_MoveTo(20, 245);
   Console_Format("Top/bottom halves swapped");

   Console_MoveTo(20, 445);
   Console_Format("Scaled bottom half, with hole");

   Console_MoveTo(350, 65);
   Console_Format("Zoomed to 1.5x full screen, two circular clip regions");

   Console_MoveTo(5, 660);
   Console_Format("Stair-step, clipped against screen edges");
}


/*
 * presentWithClipBuf --
 *
 *    Present our surface to the screen, with clipping data from a ClipBuffer.
 *
 *    The supplied ClipBuffer is always in screen coordinates. We
 *    convert them into dest-relative coordinates for the
 *    surface-to-screen blit.
 */

static void
presentWithClipBuf(ClipBuffer *buf, int dstL, int dstT, int dstR, int dstB)
{
   SVGASignedRect srcRect = { 0, 0, surfWidth, surfHeight };
   SVGASignedRect dstRect = { dstL, dstT, dstR, dstB };
   SVGASignedRect *clip;
   int i;

   SVGA3D_BeginBlitSurfaceToScreen(&colorImage, &srcRect, 0,
                                   &dstRect, &clip, buf->numRects);

   for (i = 0; i < buf->numRects; i++) {
      clip->left = buf->rects[i].left - dstL;
      clip->top = buf->rects[i].top - dstT;
      clip->right = buf->rects[i].right - dstL;
      clip->bottom = buf->rects[i].bottom - dstT;
      clip++;
   }

   SVGA_FIFOCommitAll();
}