Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
5.2 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: subbatch.h
  3. *
  4. * OpenGL batching macros.
  5. *
  6. * Copyright (c) 1993 Microsoft Corporation
  7. \**************************************************************************/
  8. #ifndef __SUBBATCH_H__
  9. #define __SUBBATCH_H__
  10. #ifdef DOGLMSGBATCHSTATS
  11. #define STATS_INC_CLIENTCALLS() (pMsgBatchInfo->BatchStats.ClientCalls++)
  12. #else
  13. #define STATS_INC_CLIENTCALLS()
  14. #endif
  15. // Put a message into shared area. If it does not fit, flush what is
  16. // currently in the buffer and then put the message at start of the buffer
  17. //
  18. // NOTE: glsbAttentionAlt() updates pMsgBatchInfo->NextOffset on return.
  19. // If you modify this macro, you have to fix the glsbAttentionAlt()
  20. // function!
  21. #define GLCLIENT_BEGIN(ProcName,MsgStruct) \
  22. { \
  23. GLMSGBATCHINFO *pMsgBatchInfo; \
  24. GLMSG_##MsgStruct *pMsg; \
  25. ULONG CurrentOffset; \
  26. \
  27. /* Get shared memory window from the TEB */ \
  28. pMsgBatchInfo = GLTEB_SHAREDMEMORYSECTION(); \
  29. STATS_INC_CLIENTCALLS(); \
  30. \
  31. /* Get and update the offset of the next message */ \
  32. CurrentOffset = pMsgBatchInfo->NextOffset; \
  33. pMsgBatchInfo->NextOffset += GLMSG_ALIGN(sizeof(GLMSG_##MsgStruct)); \
  34. \
  35. /* Flush message if shared memory window is full */ \
  36. if (pMsgBatchInfo->NextOffset > pMsgBatchInfo->MaximumOffset) \
  37. CurrentOffset = glsbAttentionAlt(CurrentOffset); \
  38. \
  39. /* Add message to the batch */ \
  40. pMsg = (GLMSG_##MsgStruct *)(((BYTE *)pMsgBatchInfo) + CurrentOffset); \
  41. pMsg->ProcOffset = offsetof(GLSRVSBPROCTABLE, glsrv##ProcName);
  42. #define GLCLIENT_END }
  43. // Large Messages have a variable amount of data associated with them.
  44. // Unlike the non-clientside version, however, we will not attempt to
  45. // copy the message into the buffer. Instead, we will pass the pointer
  46. // and flush. Unlike CSR, we will not have to copy data in/out of a
  47. // shared memory section to do this.
  48. #define GLCLIENT_BEGIN_LARGE(bSet,ProcName,MsgStruct,pData,Size,OffData) \
  49. { \
  50. GLMSGBATCHINFO *pMsgBatchInfo; \
  51. GLMSG_##MsgStruct *pMsg; \
  52. ULONG CurrentOffset; \
  53. \
  54. /* Get shared memory window from the TEB */ \
  55. pMsgBatchInfo = GLTEB_SHAREDMEMORYSECTION(); \
  56. STATS_INC_CLIENTCALLS(); \
  57. \
  58. /* Get and update the offset of the next message */ \
  59. CurrentOffset = pMsgBatchInfo->NextOffset; \
  60. pMsgBatchInfo->NextOffset += GLMSG_ALIGN(sizeof(GLMSG_##MsgStruct)); \
  61. \
  62. /* Flush message if shared memory window is full */ \
  63. if (pMsgBatchInfo->NextOffset > pMsgBatchInfo->MaximumOffset) \
  64. CurrentOffset = glsbAttentionAlt(CurrentOffset); \
  65. \
  66. /* Set up message header */ \
  67. pMsg = (GLMSG_##MsgStruct *)(((BYTE *)pMsgBatchInfo) + CurrentOffset); \
  68. pMsg->ProcOffset = offsetof(GLSRVSBPROCTABLE, glsrv##ProcName); \
  69. pMsg->##OffData = (ULONG_PTR) pData; \
  70. \
  71. DBGLEVEL2(LEVEL_INFO, "GLCLIENT_BEGIN_LARGE %s pdata 0x%x\n", \
  72. #ProcName, pData);
  73. #define GLCLIENT_END_LARGE_SET \
  74. glsbAttention(); \
  75. }
  76. #define GLCLIENT_END_LARGE_GET \
  77. glsbAttention(); \
  78. }
  79. #define GLCLIENT_BEGIN_LARGE_SET(ProcName,MsgStruct,pData,Size,OffData) \
  80. GLCLIENT_BEGIN_LARGE(TRUE,ProcName,MsgStruct,pData,Size,OffData)
  81. #define GLCLIENT_BEGIN_LARGE_GET(ProcName,MsgStruct,pData,Size,OffData) \
  82. GLCLIENT_BEGIN_LARGE(FALSE,ProcName,MsgStruct,pData,Size,OffData)
  83. #define GLMSG_MEMCPY(dest,src,size) memcpy(dest,src,size)
  84. #endif /* !__SUBBATCH_H__ */