Branimir Karadžić 10 anos atrás
pai
commit
202bfbd174
6 arquivos alterados com 27 adições e 18 exclusões
  1. 10 4
      include/bgfx/bgfxdefines.h
  2. 1 0
      src/bgfx.cpp
  3. 7 5
      src/bgfx_p.h
  4. 3 3
      src/renderer_d3d11.cpp
  5. 3 3
      src/renderer_d3d9.cpp
  6. 3 3
      src/renderer_gl.cpp

+ 10 - 4
include/bgfx/bgfxdefines.h

@@ -353,6 +353,9 @@
 #define BGFX_RESET_SRGB_BACKBUFFER       UINT32_C(0x00008000) //!< Enable sRGB backbuffer.
 #define BGFX_RESET_HIDPI                 UINT32_C(0x00010000) //!< Enable HiDPI rendering.
 
+#define BGFX_RESET_RESERVED_SHIFT        31                   //!< Internal bits shift.
+#define BGFX_RESET_RESERVED_MASK         UINT32_C(0x80000000) //!< Internal bits mask.
+
 ///
 #define BGFX_CAPS_TEXTURE_COMPARE_LEQUAL UINT64_C(0x0000000000000001) //!< Texture compare less equal mode is supported.
 #define BGFX_CAPS_TEXTURE_COMPARE_ALL    UINT64_C(0x0000000000000003) //!< All texture compare modes are supported.
@@ -396,10 +399,13 @@
 #define BGFX_VIEW_STEREO UINT8_C(0x01) //!< View will be rendered in stereo mode.
 
 ///
-#define BGFX_SUBMIT_EYE_LEFT  UINT8_C(0x01) //!< Submit to left eye.
-#define BGFX_SUBMIT_EYE_RIGHT UINT8_C(0x02) //!< Submit to right eye.
-#define BGFX_SUBMIT_EYE_MASK  UINT8_C(0x03) //!<
-#define BGFX_SUBMIT_EYE_FIRST BGFX_SUBMIT_EYE_LEFT
+#define BGFX_SUBMIT_EYE_LEFT       UINT8_C(0x01) //!< Submit to left eye.
+#define BGFX_SUBMIT_EYE_RIGHT      UINT8_C(0x02) //!< Submit to right eye.
+#define BGFX_SUBMIT_EYE_MASK       UINT8_C(0x03) //!<
+#define BGFX_SUBMIT_EYE_FIRST      BGFX_SUBMIT_EYE_LEFT
+
+#define BGFX_SUBMIT_RESERVED_SHIFT 7             //!< Internal bits shift.
+#define BGFX_SUBMIT_RESERVED_MASK  UINT8_C(0x80) //!< Internal bits mask.
 
 ///
 #define BGFX_PCI_ID_NONE                UINT16_C(0x0000) //!< Autoselect adapter.

+ 1 - 0
src/bgfx.cpp

@@ -2365,6 +2365,7 @@ again:
 	void reset(uint32_t _width, uint32_t _height, uint32_t _flags)
 	{
 		BGFX_CHECK_MAIN_THREAD();
+		BX_CHECK(0 == (_flags&BGFX_RESET_RESERVED_MASK), "Do not set reset reserved flags!");
 		s_ctx->reset(_width, _height, _flags);
 	}
 

+ 7 - 5
src/bgfx_p.h

@@ -173,12 +173,14 @@ namespace stl
 
 #define BGFX_MAX_COMPUTE_BINDINGS 8
 
-#define BGFX_TEXTURE_INTERNAL_DEFAULT_SAMPLER UINT32_C(0x10000000)
+#define BGFX_TEXTURE_INTERNAL_DEFAULT_SAMPLER  UINT32_C(0x10000000)
 
-#define BGFX_RESET_INTERNAL_FORCE     UINT32_C(0x80000000)
+#define BGFX_RESET_INTERNAL_FORCE              UINT32_C(0x80000000)
 
