mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Fix] (MG_Impl/GLImpl): fix indexed shader storage buffer queries [skip ci]
This commit is contained in:
@@ -1285,7 +1285,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
|
|
||||||
point.Bind(bufferObject);
|
point.Bind(bufferObject);
|
||||||
if (bufferObject) {
|
if (bufferObject) {
|
||||||
point.SetRange(Range1D(0, bufferObject->GetSize()));
|
point.SetRange(Range1D(0, bufferObject->GetSize()), false);
|
||||||
MGLOG_D("%s: set range (0, %d)", __func__, bufferObject->GetSize());
|
MGLOG_D("%s: set range (0, %d)", __func__, bufferObject->GetSize());
|
||||||
} else {
|
} else {
|
||||||
point.ClearRange();
|
point.ClearRange();
|
||||||
|
|||||||
@@ -143,6 +143,16 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
return queryKind == IndexedBufferQueryKind::Start || queryKind == IndexedBufferQueryKind::Size;
|
return queryKind == IndexedBufferQueryKind::Start || queryKind == IndexedBufferQueryKind::Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SizeT GetIndexedBufferQueryPointCount(BufferTarget bufferTarget) {
|
||||||
|
const SizeT frontendCount = MG_State::pGLContext->GetBufferBindingPointCount(bufferTarget);
|
||||||
|
if (bufferTarget == BufferTarget::ShaderStorage && MG_Backend::pActiveBackendObject) {
|
||||||
|
const Int backendCount =
|
||||||
|
MG_Backend::pActiveBackendObject->GetDynamicParameters().MaxShaderStorageBufferBindings;
|
||||||
|
return std::min(frontendCount, static_cast<SizeT>(std::max(backendCount, 0)));
|
||||||
|
}
|
||||||
|
return frontendCount;
|
||||||
|
}
|
||||||
|
|
||||||
bool TryDecodeDrawBufferQuery(GLenum pname, SizeT& drawBufferIndex) {
|
bool TryDecodeDrawBufferQuery(GLenum pname, SizeT& drawBufferIndex) {
|
||||||
if (pname == GL_DRAW_BUFFER) {
|
if (pname == GL_DRAW_BUFFER) {
|
||||||
drawBufferIndex = 0;
|
drawBufferIndex = 0;
|
||||||
@@ -223,7 +233,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index >= MG_State::pGLContext->GetBufferBindingPointCount(bufferTarget)) {
|
if (index >= GetIndexedBufferQueryPointCount(bufferTarget)) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidValue,
|
ErrorCode::InvalidValue,
|
||||||
MakeUnique<GenericErrorInfo>(
|
MakeUnique<GenericErrorInfo>(
|
||||||
@@ -589,9 +599,17 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
*data = static_cast<GLint>(bufferObject->GetExternalIndex());
|
*data = static_cast<GLint>(bufferObject->GetExternalIndex());
|
||||||
return;
|
return;
|
||||||
case IndexedBufferQueryKind::Start:
|
case IndexedBufferQueryKind::Start:
|
||||||
|
if (!bindingPoint.HasExplicitRange()) {
|
||||||
|
*data = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
*data = static_cast<GLint>(bindingPoint.GetRange().start);
|
*data = static_cast<GLint>(bindingPoint.GetRange().start);
|
||||||
return;
|
return;
|
||||||
case IndexedBufferQueryKind::Size: {
|
case IndexedBufferQueryKind::Size: {
|
||||||
|
if (!bindingPoint.HasExplicitRange()) {
|
||||||
|
*data = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const Range1D range = bindingPoint.GetRange();
|
const Range1D range = bindingPoint.GetRange();
|
||||||
const auto start = std::min(range.start, bufferObject->GetSize());
|
const auto start = std::min(range.start, bufferObject->GetSize());
|
||||||
const auto end = std::min(range.end, bufferObject->GetSize());
|
const auto end = std::min(range.end, bufferObject->GetSize());
|
||||||
@@ -639,9 +657,17 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
*data = static_cast<GLint64>(bufferObject->GetExternalIndex());
|
*data = static_cast<GLint64>(bufferObject->GetExternalIndex());
|
||||||
return;
|
return;
|
||||||
case IndexedBufferQueryKind::Start:
|
case IndexedBufferQueryKind::Start:
|
||||||
|
if (!bindingPoint.HasExplicitRange()) {
|
||||||
|
*data = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
*data = static_cast<GLint64>(range.start);
|
*data = static_cast<GLint64>(range.start);
|
||||||
return;
|
return;
|
||||||
case IndexedBufferQueryKind::Size: {
|
case IndexedBufferQueryKind::Size: {
|
||||||
|
if (!bindingPoint.HasExplicitRange()) {
|
||||||
|
*data = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto start = std::min(range.start, bufferObject->GetSize());
|
const auto start = std::min(range.start, bufferObject->GetSize());
|
||||||
const auto end = std::min(range.end, bufferObject->GetSize());
|
const auto end = std::min(range.end, bufferObject->GetSize());
|
||||||
*data = static_cast<GLint64>(end - start);
|
*data = static_cast<GLint64>(end - start);
|
||||||
@@ -1669,7 +1695,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
*params = dynamicParameters.MaxSampleMaskWords;
|
*params = dynamicParameters.MaxSampleMaskWords;
|
||||||
break;
|
break;
|
||||||
case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS:
|
case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS:
|
||||||
*params = dynamicParameters.MaxShaderStorageBufferBindings;
|
*params = static_cast<GLint>(GetIndexedBufferQueryPointCount(BufferTarget::ShaderStorage));
|
||||||
break;
|
break;
|
||||||
case GL_MAX_TEXTURE_BUFFER_SIZE:
|
case GL_MAX_TEXTURE_BUFFER_SIZE:
|
||||||
*params = dynamicParameters.MaxTextureBufferSize;
|
*params = dynamicParameters.MaxTextureBufferSize;
|
||||||
|
|||||||
@@ -179,12 +179,21 @@ namespace MobileGL {
|
|||||||
|
|
||||||
Range1D GetRange() const { return m_range; }
|
Range1D GetRange() const { return m_range; }
|
||||||
|
|
||||||
void SetRange(const Range1D& range) { m_range = range; }
|
Bool HasExplicitRange() const { return m_hasExplicitRange; }
|
||||||
|
|
||||||
void ClearRange() { m_range = Range1D(); }
|
void SetRange(const Range1D& range, Bool hasExplicitRange = true) {
|
||||||
|
m_range = range;
|
||||||
|
m_hasExplicitRange = hasExplicitRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClearRange() {
|
||||||
|
m_range = Range1D();
|
||||||
|
m_hasExplicitRange = false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Range1D m_range;
|
Range1D m_range;
|
||||||
|
Bool m_hasExplicitRange = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ComponentSizes {
|
struct ComponentSizes {
|
||||||
|
|||||||
Reference in New Issue
Block a user