mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 18:29:23 +00:00
Add Toggles to disable base vertex and base instance rendering
These are not supported on some older OpenGL, OpenGL ES, and iOS devices. Bug: dawn:343 Change-Id: I70def749ae57fcfe2895f8556674dd241941d3d3 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16163 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
2f0f850da8
commit
a9d7d47842
@@ -869,12 +869,23 @@ namespace dawn_native { namespace opengl {
|
||||
indexBufferBaseOffset),
|
||||
draw->instanceCount, draw->baseVertex, draw->firstInstance);
|
||||
} else {
|
||||
// This branch is only needed on OpenGL < 4.2
|
||||
gl.DrawElementsInstancedBaseVertex(
|
||||
lastPipeline->GetGLPrimitiveTopology(), draw->indexCount, formatType,
|
||||
reinterpret_cast<void*>(draw->firstIndex * formatSize +
|
||||
indexBufferBaseOffset),
|
||||
draw->instanceCount, draw->baseVertex);
|
||||
// This branch is only needed on OpenGL < 4.2; ES < 3.2
|
||||
if (draw->baseVertex != 0) {
|
||||
gl.DrawElementsInstancedBaseVertex(
|
||||
lastPipeline->GetGLPrimitiveTopology(), draw->indexCount,
|
||||
formatType,
|
||||
reinterpret_cast<void*>(draw->firstIndex * formatSize +
|
||||
indexBufferBaseOffset),
|
||||
draw->instanceCount, draw->baseVertex);
|
||||
} else {
|
||||
// This branch is only needed on OpenGL < 3.2; ES < 3.2
|
||||
gl.DrawElementsInstanced(
|
||||
lastPipeline->GetGLPrimitiveTopology(), draw->indexCount,
|
||||
formatType,
|
||||
reinterpret_cast<void*>(draw->firstIndex * formatSize +
|
||||
indexBufferBaseOffset),
|
||||
draw->instanceCount);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace dawn_native { namespace opengl {
|
||||
const DeviceDescriptor* descriptor,
|
||||
const OpenGLFunctions& functions)
|
||||
: DeviceBase(adapter, descriptor), gl(functions) {
|
||||
InitTogglesFromDriver();
|
||||
if (descriptor != nullptr) {
|
||||
ApplyToggleOverrides(descriptor);
|
||||
}
|
||||
@@ -46,6 +47,30 @@ namespace dawn_native { namespace opengl {
|
||||
BaseDestructor();
|
||||
}
|
||||
|
||||
void Device::InitTogglesFromDriver() {
|
||||
bool supportsBaseVertex = gl.IsAtLeastGLES(3, 2) || gl.IsAtLeastGL(3, 2);
|
||||
|
||||
bool supportsBaseInstance = gl.IsAtLeastGLES(3, 2) || gl.IsAtLeastGL(4, 2);
|
||||
|
||||
// TODO(crbug.com/dawn/343): We can support the extension variants, but need to load the EXT
|
||||
// procs without the extension suffix.
|
||||
// We'll also need emulation of shader builtins gl_BaseVertex and gl_BaseInstance.
|
||||
|
||||
// supportsBaseVertex |=
|
||||
// (gl.IsAtLeastGLES(2, 0) &&
|
||||
// (gl.IsGLExtensionSupported("OES_draw_elements_base_vertex") ||
|
||||
// gl.IsGLExtensionSupported("EXT_draw_elements_base_vertex"))) ||
|
||||
// (gl.IsAtLeastGL(3, 1) && gl.IsGLExtensionSupported("ARB_draw_elements_base_vertex"));
|
||||
|
||||
// supportsBaseInstance |=
|
||||
// (gl.IsAtLeastGLES(3, 1) && gl.IsGLExtensionSupported("EXT_base_instance")) ||
|
||||
// (gl.IsAtLeastGL(3, 1) && gl.IsGLExtensionSupported("ARB_base_instance"));
|
||||
|
||||
// TODO(crbug.com/dawn/343): Investigate emulation.
|
||||
SetToggle(Toggle::DisableBaseVertex, !supportsBaseVertex);
|
||||
SetToggle(Toggle::DisableBaseInstance, !supportsBaseInstance);
|
||||
}
|
||||
|
||||
const GLFormat& Device::GetGLFormat(const Format& format) {
|
||||
ASSERT(format.isSupported);
|
||||
ASSERT(format.GetIndex() < mFormatTable.size());
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace dawn_native { namespace opengl {
|
||||
TextureBase* texture,
|
||||
const TextureViewDescriptor* descriptor) override;
|
||||
|
||||
void InitTogglesFromDriver();
|
||||
void CheckPassedFences();
|
||||
void Destroy() override;
|
||||
MaybeError WaitForIdleForDestruction() override;
|
||||
|
||||
@@ -74,12 +74,12 @@ namespace dawn_native { namespace opengl {
|
||||
return mSupportedGLExtensionsSet.count(extension) != 0;
|
||||
}
|
||||
|
||||
bool OpenGLFunctions::IsAtLeastGL(uint32_t majorVersion, uint32_t minorVersion) {
|
||||
bool OpenGLFunctions::IsAtLeastGL(uint32_t majorVersion, uint32_t minorVersion) const {
|
||||
return mStandard == Standard::Desktop &&
|
||||
std::tie(mMajorVersion, mMinorVersion) >= std::tie(majorVersion, minorVersion);
|
||||
}
|
||||
|
||||
bool OpenGLFunctions::IsAtLeastGLES(uint32_t majorVersion, uint32_t minorVersion) {
|
||||
bool OpenGLFunctions::IsAtLeastGLES(uint32_t majorVersion, uint32_t minorVersion) const {
|
||||
return mStandard == Standard::ES &&
|
||||
std::tie(mMajorVersion, mMinorVersion) >= std::tie(majorVersion, minorVersion);
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace dawn_native { namespace opengl {
|
||||
public:
|
||||
MaybeError Initialize(GetProcAddress getProc);
|
||||
|
||||
bool IsAtLeastGL(uint32_t majorVersion, uint32_t minorVersion);
|
||||
bool IsAtLeastGLES(uint32_t majorVersion, uint32_t minorVersion);
|
||||
bool IsAtLeastGL(uint32_t majorVersion, uint32_t minorVersion) const;
|
||||
bool IsAtLeastGLES(uint32_t majorVersion, uint32_t minorVersion) const;
|
||||
|
||||
bool IsGLExtensionSupported(const char* extension) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user