common.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* SCE CONFIDENTIAL
  2. * $PSLibId$
  3. * Copyright (C) 2011 Sony Computer Entertainment Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef _SCE_API_LIBGXM_COMMON_H
  7. #define _SCE_API_LIBGXM_COMMON_H
  8. #include <gxm.h>
  9. #include <kernel.h>
  10. #include "heap.h"
  11. // Heap types
  12. enum HeapType {
  13. HEAP_TYPE_LPDDR_R,
  14. HEAP_TYPE_LPDDR_RW,
  15. HEAP_TYPE_CDRAM_RW,
  16. HEAP_TYPE_VERTEX_USSE,
  17. HEAP_TYPE_FRAGMENT_USSE
  18. };
  19. // Heap sizes
  20. #define HEAP_SIZE_LPDDR_R (64*1024*1024)
  21. #define HEAP_SIZE_LPDDR_RW (32*1024*1024)
  22. #define HEAP_SIZE_CDRAM_RW (32*1024*1024)
  23. #define HEAP_SIZE_VERTEX_USSE (8*1024*1024)
  24. #define HEAP_SIZE_FRAGMENT_USSE (8*1024*1024)
  25. // Display dimensions
  26. #define DISPLAY_WIDTH 960
  27. #define DISPLAY_HEIGHT 544
  28. #define DISPLAY_STRIDE_IN_PIXELS 1024
  29. #define DISPLAY_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8
  30. #define DISPLAY_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8
  31. #define DISPLAY_DBGFONT_FORMAT SCE_DBGFONT_PIXELFORMAT_A8B8G8R8
  32. #define DISPLAY_BUFFER_COUNT 3
  33. #define DISPLAY_MAX_PENDING_SWAPS 2
  34. // Supported flip modes
  35. enum FlipMode {
  36. FLIP_MODE_HSYNC, ///< Flip on next HSYNC
  37. FLIP_MODE_VSYNC, ///< Flip on next VSYNC
  38. FLIP_MODE_VSYNC_2 ///< Flip on next VSYNC, display for 2 VSYNCs minimum
  39. };
  40. // Graphics parameters
  41. #define MSAA_MODE SCE_GXM_MULTISAMPLE_NONE
  42. // Debug Font.
  43. // You cannot use the debugger of Visual Studio when .self link the libSceDbgFont.a
  44. //#define DISABLE_DEBUG_FONT
  45. // Mark variable as used
  46. #define UNUSED(a) (void)(a)
  47. // Align value
  48. #define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
  49. // Get maximum value
  50. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  51. // libgxm context
  52. extern SceGxmContext *g_context;
  53. // libgxm shader patcher
  54. extern SceGxmShaderPatcher *g_shaderPatcher;
  55. // libgxm display queue
  56. extern void *g_displayBufferData[DISPLAY_BUFFER_COUNT];
  57. extern SceUID g_displayBufferUid[DISPLAY_BUFFER_COUNT];
  58. extern SceGxmColorSurface g_displaySurface[DISPLAY_BUFFER_COUNT];
  59. extern SceGxmSyncObject *g_displayBufferSync[DISPLAY_BUFFER_COUNT];
  60. extern uint32_t g_displayFrontBufferIndex;
  61. extern uint32_t g_displayBackBufferIndex;
  62. // Depth buffer for display surface
  63. extern void *g_mainDepthBufferData;
  64. extern SceUID g_mainDepthBufferUid;
  65. extern SceGxmDepthStencilSurface g_mainDepthSurface;
  66. // libgxm main render target
  67. extern SceGxmRenderTarget *g_mainRenderTarget;
  68. // Expected to be provided by sample
  69. int renderDbgFont(void);
  70. // Initialize libdbgfont
  71. int initDbgFont(void);
  72. // Terminate libdbgfont
  73. int termDbgFont(void);
  74. // Initialize libgxm
  75. int initGxm(void);
  76. // Terminate libgxm
  77. int termGxm(void);
  78. // Cycles display buffers in the display queue
  79. int cycleDisplayBuffers(
  80. FlipMode flipMode = FLIP_MODE_VSYNC,
  81. uint32_t width = DISPLAY_WIDTH,
  82. uint32_t height = DISPLAY_HEIGHT,
  83. uint32_t strideInPixels = DISPLAY_STRIDE_IN_PIXELS);
  84. // Helper function to create a render target
  85. SceGxmRenderTarget *createRenderTarget(uint32_t width, uint32_t height, SceGxmMultisampleMode msaaMode);
  86. // Helper function to destroy a render target
  87. void destroyRenderTarget(SceGxmRenderTarget *renderTarget);
  88. #endif /* _SCE_API_LIBGXM_COMMON_H */