소스 검색

GL: Added clip control support.

Branimir Karadžić 9 년 전
부모
커밋
c4fa56092b
5개의 변경된 파일35개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      include/bgfx/bgfx.h
  2. 2 0
      include/bgfx/c99/bgfx.h
  3. 4 0
      src/bgfx.cpp
  4. 11 0
      src/renderer_gl.cpp
  5. 16 0
      src/renderer_gl.h

+ 2 - 0
include/bgfx/bgfx.h

@@ -499,6 +499,8 @@ namespace bgfx
 		uint8_t  numGPUs;          //!< Number of enumerated GPUs.
 		uint16_t vendorId;         //!< Selected GPU vendor id.
 		uint16_t deviceId;         //!< Selected GPU device id.
+		bool     homogeneousDepth; //!< True when NDC depth is in [-1, 1] range.
+		bool     originBottomLeft; //!< True when NDC origin is at bottom left.
 
 		/// GPU info.
 		///

+ 2 - 0
include/bgfx/c99/bgfx.h

@@ -393,6 +393,8 @@ typedef struct bgfx_caps
     uint16_t maxViews;
     uint8_t  maxFBAttachments;
     uint8_t  numGPUs;
+    bool     homogeneousDepth;
+    bool     originBottomLeft;
 
     uint16_t vendorId;
     uint16_t deviceId;

+ 4 - 0
src/bgfx.cpp

@@ -1151,6 +1151,10 @@ namespace bgfx
 		}
 
 		BX_TRACE("Max FB attachments: %d", g_caps.maxFBAttachments);
+		BX_TRACE("NDC depth [%d, 1], origin %s left."
+			, g_caps.homogeneousDepth ? -1 : 0
+			, g_caps.originBottomLeft ? "bottom" : "top"
+			);
 	}
 
 	TextureFormat::Enum getViableTextureFormat(const ImageContainer& _imageContainer)

+ 11 - 0
src/renderer_gl.cpp

@@ -1818,6 +1818,17 @@ namespace bgfx { namespace gl
 						);
 			}
 
+			if (s_extension[Extension::ARB_clip_control].m_supported)
+			{
+				GL_CHECK(glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE) );
+				g_caps.originBottomLeft = true;
+			}
+			else
+			{
+				g_caps.homogeneousDepth = true;
+				g_caps.originBottomLeft = true;
+			}
+
 			m_vaoSupport = !!(BGFX_CONFIG_RENDERER_OPENGLES >= 30)
 				|| s_extension[Extension::ARB_vertex_array_object].m_supported
 				|| s_extension[Extension::OES_vertex_array_object].m_supported

+ 16 - 0
src/renderer_gl.h

@@ -791,6 +791,22 @@ typedef uint64_t GLuint64;
 #	define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346
 #endif // GL_CONSERVATIVE_RASTERIZATION_NV
 
+#ifndef GL_NEGATIVE_ONE_TO_ONE
+#	define GL_NEGATIVE_ONE_TO_ONE 0x935E
+#endif // GL_NEGATIVE_ONE_TO_ONE
+
+#ifndef GL_ZERO_TO_ONE
+#	define GL_ZERO_TO_ONE 0x935F
+#endif // GL_ZERO_TO_ONE
+
+#ifndef GL_LOWER_LEFT
+#	define GL_LOWER_LEFT 0x8CA1
+#endif // GL_LOWER_LEFT
+
+#ifndef GL_UPPER_LEFT
+#	define GL_UPPER_LEFT 0x8CA2
+#endif // GL_UPPER_LEFT
+
 // _KHR or _ARB...
 #define GL_DEBUG_OUTPUT_SYNCHRONOUS         0x8242
 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243