-#define BGFX_STATE_INTERNAL_SCISSOR         UINT64_C(0x2000000000000000)
-#define BGFX_STATE_INTERNAL_OCCLUSION_QUERY UINT64_C(0x4000000000000000)
+#define BGFX_STATE_INTERNAL_SCISSOR            UINT64_C(0x2000000000000000)
+#define BGFX_STATE_INTERNAL_OCCLUSION_QUERY    UINT64_C(0x4000000000000000)
+
+#define BGFX_SUBMIT_INTERNAL_OCCLUSION_VISIBLE UINT8_C(0x80)
 
 #define BGFX_RENDERER_DIRECT3D9_NAME  "Direct3D 9"
 #define BGFX_RENDERER_DIRECT3D11_NAME "Direct3D 11"
@@ -1374,7 +1376,7 @@ namespace bgfx
 		void setCondition(OcclusionQueryHandle _handle, bool _visible)
 		{
 			m_draw.m_occlusionQuery = _handle;
-			BX_UNUSED(_visible);
+			m_draw.m_submitFlags   |= _visible ? BGFX_SUBMIT_INTERNAL_OCCLUSION_VISIBLE : 0;
 		}
 
 		void setStencil(uint32_t _fstencil, uint32_t _bstencil)

+ 3 - 3
src/renderer_d3d11.cpp

@@ -2729,10 +2729,10 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 			return sampler;
 		}
 
-		bool isVisible(OcclusionQueryHandle _handle)
+		bool isVisible(OcclusionQueryHandle _handle, bool _visible)
 		{
 			m_occlusionQuery.resolve();
-			return m_occlusion[_handle.idx];
+			return _visible == m_occlusion[_handle.idx];
 		}
 
 		DXGI_FORMAT getBufferFormat()
@@ -5053,7 +5053,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 				const bool hasOcclusionQuery = 0 != (draw.m_stateFlags & BGFX_STATE_INTERNAL_OCCLUSION_QUERY);
 				if (isValid(draw.m_occlusionQuery)
 				&&  !hasOcclusionQuery
-				&&  !isVisible(draw.m_occlusionQuery) )
+				&&  !isVisible(draw.m_occlusionQuery, 0 != (draw.m_submitFlags&BGFX_SUBMIT_INTERNAL_OCCLUSION_VISIBLE) ) )
 				{
 					continue;
 				}

+ 3 - 3
src/renderer_d3d9.cpp

@@ -1565,10 +1565,10 @@ namespace bgfx { namespace d3d9
 			}
 		}
 
-		bool isVisible(OcclusionQueryHandle _handle)
+		bool isVisible(OcclusionQueryHandle _handle, bool _visible)
 		{
 			m_occlusionQuery.resolve();
-			return m_occlusion[_handle.idx];
+			return _visible == m_occlusion[_handle.idx];
 		}
 
 		void capturePreReset()
@@ -3539,7 +3539,7 @@ namespace bgfx { namespace d3d9
 				const bool hasOcclusionQuery = 0 != (draw.m_stateFlags & BGFX_STATE_INTERNAL_OCCLUSION_QUERY);
 				if (isValid(draw.m_occlusionQuery)
 				&&  !hasOcclusionQuery
-				&&  !isVisible(draw.m_occlusionQuery) )
+				&&  !isVisible(draw.m_occlusionQuery, 0 != (draw.m_submitFlags&BGFX_SUBMIT_INTERNAL_OCCLUSION_VISIBLE) ) )
 				{
 					continue;
 				}

+ 3 - 3
src/renderer_gl.cpp

@@ -2712,10 +2712,10 @@ namespace bgfx { namespace gl
 			}
 		}
 
-		bool isVisible(OcclusionQueryHandle _handle)
+		bool isVisible(OcclusionQueryHandle _handle, bool _visible)
 		{
 			m_occlusionQuery.resolve();
-			return m_occlusion[_handle.idx];
+			return _visible == m_occlusion[_handle.idx];
 		}
 
 		void ovrPostReset()
@@ -5605,7 +5605,7 @@ namespace bgfx { namespace gl
 				const bool hasOcclusionQuery = 0 != (draw.m_stateFlags & BGFX_STATE_INTERNAL_OCCLUSION_QUERY);
 				if (isValid(draw.m_occlusionQuery)
 				&&  !hasOcclusionQuery
-				&&  !isVisible(draw.m_occlusionQuery) )
+				&&  !isVisible(draw.m_occlusionQuery, 0 != (draw.m_submitFlags&BGFX_SUBMIT_INTERNAL_OCCLUSION_VISIBLE) ) )
 				{
 					continue;
 				}