mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-20 08:21:56 +09:00
[Chore] (MG_Backend, MG_Backend/DirectGLES, MG_Backend/DirectVulkan, MG_Backend/MGPipe, MG_Backend/Record, MG_Benchmark/Buffer, MG_Benchmark/Container, MG_Benchmark/Driver, MG_Benchmark/Program, MG_Benchmark/ShaderCache, MG_Benchmark/Transpile, MG_Gbm, MG_Impl, MG_Impl/CGLImpl, MG_Impl/DyldInterpose, MG_Impl/EGLImpl, MG_Impl/GLImpl, MG_Impl/GLXImpl, MG_Impl/NSOpenGLImpl, MG_Impl/Pipe, MG_Impl/WGLImpl, MG_IntegrationTest, MG_IntegrationTest/Harness, MG_IntegrationTest/Scenarios, MG_Pipe, MG_Remote, MG_Remote/Client, MG_Remote/Protocol, MG_Remote/Server, MG_Remote/Transport, MG_Remote/Wire, MG_State/EGLState, MG_State/GLState, MG_Test, MG_Test/Backend, MG_Test/BackendLoader, MG_Test/Buffer, MG_Test/EGLState, MG_Test/Framebuffer, MG_Test/Gbm, MG_Test/Pipe, MG_Test/Pipeline, MG_Test/Program, MG_Test/Query, MG_Test/SelfTest, MG_Test/ShaderTranspiler, MG_Test/State, MG_Test/Swapchain, MG_Test/Texture, MG_Test/Util, MG_Test/VertexArray, MG_Test/Wire, MG_Util/Async, MG_Util/BackendLoaders, MG_Util/Converters, MG_Util/Damage, MG_Util/Debug, MG_Util/Math, MG_Util/Metrics, MG_Util/SelfTest, MG_Util/ShaderTranspiler, MG_Util/Texture, MG_Util/X11, MobileGL, scripts/data, tools/cts, tools/device_bench, tools/spikes, tools/trace_replay, tools/wgl-smoke): clang-format every C and C++ source
- Layout only: token streams match up to split literals, continuations and using order - The size totals fall, so the structure baseline is lowered
This commit is contained in:
@@ -104,9 +104,7 @@ namespace MobileGL::MG_Impl::CGLImpl {
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyPixelFormatAttribute(PixelFormatObject& pixelFormat,
|
||||
CGLPixelFormatAttribute attrib,
|
||||
GLint value) {
|
||||
void ApplyPixelFormatAttribute(PixelFormatObject& pixelFormat, CGLPixelFormatAttribute attrib, GLint value) {
|
||||
switch (attrib) {
|
||||
case kCGLPFADoubleBuffer:
|
||||
pixelFormat.DoubleBuffer = true;
|
||||
@@ -163,14 +161,22 @@ namespace MobileGL::MG_Impl::CGLImpl {
|
||||
EGLImpl::BindAPI(EGL_OPENGL_API);
|
||||
|
||||
const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, std::max(pixelFormat->AlphaSize, 0),
|
||||
EGL_DEPTH_SIZE, std::max(pixelFormat->DepthSize, 0),
|
||||
EGL_STENCIL_SIZE, std::max(pixelFormat->StencilSize, 0),
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_RED_SIZE,
|
||||
8,
|
||||
EGL_GREEN_SIZE,
|
||||
8,
|
||||
EGL_BLUE_SIZE,
|
||||
8,
|
||||
EGL_ALPHA_SIZE,
|
||||
std::max(pixelFormat->AlphaSize, 0),
|
||||
EGL_DEPTH_SIZE,
|
||||
std::max(pixelFormat->DepthSize, 0),
|
||||
EGL_STENCIL_SIZE,
|
||||
std::max(pixelFormat->StencilSize, 0),
|
||||
EGL_SURFACE_TYPE,
|
||||
EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE,
|
||||
EGL_OPENGL_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
@@ -191,9 +197,7 @@ namespace MobileGL::MG_Impl::CGLImpl {
|
||||
}
|
||||
|
||||
const EGLint contextAttribs[] = {
|
||||
EGL_CONTEXT_MAJOR_VERSION, 3,
|
||||
EGL_CONTEXT_MINOR_VERSION, 3,
|
||||
EGL_NONE,
|
||||
EGL_CONTEXT_MAJOR_VERSION, 3, EGL_CONTEXT_MINOR_VERSION, 3, EGL_NONE,
|
||||
};
|
||||
EGLContext eglContext = EGLImpl::CreateContext(display, config, shareContext, contextAttribs);
|
||||
if (eglContext == EGL_NO_CONTEXT) {
|
||||
@@ -246,12 +250,12 @@ namespace MobileGL::MG_Impl::CGLImpl {
|
||||
object.Surface = EGL_NO_SURFACE;
|
||||
}
|
||||
const EGLAttrib attribs[] = {
|
||||
EGL_WIDTH, std::max<GLint>(object.SurfaceBackingSize[0], 1),
|
||||
EGL_WIDTH, std::max<GLint>(object.SurfaceBackingSize[0], 1),
|
||||
EGL_HEIGHT, std::max<GLint>(object.SurfaceBackingSize[1], 1),
|
||||
EGL_NONE,
|
||||
};
|
||||
EGLSurface surface = EGLImpl::CreatePlatformWindowSurface(object.Display, object.Config,
|
||||
object.MetalLayer, attribs);
|
||||
EGLSurface surface =
|
||||
EGLImpl::CreatePlatformWindowSurface(object.Display, object.Config, object.MetalLayer, attribs);
|
||||
if (surface == EGL_NO_SURFACE) {
|
||||
object.HasDrawable = false;
|
||||
return kCGLBadDrawable;
|
||||
@@ -265,10 +269,9 @@ namespace MobileGL::MG_Impl::CGLImpl {
|
||||
if (object.Surface == EGL_NO_SURFACE) {
|
||||
return kCGLBadDrawable;
|
||||
}
|
||||
return EGLImpl::ResizePlatformWindowSurface(
|
||||
object.Display, object.Surface,
|
||||
std::max<GLint>(object.SurfaceBackingSize[0], 1),
|
||||
std::max<GLint>(object.SurfaceBackingSize[1], 1))
|
||||
return EGLImpl::ResizePlatformWindowSurface(object.Display, object.Surface,
|
||||
std::max<GLint>(object.SurfaceBackingSize[0], 1),
|
||||
std::max<GLint>(object.SurfaceBackingSize[1], 1))
|
||||
? kCGLNoError
|
||||
: kCGLBadDrawable;
|
||||
}
|
||||
@@ -528,8 +531,7 @@ namespace MobileGL::MG_Impl::CGLImpl {
|
||||
object->SwapInterval = params[0];
|
||||
EGLImpl::SwapInterval(object->Display, object->SwapInterval);
|
||||
return kCGLNoError;
|
||||
case kCGLCPSurfaceBackingSize:
|
||||
{
|
||||
case kCGLCPSurfaceBackingSize: {
|
||||
const GLint width = std::max<GLint>(params[0], 1);
|
||||
const GLint height = std::max<GLint>(params[1], 1);
|
||||
if (object->SurfaceBackingSize[0] == width && object->SurfaceBackingSize[1] == height) {
|
||||
|
||||
@@ -47,5 +47,5 @@ namespace MobileGL::MG_Impl::CGLImpl {
|
||||
CGLError AttachDrawable(CGLContextObj ctx, void* nsView, void* metalLayer, GLint width, GLint height);
|
||||
void* GetContextNSObject(CGLContextObj ctx);
|
||||
void SetContextNSObject(CGLContextObj ctx, void* nsObject);
|
||||
}
|
||||
} // namespace MobileGL::MG_Impl::CGLImpl
|
||||
#endif
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
MOBILEGL_CGL_API CGLError CGLChoosePixelFormat(const CGLPixelFormatAttribute* attribs,
|
||||
CGLPixelFormatObj* pix,
|
||||
MOBILEGL_CGL_API CGLError CGLChoosePixelFormat(const CGLPixelFormatAttribute* attribs, CGLPixelFormatObj* pix,
|
||||
GLint* npix) {
|
||||
return MobileGL::MG_Impl::CGLImpl::ChoosePixelFormat(attribs, pix, npix);
|
||||
}
|
||||
@@ -20,9 +19,7 @@ MOBILEGL_CGL_API CGLError CGLDestroyPixelFormat(CGLPixelFormatObj pix) {
|
||||
return MobileGL::MG_Impl::CGLImpl::DestroyPixelFormat(pix);
|
||||
}
|
||||
|
||||
MOBILEGL_CGL_API CGLError CGLDescribePixelFormat(CGLPixelFormatObj pix,
|
||||
GLint pix_num,
|
||||
CGLPixelFormatAttribute attrib,
|
||||
MOBILEGL_CGL_API CGLError CGLDescribePixelFormat(CGLPixelFormatObj pix, GLint pix_num, CGLPixelFormatAttribute attrib,
|
||||
GLint* value) {
|
||||
return MobileGL::MG_Impl::CGLImpl::DescribePixelFormat(pix, pix_num, attrib, value);
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ namespace {
|
||||
constexpr std::uint32_t MaxDisplays = sizeof(CGOpenGLDisplayMask) * 8;
|
||||
CGDirectDisplayID displays[MaxDisplays] = {};
|
||||
std::uint32_t displayCount = 0;
|
||||
if (displayMask != 0 &&
|
||||
CGGetActiveDisplayList(MaxDisplays, displays, &displayCount) == kCGErrorSuccess) {
|
||||
if (displayMask != 0 && CGGetActiveDisplayList(MaxDisplays, displays, &displayCount) == kCGErrorSuccess) {
|
||||
const auto mask = static_cast<CGOpenGLDisplayMask>(displayMask);
|
||||
for (std::uint32_t i = 0; i < displayCount; ++i) {
|
||||
if ((CGDisplayIDToOpenGLDisplayMask(displays[i]) & mask) != 0) {
|
||||
@@ -69,24 +68,22 @@ namespace {
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
CVReturn MobileGLCVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(
|
||||
CVDisplayLinkRef displayLink,
|
||||
CGLContextObj context,
|
||||
CGLPixelFormatObj pixelFormat) {
|
||||
CVReturn MobileGLCVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(CVDisplayLinkRef displayLink,
|
||||
CGLContextObj context,
|
||||
CGLPixelFormatObj pixelFormat) {
|
||||
GLint virtualScreen = 0;
|
||||
if (MobileGL::MG_Impl::CGLImpl::GetVirtualScreen(context, &virtualScreen) == kCGLNoError) {
|
||||
GLint displayMask = 0;
|
||||
if (!displayLink ||
|
||||
MobileGL::MG_Impl::CGLImpl::DescribePixelFormat(
|
||||
pixelFormat, virtualScreen, kCGLPFADisplayMask, &displayMask) != kCGLNoError) {
|
||||
if (!displayLink || MobileGL::MG_Impl::CGLImpl::DescribePixelFormat(
|
||||
pixelFormat, virtualScreen, kCGLPFADisplayMask, &displayMask) != kCGLNoError) {
|
||||
return kCVReturnInvalidArgument;
|
||||
}
|
||||
return CVDisplayLinkSetCurrentCGDisplay(displayLink, DisplayForMask(displayMask));
|
||||
}
|
||||
|
||||
using OriginalFunction = CVReturn (*)(CVDisplayLinkRef, CGLContextObj, CGLPixelFormatObj);
|
||||
static const auto original = reinterpret_cast<OriginalFunction>(
|
||||
dlsym(RTLD_NEXT, "CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext"));
|
||||
static const auto original =
|
||||
reinterpret_cast<OriginalFunction>(dlsym(RTLD_NEXT, "CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext"));
|
||||
return original ? original(displayLink, context, pixelFormat) : kCVReturnError;
|
||||
}
|
||||
|
||||
@@ -95,7 +92,7 @@ namespace {
|
||||
{reinterpret_cast<const void*>(MobileGLDlsym), reinterpret_cast<const void*>(dlsym)},
|
||||
{reinterpret_cast<const void*>(MobileGLCVDisplayLinkSetCurrentCGDisplayFromOpenGLContext),
|
||||
reinterpret_cast<const void*>(CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext)},
|
||||
};
|
||||
};
|
||||
#pragma clang diagnostic pop
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
static Double cpuStartMs = -1.0;
|
||||
const auto threadCpuMs = []() -> Double {
|
||||
#if defined(__unix__) || defined(__linux__) || defined(__ANDROID__)
|
||||
struct timespec now {};
|
||||
struct timespec now{};
|
||||
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &now) == 0)
|
||||
return static_cast<Double>(now.tv_sec) * 1000.0 + static_cast<Double>(now.tv_nsec) / 1e6;
|
||||
#endif
|
||||
@@ -195,11 +195,12 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
} // namespace
|
||||
|
||||
Bool StreamGateActive() {
|
||||
return MG_Config::Transport != MG_Config::TransportMode::Monolith &&
|
||||
!MG_Remote::Client::RunsAsTheServerRole();
|
||||
return MG_Config::Transport != MG_Config::TransportMode::Monolith && !MG_Remote::Client::RunsAsTheServerRole();
|
||||
}
|
||||
|
||||
std::recursive_mutex& StreamMutex() { return EGLOperationMutex(); }
|
||||
std::recursive_mutex& StreamMutex() {
|
||||
return EGLOperationMutex();
|
||||
}
|
||||
|
||||
void StreamBindCallingThreadLocked() {
|
||||
const Uint64 token = t_threadContextToken;
|
||||
@@ -253,7 +254,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
// server is another process; in the one-process shape the apply thread reads that block
|
||||
// too, and only a barriered apply's return may touch it (ClientSession::ReleaseFillPins).
|
||||
if (ClientSession* session = ClientSession::Active();
|
||||
session != nullptr && session->Started() && MG_Config::Transport != MG_Config::TransportMode::InProcess) {
|
||||
session != nullptr && session->Started() &&
|
||||
MG_Config::Transport != MG_Config::TransportMode::InProcess) {
|
||||
session->WaitForApplyToCatchUp("eglDestroyContext");
|
||||
session->ReleaseFillPins();
|
||||
}
|
||||
@@ -454,9 +456,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
}
|
||||
EGLint alpha = 0;
|
||||
(void)state->GetConfigAttrib(dpy, config, EGL_ALPHA_SIZE, &alpha);
|
||||
auto presentation =
|
||||
Wayland::WindowSurface::Create(reinterpret_cast<void*>(static_cast<uintptr_t>(nativeDisplay)), window,
|
||||
width, height, alpha > 0);
|
||||
auto presentation = Wayland::WindowSurface::Create(
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(nativeDisplay)), window, width, height, alpha > 0);
|
||||
if (!presentation) {
|
||||
state->SetError(EGL_BAD_NATIVE_WINDOW);
|
||||
return true;
|
||||
@@ -469,8 +470,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
(void)state->ResizeSurface(dpy, surface, width, height);
|
||||
auto* backendObject = GetBackendObject(state);
|
||||
if (!backendObject || !backendObject->CreateEGLPbufferSurface(surface, width, height)) {
|
||||
MGLOG_E("eglCreateWindowSurface: the backend refused the %dx%d drawable behind a Wayland window",
|
||||
width, height);
|
||||
MGLOG_E("eglCreateWindowSurface: the backend refused the %dx%d drawable behind a Wayland window", width,
|
||||
height);
|
||||
state->DestroySurface(dpy, surface);
|
||||
state->SetError(EGL_BAD_ALLOC);
|
||||
return true;
|
||||
@@ -493,8 +494,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
if (!it->second->TakeResize(&width, &height)) return;
|
||||
(void)state->ResizeSurface(dpy, surface, width, height);
|
||||
auto* backendObject = MG_Backend::pActiveBackendObject.get();
|
||||
if (backendObject == nullptr ||
|
||||
!backendObject->ResizeEGLWindowSurface(surface, static_cast<Uint32>(width), static_cast<Uint32>(height))) {
|
||||
if (backendObject == nullptr || !backendObject->ResizeEGLWindowSurface(surface, static_cast<Uint32>(width),
|
||||
static_cast<Uint32>(height))) {
|
||||
MGLOG_E("Wayland: the drawable behind a %dx%d window could not be resized", width, height);
|
||||
}
|
||||
}
|
||||
@@ -556,10 +557,12 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
lostFramebuffer.reset();
|
||||
lostDefault.reset();
|
||||
}
|
||||
if (auto* remote = dynamic_cast<MG_Remote::Client::BackendObject_Remote*>(MG_Backend::pActiveBackendObject.get()))
|
||||
if (auto* remote =
|
||||
dynamic_cast<MG_Remote::Client::BackendObject_Remote*>(MG_Backend::pActiveBackendObject.get()))
|
||||
remote->OnSessionReplaced();
|
||||
#if MOBILEGL_WAYLAND_WINDOWS
|
||||
for (auto& [surface, presentation] : WaylandSurfaces()) presentation->OnSessionReplaced();
|
||||
for (auto& [surface, presentation] : WaylandSurfaces())
|
||||
presentation->OnSessionReplaced();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@@ -686,7 +689,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
requestedWidth = static_cast<Uint32>(nativeWidth);
|
||||
requestedHeight = static_cast<Uint32>(nativeHeight);
|
||||
MGLOG_I("eglCreateWindowSurface: no EGL_WIDTH/EGL_HEIGHT; the server-owned window is asked for the "
|
||||
"native window's %dx%d", nativeWidth, nativeHeight);
|
||||
"native window's %dx%d",
|
||||
nativeWidth, nativeHeight);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -725,7 +729,9 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
return surface;
|
||||
}
|
||||
|
||||
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw) { return SwapBuffersWithDamage(dpy, draw, nullptr, 0); }
|
||||
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw) {
|
||||
return SwapBuffersWithDamage(dpy, draw, nullptr, 0);
|
||||
}
|
||||
|
||||
// EGL_KHR/EXT_swap_buffers_with_damage. The rectangles (GL window coordinates, origin
|
||||
// bottom-left; none = the whole surface) are clipped to the surface and fitted into a record.
|
||||
@@ -774,7 +780,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
if (!damage.IsFull()) {
|
||||
EGLint width = 0;
|
||||
EGLint height = 0;
|
||||
if (state->QuerySurface(dpy, draw, EGL_WIDTH, &width) && state->QuerySurface(dpy, draw, EGL_HEIGHT, &height)) {
|
||||
if (state->QuerySurface(dpy, draw, EGL_WIDTH, &width) &&
|
||||
state->QuerySurface(dpy, draw, EGL_HEIGHT, &height)) {
|
||||
damage.Normalize(width, height);
|
||||
} else {
|
||||
damage.SetFull();
|
||||
@@ -796,7 +803,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
Bool (*const sessionLost)() = nullptr;
|
||||
#endif
|
||||
switch (it->second->Present(damage, state->GetSwapInterval(dpy), sessionLost)) {
|
||||
case Wayland::WindowSurface::PresentResult::kPresented: break;
|
||||
case Wayland::WindowSurface::PresentResult::kPresented:
|
||||
break;
|
||||
case Wayland::WindowSurface::PresentResult::kLost:
|
||||
it->second->CommitPendingState();
|
||||
state->SetError(EGL_CONTEXT_LOST);
|
||||
@@ -810,7 +818,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
const Bool swapped = damage.IsFull() ? backendObject->SwapEGLBuffers(dpy, draw)
|
||||
: backendObject->SwapEGLBuffersWithDamage(dpy, draw, damage);
|
||||
if (!swapped) {
|
||||
MGLOG_E_ONCE("eglSwapBuffers failed on thread=%s dpy=%p draw=%p", CurrentThreadIdString().c_str(), dpy, draw);
|
||||
MGLOG_E_ONCE("eglSwapBuffers failed on thread=%s dpy=%p draw=%p", CurrentThreadIdString().c_str(), dpy,
|
||||
draw);
|
||||
state->SetError(EGL_BAD_SURFACE);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
@@ -874,8 +883,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
// fresh session's all the same.
|
||||
const ClientSession::ScopedCurrentSessionWork currentSession;
|
||||
// A split client builds the context's GL state only once the server has its token (below).
|
||||
const Bool splitClient = MG_Config::Transport != MG_Config::TransportMode::Monolith &&
|
||||
!MG_Remote::Client::RunsAsTheServerRole();
|
||||
const Bool splitClient =
|
||||
MG_Config::Transport != MG_Config::TransportMode::Monolith && !MG_Remote::Client::RunsAsTheServerRole();
|
||||
#else
|
||||
constexpr Bool splitClient = false;
|
||||
#endif
|
||||
@@ -899,10 +908,9 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
// handle whose first verb the server refuses - a late failure where an early one is
|
||||
// available, and EGL_NO_CONTEXT with EGL_BAD_ACCESS is the early one. NoWire (the
|
||||
// pre-Start bring-up, the server role) keeps it: there is no server to refuse.
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith &&
|
||||
!MG_Remote::Client::RunsAsTheServerRole()) {
|
||||
auto emitted = MG_Remote::Client::SendCreateContextFrame(
|
||||
state->GetContextClientToken(context), state->GetContextShareGroupToken(context), 0);
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith && !MG_Remote::Client::RunsAsTheServerRole()) {
|
||||
auto emitted = MG_Remote::Client::SendCreateContextFrame(state->GetContextClientToken(context),
|
||||
state->GetContextShareGroupToken(context), 0);
|
||||
// THE LOSS CAN BE FOUND OUT HERE: a session whose server is gone, which nothing had
|
||||
// noticed yet, refuses the create by hanging up on it. That is the loss, not a refusal:
|
||||
// the half-built context goes (its objects silently - they were never on any server),
|
||||
@@ -941,7 +949,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
// built before the token crossed: a context in a share group of its own then drew with
|
||||
// default objects its group never had.
|
||||
if (emitted == MG_Remote::Client::ContextFrameEmit::Sent) {
|
||||
StreamBindContextLocked(state->GetContextClientToken(context), state->GetContextShareGroupToken(context));
|
||||
StreamBindContextLocked(state->GetContextClientToken(context),
|
||||
state->GetContextShareGroupToken(context));
|
||||
}
|
||||
(void)state->BuildContextGLState(context);
|
||||
}
|
||||
@@ -1026,8 +1035,9 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
#endif
|
||||
const String threadId = CurrentThreadIdString();
|
||||
|
||||
MGLOG_D("eglMakeCurrent begin thread=%s dpy=%p draw=%p read=%p ctx=%p oldDpy=%p oldDraw=%p oldRead=%p oldCtx=%p",
|
||||
threadId.c_str(), dpy, draw, read, ctx, oldDisplay, oldDraw, oldRead, oldContext);
|
||||
MGLOG_D(
|
||||
"eglMakeCurrent begin thread=%s dpy=%p draw=%p read=%p ctx=%p oldDpy=%p oldDraw=%p oldRead=%p oldCtx=%p",
|
||||
threadId.c_str(), dpy, draw, read, ctx, oldDisplay, oldDraw, oldRead, oldContext);
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// EGL 1.5 3.7.3 / 3.2: after a power-management event - a lost device, here - making a
|
||||
// context created before it current fails with EGL_CONTEXT_LOST. The application destroys
|
||||
@@ -1053,8 +1063,7 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
const Bool releaseCurrentRequest =
|
||||
draw == EGL_NO_SURFACE && read == EGL_NO_SURFACE && ctx == EGL_NO_CONTEXT;
|
||||
const Bool releaseCurrentRequest = draw == EGL_NO_SURFACE && read == EGL_NO_SURFACE && ctx == EGL_NO_CONTEXT;
|
||||
if (releaseCurrentRequest) {
|
||||
if (auto* backendObject = MG_Backend::pActiveBackendObject.get()) {
|
||||
if (!backendObject->MakeEGLCurrent(dpy, draw, read, ctx)) {
|
||||
@@ -1097,8 +1106,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
}
|
||||
}
|
||||
if (!backendObject->MakeEGLCurrent(dpy, backendDraw, backendRead, ctx)) {
|
||||
MGLOG_E_ONCE("eglMakeCurrent backend attach failed thread=%s dpy=%p draw=%p read=%p ctx=%p", threadId.c_str(),
|
||||
dpy, draw, read, ctx);
|
||||
MGLOG_E_ONCE("eglMakeCurrent backend attach failed thread=%s dpy=%p draw=%p read=%p ctx=%p",
|
||||
threadId.c_str(), dpy, draw, read, ctx);
|
||||
state->SetError(EGL_BAD_ACCESS);
|
||||
state->MakeCurrent(oldDisplay, oldDraw, oldRead, oldContext);
|
||||
return EGL_FALSE;
|
||||
@@ -1306,7 +1315,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
// backend: let it bring the surface's record up to date first, so a caller that polls the size
|
||||
// while it draws nothing still sees the change.
|
||||
if (attribute == EGL_WIDTH || attribute == EGL_HEIGHT) {
|
||||
if (auto* backendObject = MG_Backend::pActiveBackendObject.get()) backendObject->RefreshSurfaceExtent(surface);
|
||||
if (auto* backendObject = MG_Backend::pActiveBackendObject.get())
|
||||
backendObject->RefreshSurfaceExtent(surface);
|
||||
}
|
||||
return state->QuerySurface(display, surface, attribute, value) ? EGL_TRUE : EGL_FALSE;
|
||||
}
|
||||
@@ -1338,7 +1348,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
if (!region.IsFull()) {
|
||||
EGLint width = 0;
|
||||
EGLint height = 0;
|
||||
if (state->QuerySurface(dpy, surface, EGL_WIDTH, &width) && state->QuerySurface(dpy, surface, EGL_HEIGHT, &height))
|
||||
if (state->QuerySurface(dpy, surface, EGL_WIDTH, &width) &&
|
||||
state->QuerySurface(dpy, surface, EGL_HEIGHT, &height))
|
||||
region.Normalize(width, height);
|
||||
else
|
||||
region.SetFull();
|
||||
@@ -1653,7 +1664,9 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
return state->GetSyncAttrib(dpy, sync, attribute, value) ? EGL_TRUE : EGL_FALSE;
|
||||
}
|
||||
|
||||
void SetDispatcherCurrentApiHook(EGLenum (*hook)()) { g_dispatcherCurrentApi.store(hook); }
|
||||
void SetDispatcherCurrentApiHook(EGLenum (*hook)()) {
|
||||
g_dispatcherCurrentApi.store(hook);
|
||||
}
|
||||
|
||||
Bool SharedImagesAvailable() {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
@@ -1678,8 +1691,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
auto* backendObject = MG_Backend::pActiveBackendObject.get();
|
||||
if (backendObject == nullptr) return false;
|
||||
MG_Backend::SharedImageExport probe{};
|
||||
const Bool allocated = backendObject->AllocateSharedImage(
|
||||
16, 16, MG_State::EGLState::EGLContext::kDrmFourccNv12, &probe);
|
||||
const Bool allocated =
|
||||
backendObject->AllocateSharedImage(16, 16, MG_State::EGLState::EGLContext::kDrmFourccNv12, &probe);
|
||||
#if !defined(_WIN32)
|
||||
if (probe.Fd >= 0) ::close(probe.Fd);
|
||||
#endif
|
||||
@@ -1695,7 +1708,7 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
#if defined(_WIN32)
|
||||
return false;
|
||||
#else
|
||||
struct stat sa {}, sb {};
|
||||
struct stat sa{}, sb{};
|
||||
return ::fstat(a, &sa) == 0 && ::fstat(b, &sb) == 0 && sa.st_dev == sb.st_dev && sa.st_ino == sb.st_ino;
|
||||
#endif
|
||||
}
|
||||
@@ -1717,7 +1730,9 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void NoteSharedImageBoundToTexture() { SharedImageBoundToTexture().store(true, std::memory_order_relaxed); }
|
||||
void NoteSharedImageBoundToTexture() {
|
||||
SharedImageBoundToTexture().store(true, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void FlushSharedImageAccesses() {
|
||||
if (!SharedImageBoundToTexture().load(std::memory_order_relaxed) &&
|
||||
@@ -1794,10 +1809,10 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
static_cast<Uint32>(request.Height), request.Fourcc,
|
||||
layout, &sharedImageId);
|
||||
} else {
|
||||
imported = backendObject != nullptr &&
|
||||
backendObject->ImportSharedImage(request.Fd, static_cast<Uint32>(request.Width),
|
||||
static_cast<Uint32>(request.Height), request.Fourcc,
|
||||
&sharedImageId);
|
||||
imported =
|
||||
backendObject != nullptr &&
|
||||
backendObject->ImportSharedImage(request.Fd, static_cast<Uint32>(request.Width),
|
||||
static_cast<Uint32>(request.Height), request.Fourcc, &sharedImageId);
|
||||
}
|
||||
if (!imported || sharedImageId == 0) {
|
||||
MGLOG_I_ONCE("eglCreateImage: a %dx%d dma-buf is not one of the server's shared images; refused "
|
||||
@@ -1854,7 +1869,8 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
if (!state) {
|
||||
return EGL_FALSE;
|
||||
}
|
||||
return state->QueryDmaBufFormats(dpy, SharedImagesAvailable(), SharedImageYuvAvailable(), max_formats, formats, num_formats)
|
||||
return state->QueryDmaBufFormats(dpy, SharedImagesAvailable(), SharedImageYuvAvailable(), max_formats, formats,
|
||||
num_formats)
|
||||
? EGL_TRUE
|
||||
: EGL_FALSE;
|
||||
}
|
||||
@@ -1866,8 +1882,9 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
if (!state) {
|
||||
return EGL_FALSE;
|
||||
}
|
||||
return state->QueryDmaBufModifiers(dpy, SharedImagesAvailable(), SharedImageYuvAvailable(), format, max_modifiers,
|
||||
reinterpret_cast<Uint64*>(modifiers), external_only, num_modifiers)
|
||||
return state->QueryDmaBufModifiers(dpy, SharedImagesAvailable(), SharedImageYuvAvailable(), format,
|
||||
max_modifiers, reinterpret_cast<Uint64*>(modifiers), external_only,
|
||||
num_modifiers)
|
||||
? EGL_TRUE
|
||||
: EGL_FALSE;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
// like a surfaceless one (the frames come from the backend, not from the device), and window
|
||||
// surfaces on it are refused. Chromium's Wayland GPU process hands its GL implementation nothing
|
||||
// but a GBM display, so without the claim it never reaches this library at all.
|
||||
#define MOBILEGL_PLATFORM_WAYLAND_EXTENSIONS \
|
||||
#define MOBILEGL_PLATFORM_WAYLAND_EXTENSIONS \
|
||||
" EGL_KHR_platform_wayland EGL_EXT_platform_wayland EGL_KHR_platform_gbm EGL_MESA_platform_gbm"
|
||||
#else
|
||||
#define MOBILEGL_PLATFORM_WAYLAND_EXTENSIONS ""
|
||||
@@ -52,4 +52,4 @@ namespace MobileGL::MG_Impl::EGLImpl {
|
||||
inline constexpr const char* kClientExtensionString =
|
||||
"EGL_EXT_client_extensions EGL_KHR_create_context EGL_EXT_platform_base "
|
||||
"EGL_KHR_platform_base EGL_MESA_platform_surfaceless" MOBILEGL_PLATFORM_WAYLAND_EXTENSIONS;
|
||||
}
|
||||
} // namespace MobileGL::MG_Impl::EGLImpl
|
||||
|
||||
@@ -379,7 +379,7 @@ MOBILEGL_EGL_API EGLBoolean eglDestroyImage(EGLDisplay dpy, EGLImage image) {
|
||||
// for every cached client buffer when it dies, wl_shm ones included; a null answer from
|
||||
// eglGetProcAddress made that a jump to address 0.
|
||||
MOBILEGL_EGL_API EGLImage eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer,
|
||||
const EGLint* attrib_list) {
|
||||
const EGLint* attrib_list) {
|
||||
const MobileGL::MG_Impl::EGLImpl::StreamLockScope mglStreamLock;
|
||||
MGLOG_D("eglCreateImageKHR(dpy=%p, ctx=%p, target=%u, buffer=%p, attrib_list=%p)", dpy, ctx, target, buffer,
|
||||
attrib_list);
|
||||
|
||||
@@ -37,12 +37,10 @@
|
||||
|
||||
// Defined in Definitions.cpp; eglext.h declares them only under EGL_EGLEXT_PROTOTYPES.
|
||||
extern "C" EGLImage eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer,
|
||||
const EGLint* attrib_list);
|
||||
const EGLint* attrib_list);
|
||||
extern "C" EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImage image);
|
||||
extern "C" EGLBoolean eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface draw, const EGLint* rects,
|
||||
EGLint n_rects);
|
||||
extern "C" EGLBoolean eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface draw, const EGLint* rects,
|
||||
EGLint n_rects);
|
||||
extern "C" EGLBoolean eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface draw, const EGLint* rects, EGLint n_rects);
|
||||
extern "C" EGLBoolean eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface draw, const EGLint* rects, EGLint n_rects);
|
||||
extern "C" EGLBoolean eglSetDamageRegionKHR(EGLDisplay dpy, EGLSurface surface, EGLint* rects, EGLint n_rects);
|
||||
extern "C" EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list);
|
||||
extern "C" EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
|
||||
@@ -147,7 +145,9 @@ namespace {
|
||||
|
||||
// One device, one identity. A pointer to a private object rather than a number, so that a
|
||||
// device from somewhere else cannot compare equal to this one by accident.
|
||||
struct DeviceToken { int unused; };
|
||||
struct DeviceToken {
|
||||
int unused;
|
||||
};
|
||||
DeviceToken g_deviceToken;
|
||||
|
||||
EGLBoolean EGLAPIENTRY VendorQueryDevicesEXT(EGLint max_devices, EGLDeviceEXT* devices, EGLint* num_devices) {
|
||||
@@ -227,7 +227,8 @@ namespace {
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
EGLint EGLAPIENTRY VendorLabelObjectKHR(EGLDisplay dpy, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label) {
|
||||
EGLint EGLAPIENTRY VendorLabelObjectKHR(EGLDisplay dpy, EGLenum objectType, EGLObjectKHR object,
|
||||
EGLLabelKHR label) {
|
||||
(void)dpy;
|
||||
(void)objectType;
|
||||
(void)object;
|
||||
@@ -333,7 +334,9 @@ namespace {
|
||||
return reinterpret_cast<void*>(MG_Impl::EGLImpl::GetProcAddress(procName));
|
||||
}
|
||||
|
||||
void* EGLAPIENTRY VendorGetProcAddress(const char* procName) { return LookupEntryPoint(procName); }
|
||||
void* EGLAPIENTRY VendorGetProcAddress(const char* procName) {
|
||||
return LookupEntryPoint(procName);
|
||||
}
|
||||
|
||||
// glvnd hands a vendor the index each EGL entry point occupies in its dispatch table, so that a
|
||||
// vendor whose entry points are thin wrappers around glvnd can call back into the right slot.
|
||||
@@ -345,8 +348,10 @@ namespace {
|
||||
(void)index;
|
||||
}
|
||||
|
||||
void* EGLAPIENTRY VendorGetDispatchAddress(const char* procName) { return LookupEntryPoint(procName); }
|
||||
} // namespace
|
||||
void* EGLAPIENTRY VendorGetDispatchAddress(const char* procName) {
|
||||
return LookupEntryPoint(procName);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// libeglabi.h has already declared this prototype without an export attribute, and MSVC refuses a
|
||||
// redeclaration that adds dllexport. Windows has no glvnd to look the symbol up, so it is a plain
|
||||
@@ -356,8 +361,8 @@ namespace {
|
||||
#else
|
||||
#define MOBILEGL_GLVND_EGL_MAIN MOBILEGL_EGL_API
|
||||
#endif
|
||||
MOBILEGL_GLVND_EGL_MAIN EGLBoolean __egl_Main(uint32_t version, const __EGLapiExports* exports,
|
||||
__EGLvendorInfo* vendor, __EGLapiImports* imports) {
|
||||
MOBILEGL_GLVND_EGL_MAIN EGLBoolean __egl_Main(uint32_t version, const __EGLapiExports* exports, __EGLvendorInfo* vendor,
|
||||
__EGLapiImports* imports) {
|
||||
(void)vendor;
|
||||
if (EGL_VENDOR_ABI_GET_MAJOR_VERSION(version) != EGL_VENDOR_ABI_MAJOR_VERSION) {
|
||||
// A vendor that does not know the ABI it is being handed must say so, not guess: the
|
||||
|
||||
@@ -206,8 +206,8 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
api.readEvents = reinterpret_cast<decltype(api.readEvents)>(sym("wl_display_read_events"));
|
||||
api.cancelRead = reinterpret_cast<decltype(api.cancelRead)>(sym("wl_display_cancel_read"));
|
||||
api.loaded = api.displayInterface && api.registryInterface && api.shmInterface &&
|
||||
api.shmPoolInterface && api.bufferInterface && api.marshalFlags && api.addListener && api.destroy &&
|
||||
api.getVersion && api.createWrapper && api.wrapperDestroy && api.setQueue &&
|
||||
api.shmPoolInterface && api.bufferInterface && api.marshalFlags && api.addListener &&
|
||||
api.destroy && api.getVersion && api.createWrapper && api.wrapperDestroy && api.setQueue &&
|
||||
api.createQueue && api.queueDestroy && api.roundtripQueue && api.dispatchQueue &&
|
||||
api.dispatchQueuePending && api.flush;
|
||||
if (!api.loaded) MGLOG_E("Wayland: libwayland-client.so.0 lacks an entry point this library uses");
|
||||
@@ -226,7 +226,9 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
};
|
||||
|
||||
// The compositor is done with a buffer: it may be drawn into again.
|
||||
void OnBufferRelease(void* data, wl_proxy*) { static_cast<ShmBuffer*>(data)->busy = false; }
|
||||
void OnBufferRelease(void* data, wl_proxy*) {
|
||||
static_cast<ShmBuffer*>(data)->busy = false;
|
||||
}
|
||||
void (*const kBufferListener[])(void) = {reinterpret_cast<void (*)(void)>(&OnBufferRelease)};
|
||||
|
||||
// zwp_linux_dmabuf_v1 and zwp_linux_buffer_params_v1 as their generated protocol code
|
||||
@@ -270,8 +272,12 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
p.paramsEvents[1] = {"failed", "", p.noObjectTypes};
|
||||
p.dmabuf = {"zwp_linux_dmabuf_v1", static_cast<int>(kDmabufMaxVersion), 2, p.dmabufRequests, 2,
|
||||
p.dmabufEvents};
|
||||
p.params = {"zwp_linux_buffer_params_v1", static_cast<int>(kDmabufMaxVersion), 4, p.paramsRequests,
|
||||
2, p.paramsEvents};
|
||||
p.params = {"zwp_linux_buffer_params_v1",
|
||||
static_cast<int>(kDmabufMaxVersion),
|
||||
4,
|
||||
p.paramsRequests,
|
||||
2,
|
||||
p.paramsEvents};
|
||||
ready = true;
|
||||
});
|
||||
return ready ? &protocol : nullptr;
|
||||
@@ -290,8 +296,12 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
wl_proxy* buffer = nullptr;
|
||||
Bool failed = false;
|
||||
};
|
||||
void OnParamsCreated(void* data, wl_proxy*, wl_proxy* buffer) { static_cast<ParamsOutcome*>(data)->buffer = buffer; }
|
||||
void OnParamsFailed(void* data, wl_proxy*) { static_cast<ParamsOutcome*>(data)->failed = true; }
|
||||
void OnParamsCreated(void* data, wl_proxy*, wl_proxy* buffer) {
|
||||
static_cast<ParamsOutcome*>(data)->buffer = buffer;
|
||||
}
|
||||
void OnParamsFailed(void* data, wl_proxy*) {
|
||||
static_cast<ParamsOutcome*>(data)->failed = true;
|
||||
}
|
||||
void (*const kParamsListener[])(void) = {reinterpret_cast<void (*)(void)>(&OnParamsCreated),
|
||||
reinterpret_cast<void (*)(void)>(&OnParamsFailed)};
|
||||
|
||||
@@ -304,7 +314,9 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
Bool busy = false;
|
||||
};
|
||||
|
||||
void OnDmabufBufferRelease(void* data, wl_proxy*) { static_cast<DmabufBuffer*>(data)->busy = false; }
|
||||
void OnDmabufBufferRelease(void* data, wl_proxy*) {
|
||||
static_cast<DmabufBuffer*>(data)->busy = false;
|
||||
}
|
||||
void (*const kDmabufBufferListener[])(void) = {reinterpret_cast<void (*)(void)>(&OnDmabufBufferRelease)};
|
||||
|
||||
// MOBILEGL_WAYLAND_DMABUF=0 keeps every window on wl_shm.
|
||||
@@ -357,8 +369,10 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
const Api& api = WaylandApi();
|
||||
if (frameCallback) api.destroy(frameCallback);
|
||||
if (surfaceWrapper) api.wrapperDestroy(surfaceWrapper);
|
||||
for (auto& buffer : buffers) Release(buffer);
|
||||
for (auto& buffer : dmabufBuffers) Release(buffer);
|
||||
for (auto& buffer : buffers)
|
||||
Release(buffer);
|
||||
for (auto& buffer : dmabufBuffers)
|
||||
Release(buffer);
|
||||
if (dmabuf) api.marshalFlags(dmabuf, kDmabufDestroy, nullptr, api.getVersion(dmabuf), kMarshalFlagDestroy);
|
||||
// Neither wl_shm (version 1) nor wl_registry has a destroy request: the proxies go
|
||||
// on this side only.
|
||||
@@ -374,8 +388,9 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
|
||||
void Release(ShmBuffer& buffer) {
|
||||
const Api& api = WaylandApi();
|
||||
if (buffer.buffer) api.marshalFlags(buffer.buffer, kBufferDestroy, nullptr, api.getVersion(buffer.buffer),
|
||||
kMarshalFlagDestroy);
|
||||
if (buffer.buffer)
|
||||
api.marshalFlags(buffer.buffer, kBufferDestroy, nullptr, api.getVersion(buffer.buffer),
|
||||
kMarshalFlagDestroy);
|
||||
if (buffer.map) munmap(buffer.map, buffer.size);
|
||||
buffer = ShmBuffer{};
|
||||
}
|
||||
@@ -402,8 +417,8 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
return false;
|
||||
}
|
||||
// One pool per buffer, destroyed at once: the buffer keeps the memory alive.
|
||||
wl_proxy* pool = api.marshalFlags(shm, kShmCreatePool, api.shmPoolInterface, api.getVersion(shm), 0, nullptr,
|
||||
fd, static_cast<int32_t>(size));
|
||||
wl_proxy* pool = api.marshalFlags(shm, kShmCreatePool, api.shmPoolInterface, api.getVersion(shm), 0,
|
||||
nullptr, fd, static_cast<int32_t>(size));
|
||||
close(fd);
|
||||
if (pool == nullptr) {
|
||||
munmap(map, size);
|
||||
@@ -451,8 +466,9 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
// as long as it still shows it.
|
||||
void Release(DmabufBuffer& buffer) {
|
||||
const Api& api = WaylandApi();
|
||||
if (buffer.buffer) api.marshalFlags(buffer.buffer, kBufferDestroy, nullptr, api.getVersion(buffer.buffer),
|
||||
kMarshalFlagDestroy);
|
||||
if (buffer.buffer)
|
||||
api.marshalFlags(buffer.buffer, kBufferDestroy, nullptr, api.getVersion(buffer.buffer),
|
||||
kMarshalFlagDestroy);
|
||||
if (buffer.imageId != 0) {
|
||||
if (auto* backendObject = MG_Backend::pActiveBackendObject.get()) {
|
||||
(void)backendObject->ReleaseSharedImage(buffer.imageId);
|
||||
@@ -545,7 +561,8 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
|
||||
// The rest of this window's life is wl_shm's.
|
||||
void FallBackToShm() {
|
||||
for (auto& buffer : dmabufBuffers) Release(buffer);
|
||||
for (auto& buffer : dmabufBuffers)
|
||||
Release(buffer);
|
||||
dmabufDamage.InvalidateAll();
|
||||
useDmabuf = false;
|
||||
}
|
||||
@@ -649,8 +666,7 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
};
|
||||
|
||||
namespace {
|
||||
void OnRegistryGlobal(void* data, wl_proxy* registry, uint32_t name, const char* interface,
|
||||
uint32_t version) {
|
||||
void OnRegistryGlobal(void* data, wl_proxy* registry, uint32_t name, const char* interface, uint32_t version) {
|
||||
auto* impl = static_cast<WindowSurface::Impl*>(data);
|
||||
const Api& api = WaylandApi();
|
||||
if (impl->shm == nullptr && std::strcmp(interface, "wl_shm") == 0) {
|
||||
@@ -658,8 +674,7 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
api.marshalFlags(registry, kRegistryBind, api.shmInterface, 1, 0, name, "wl_shm", 1u, nullptr);
|
||||
return;
|
||||
}
|
||||
if (impl->dmabufWanted && impl->dmabuf == nullptr &&
|
||||
std::strcmp(interface, "zwp_linux_dmabuf_v1") == 0) {
|
||||
if (impl->dmabufWanted && impl->dmabuf == nullptr && std::strcmp(interface, "zwp_linux_dmabuf_v1") == 0) {
|
||||
const LinuxDmabufProtocol* protocol = LinuxDmabuf();
|
||||
if (protocol == nullptr) return;
|
||||
const uint32_t bindVersion = std::min(version, kDmabufMaxVersion);
|
||||
@@ -680,7 +695,9 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
void (*const kFrameListener[])(void) = {reinterpret_cast<void (*)(void)>(&OnFrameDone)};
|
||||
|
||||
// The application destroyed its wl_egl_window first: nothing may be read from it after this.
|
||||
void OnWindowDestroyed(void* data) { static_cast<WindowSurface::Impl*>(data)->window = nullptr; }
|
||||
void OnWindowDestroyed(void* data) {
|
||||
static_cast<WindowSurface::Impl*>(data)->window = nullptr;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
@@ -734,8 +751,8 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
api.setQueue(static_cast<wl_proxy*>(surfaceWrapper), queue);
|
||||
}
|
||||
auto* wrapper = static_cast<wl_proxy*>(surfaceWrapper);
|
||||
frameCallback = api.marshalFlags(wrapper, kSurfaceFrame, api.callbackInterface, api.getVersion(wrapper), 0,
|
||||
nullptr);
|
||||
frameCallback =
|
||||
api.marshalFlags(wrapper, kSurfaceFrame, api.callbackInterface, api.getVersion(wrapper), 0, nullptr);
|
||||
if (frameCallback == nullptr) return;
|
||||
api.addListener(frameCallback, const_cast<void (**)(void)>(kFrameListener), this);
|
||||
throttle.Requested(NowMs());
|
||||
@@ -767,8 +784,8 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
if (impl->queue == nullptr || impl->displayWrapper == nullptr) return nullptr;
|
||||
api.setQueue(static_cast<wl_proxy*>(impl->displayWrapper), impl->queue);
|
||||
auto* wrapper = static_cast<wl_proxy*>(impl->displayWrapper);
|
||||
impl->registry = api.marshalFlags(wrapper, kDisplayGetRegistry, api.registryInterface, api.getVersion(wrapper),
|
||||
0, nullptr);
|
||||
impl->registry =
|
||||
api.marshalFlags(wrapper, kDisplayGetRegistry, api.registryInterface, api.getVersion(wrapper), 0, nullptr);
|
||||
if (impl->registry == nullptr) return nullptr;
|
||||
api.addListener(impl->registry, const_cast<void (**)(void)>(kRegistryListener), impl.get());
|
||||
if (api.roundtripQueue(wlDisplay, impl->queue) < 0 || impl->shm == nullptr) {
|
||||
@@ -852,7 +869,8 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
auto* backendObject = MG_Backend::pActiveBackendObject.get();
|
||||
if (buffer != nullptr && backendObject != nullptr) {
|
||||
const SizeT index = static_cast<SizeT>(buffer - impl.dmabufBuffers);
|
||||
const MG_Util::Damage::Region copy = impl.dmabufDamage.TakeForWrite(index, damage, impl.width, impl.height);
|
||||
const MG_Util::Damage::Region copy =
|
||||
impl.dmabufDamage.TakeForWrite(index, damage, impl.width, impl.height);
|
||||
if (backendObject->PresentToSharedImage(buffer->imageId, copy)) {
|
||||
impl.Commit(buffer->buffer, damage);
|
||||
buffer->busy = true;
|
||||
|
||||
@@ -90,7 +90,11 @@ namespace MobileGL::MG_Impl::EGLImpl::Wayland {
|
||||
// that failed - or was read back - on a lost device is nothing but zeros: kLost, with no
|
||||
// buffer attached and the window left where it was, so the caller reports the loss at
|
||||
// this swap instead of showing a transparent window that the toolkit never redraws.
|
||||
enum class PresentResult { kPresented, kNotShown, kLost };
|
||||
enum class PresentResult {
|
||||
kPresented,
|
||||
kNotShown,
|
||||
kLost
|
||||
};
|
||||
PresentResult Present(const MG_Util::Damage::Region& damage, Int swapInterval, Bool (*sessionLost)());
|
||||
|
||||
// wl_egl_window_resize's effect, taken: true (with the new size) when the application gave
|
||||
|
||||
@@ -138,15 +138,14 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const TextureInternalFormat internal =
|
||||
MG_Util::ConvertGLEnumToTextureInternalFormat(internalformat);
|
||||
const TextureInternalFormat internal = MG_Util::ConvertGLEnumToTextureInternalFormat(internalformat);
|
||||
const SizeT elementSize = MG_Util::GetSizedInternalFormatSizeInBytes(internal);
|
||||
if (elementSize == 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
std::format("internalformat 0x{:X} has no known element size.",
|
||||
internalformat)));
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
std::format("internalformat 0x{:X} has no known element size.", internalformat)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -157,9 +156,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
GLsizeiptr size, SizeT patternSize, BufferOp op) {
|
||||
if (offset < 0 || size < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"Offset and size must be non-negative."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"Offset and size must be non-negative."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -173,10 +171,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
if (static_cast<SizeT>(offset) + static_cast<SizeT>(size) > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"Offset and size exceed buffer size."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"Offset and size exceed buffer size."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -191,8 +188,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool BuildClearPattern(GLenum internalformat, GLenum format, GLenum type, const void* data,
|
||||
SizeT patternSize, BufferOp op, Vector<Uint8>& pattern) {
|
||||
Bool BuildClearPattern(GLenum internalformat, GLenum format, GLenum type, const void* data, SizeT patternSize,
|
||||
BufferOp op, Vector<Uint8>& pattern) {
|
||||
const TextureInternalFormat internal = MG_Util::ConvertGLEnumToTextureInternalFormat(internalformat);
|
||||
const TextureInputFormat inputFormat = MG_Util::ConvertGLEnumToTextureInputFormat(format);
|
||||
const TexturePixelDataType inputType = MG_Util::ConvertGLEnumToTexturePixelDataType(type);
|
||||
@@ -212,8 +209,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
inputPixel = zeroInput.data();
|
||||
}
|
||||
|
||||
if (!MG_Util::PixelStoreProcessor::ConvertOnePixelToInternal(
|
||||
internal, inputFormat, inputType, inputPixel, pattern)) {
|
||||
if (!MG_Util::PixelStoreProcessor::ConvertOnePixelToInternal(internal, inputFormat, inputType, inputPixel,
|
||||
pattern)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
@@ -233,8 +230,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ClearBufferRange_State(const SharedPtr<MG_State::GLState::BufferObject>& bufferObject,
|
||||
GLenum internalformat, GLintptr offset, GLsizeiptr size,
|
||||
GLenum format, GLenum type, const void* data, BufferOp op) {
|
||||
GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type,
|
||||
const void* data, BufferOp op) {
|
||||
const SizeT patternSize = GetClearPatternSize(internalformat, format, type, op);
|
||||
if (patternSize == 0) return;
|
||||
if (!ValidateBufferClearRange(bufferObject, offset, size, patternSize, op)) return;
|
||||
@@ -298,8 +295,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!MG_Config::Features.CoherentAsFlush) return accessBits;
|
||||
if (!(accessBits & BufferMappingAccessBit::FlushExplicit)) return accessBits;
|
||||
if (!(accessBits & BufferMappingAccessBit::Persistent)) return accessBits;
|
||||
accessBits = Flags<BufferMappingAccessBit>(
|
||||
accessBits.GetRaw() & ~static_cast<Uint>(BufferMappingAccessBit::FlushExplicit));
|
||||
accessBits = Flags<BufferMappingAccessBit>(accessBits.GetRaw() &
|
||||
~static_cast<Uint>(BufferMappingAccessBit::FlushExplicit));
|
||||
accessBits |= BufferMappingAccessBit::Coherent;
|
||||
return accessBits;
|
||||
}
|
||||
@@ -318,8 +315,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if ((flags & GL_MAP_PERSISTENT_BIT) && !(flags & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT))) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"GL_MAP_PERSISTENT_BIT requires GL_MAP_READ_BIT or GL_MAP_WRITE_BIT."));
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"GL_MAP_PERSISTENT_BIT requires GL_MAP_READ_BIT or GL_MAP_WRITE_BIT."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -382,9 +380,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void GetBufferParameteriv_Object(const SharedPtr<MG_State::GLState::BufferObject>& bufferObject, GLenum pname,
|
||||
GLint* params, BufferOp op) {
|
||||
if (!params) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"Params pointer cannot be null."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"Params pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -415,10 +413,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
case GL_BUFFER_ACCESS_FLAGS:
|
||||
// The MapBufferRange flags verbatim; glMapBuffer's access enum has already been
|
||||
// normalised into the same bits. Zero while the buffer is not mapped.
|
||||
*params = bufferObject->IsMapped()
|
||||
? static_cast<GLint>(
|
||||
MG_Util::ConvertBufferMappingAccessToGLEnum(bufferObject->GetMappingAccess()))
|
||||
: 0;
|
||||
*params = bufferObject->IsMapped() ? static_cast<GLint>(MG_Util::ConvertBufferMappingAccessToGLEnum(
|
||||
bufferObject->GetMappingAccess()))
|
||||
: 0;
|
||||
break;
|
||||
case GL_BUFFER_MAPPED:
|
||||
*params = bufferObject->IsMapped() ? GL_TRUE : GL_FALSE;
|
||||
@@ -437,8 +434,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
break;
|
||||
default:
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
std::format("Invalid pname enum: 0x{:X}", pname)));
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
std::format("Invalid pname enum: 0x{:X}", pname)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -446,9 +444,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void GetBufferParameteri64v_Object(const SharedPtr<MG_State::GLState::BufferObject>& bufferObject, GLenum pname,
|
||||
GLint64* params, BufferOp op) {
|
||||
if (!params) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"Params pointer cannot be null."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"Params pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -460,7 +458,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
*params = static_cast<GLint64>(bufferObject->GetMappedRange().start);
|
||||
break;
|
||||
case GL_BUFFER_MAP_LENGTH:
|
||||
*params = static_cast<GLint64>(bufferObject->GetMappedRange().end - bufferObject->GetMappedRange().start);
|
||||
*params =
|
||||
static_cast<GLint64>(bufferObject->GetMappedRange().end - bufferObject->GetMappedRange().start);
|
||||
break;
|
||||
default: {
|
||||
GLint value = 0;
|
||||
@@ -474,15 +473,16 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void GetBufferPointerv_Object(const SharedPtr<MG_State::GLState::BufferObject>& bufferObject, GLenum pname,
|
||||
void** params, BufferOp op) {
|
||||
if (!params) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"Params pointer cannot be null."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
"Params pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
if (pname != GL_BUFFER_MAP_POINTER) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
std::format("Invalid pname enum: 0x{:X}", pname)));
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", GetBufferOpName(op),
|
||||
std::format("Invalid pname enum: 0x{:X}", pname)));
|
||||
return;
|
||||
}
|
||||
*params = bufferObject->GetMappedPointer();
|
||||
@@ -577,8 +577,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// time (leaving Persistent|Coherent), so honor the app's flush on such a map as
|
||||
// a no-op: its writes reach the backend without explicit flushes. Other maps
|
||||
// keep the spec error.
|
||||
if (MG_Config::Features.CoherentAsFlush &&
|
||||
(mappingAccess & BufferMappingAccessBit::Persistent) &&
|
||||
if (MG_Config::Features.CoherentAsFlush && (mappingAccess & BufferMappingAccessBit::Persistent) &&
|
||||
(mappingAccess & BufferMappingAccessBit::Coherent)) {
|
||||
return;
|
||||
}
|
||||
@@ -690,7 +689,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
}
|
||||
|
||||
if ((accessBits & BufferMappingAccessBit::Persistent) && !(accessBits & (BufferMappingAccessBit::Read | BufferMappingAccessBit::Write))) {
|
||||
if ((accessBits & BufferMappingAccessBit::Persistent) &&
|
||||
!(accessBits & (BufferMappingAccessBit::Read | BufferMappingAccessBit::Write))) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
@@ -882,10 +882,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
SizeT bufferSize = bufferObject->GetSize();
|
||||
if (static_cast<SizeT>(offset) + static_cast<SizeT>(size) > bufferSize) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Offset and size exceed buffer size."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Offset and size exceed buffer size."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -899,9 +898,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
(offset < mappedRange.end) && (offset + size > mappedRange.start)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Cannot modify a non-persistently mapped buffer object."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Cannot modify a non-persistently mapped buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -938,15 +936,13 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
SizeT bufferSize = bufferObject->GetSize();
|
||||
if (static_cast<SizeT>(offset) + static_cast<SizeT>(size) > bufferSize) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetBufferSubData_State",
|
||||
"Offset and size exceed buffer size."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetBufferSubData_State",
|
||||
"Offset and size exceed buffer size."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (bufferObject->IsMapped() &&
|
||||
!(bufferObject->GetMappingAccess() & BufferMappingAccessBit::Persistent)) {
|
||||
if (bufferObject->IsMapped() && !(bufferObject->GetMappingAccess() & BufferMappingAccessBit::Persistent)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetBufferSubData_State",
|
||||
@@ -966,9 +962,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
if (size < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetNamedBufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetNamedBufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -977,14 +972,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
if (static_cast<SizeT>(offset) + static_cast<SizeT>(size) > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetNamedBufferSubData_State",
|
||||
"Offset and size exceed buffer size."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetNamedBufferSubData_State",
|
||||
"Offset and size exceed buffer size."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (bufferObject->IsMapped() &&
|
||||
!(bufferObject->GetMappingAccess() & BufferMappingAccessBit::Persistent)) {
|
||||
if (bufferObject->IsMapped() && !(bufferObject->GetMappingAccess() & BufferMappingAccessBit::Persistent)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetNamedBufferSubData_State",
|
||||
@@ -1049,10 +1042,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!ValidateStorageFlags(flags, BufferOp::BufferStorage)) return;
|
||||
|
||||
if (bufferObject->IsImmutableStorage()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "BufferStorage_State",
|
||||
"Buffer already has immutable storage."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "BufferStorage_State",
|
||||
"Buffer already has immutable storage."));
|
||||
return;
|
||||
}
|
||||
bufferObject->AllocateImmutableStorage(static_cast<SizeT>(size), data, flags);
|
||||
@@ -1066,10 +1058,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
if (n > 0 && !buffers) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "CreateBuffers_State",
|
||||
"Buffer output pointer cannot be null."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "CreateBuffers_State",
|
||||
"Buffer output pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1095,10 +1086,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!ValidateStorageFlags(flags, BufferOp::NamedBufferStorage)) return;
|
||||
|
||||
if (bufferObject->IsImmutableStorage()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "NamedBufferStorage_State",
|
||||
"Buffer already has immutable storage."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "NamedBufferStorage_State",
|
||||
"Buffer already has immutable storage."));
|
||||
return;
|
||||
}
|
||||
bufferObject->AllocateImmutableStorage(static_cast<SizeT>(size), data, flags);
|
||||
@@ -1132,17 +1122,15 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
void NamedBufferSubData_State(GLuint buffer, GLintptr offset, GLsizeiptr size, const void* data) {
|
||||
if (!data) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::NoError,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "NamedBufferSubData_State",
|
||||
"Data pointer cannot be null."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::NoError,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "NamedBufferSubData_State",
|
||||
"Data pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
if (size < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "NamedBufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "NamedBufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1157,10 +1145,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
if (static_cast<SizeT>(offset) + static_cast<SizeT>(size) > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "NamedBufferSubData_State",
|
||||
"Offset and size exceed buffer size."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "NamedBufferSubData_State",
|
||||
"Offset and size exceed buffer size."));
|
||||
return;
|
||||
}
|
||||
const auto mappingAccess = bufferObject->GetMappingAccess();
|
||||
@@ -1181,9 +1168,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
GLsizeiptr size) {
|
||||
if (size < 0 || readOffset < 0 || writeOffset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "CopyNamedBufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "CopyNamedBufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1229,23 +1215,24 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void ClearBufferData_State(GLenum target, GLenum internalformat, GLenum format, GLenum type, const void* data) {
|
||||
auto bufferObject = GetBoundBufferObject(target, BufferOp::ClearBufferData);
|
||||
if (!bufferObject) return;
|
||||
ClearBufferRange_State(bufferObject, internalformat, 0, static_cast<GLsizeiptr>(bufferObject->GetSize()), format,
|
||||
type, data, BufferOp::ClearBufferData);
|
||||
ClearBufferRange_State(bufferObject, internalformat, 0, static_cast<GLsizeiptr>(bufferObject->GetSize()),
|
||||
format, type, data, BufferOp::ClearBufferData);
|
||||
}
|
||||
|
||||
void ClearBufferSubData_State(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size,
|
||||
GLenum format, GLenum type, const void* data) {
|
||||
void ClearBufferSubData_State(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format,
|
||||
GLenum type, const void* data) {
|
||||
auto bufferObject = GetBoundBufferObject(target, BufferOp::ClearBufferSubData);
|
||||
if (!bufferObject) return;
|
||||
ClearBufferRange_State(bufferObject, internalformat, offset, size, format, type, data,
|
||||
BufferOp::ClearBufferSubData);
|
||||
}
|
||||
|
||||
void ClearNamedBufferData_State(GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void* data) {
|
||||
void ClearNamedBufferData_State(GLuint buffer, GLenum internalformat, GLenum format, GLenum type,
|
||||
const void* data) {
|
||||
auto bufferObject = GetNamedBufferObject(buffer, BufferOp::ClearNamedBufferData);
|
||||
if (!bufferObject) return;
|
||||
ClearBufferRange_State(bufferObject, internalformat, 0, static_cast<GLsizeiptr>(bufferObject->GetSize()), format,
|
||||
type, data, BufferOp::ClearNamedBufferData);
|
||||
ClearBufferRange_State(bufferObject, internalformat, 0, static_cast<GLsizeiptr>(bufferObject->GetSize()),
|
||||
format, type, data, BufferOp::ClearNamedBufferData);
|
||||
}
|
||||
|
||||
void ClearNamedBufferSubData_State(GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size,
|
||||
@@ -1291,23 +1278,20 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
if (length < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "MapNamedBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "MapNamedBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
return nullptr;
|
||||
}
|
||||
if (length == 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "MapNamedBufferRange_State",
|
||||
"Length must be greater than zero."));
|
||||
ErrorCode::InvalidOperation, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "MapNamedBufferRange_State",
|
||||
"Length must be greater than zero."));
|
||||
return nullptr;
|
||||
}
|
||||
if (static_cast<SizeT>(offset) + static_cast<SizeT>(length) > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "MapNamedBufferRange_State",
|
||||
"Offset and length exceed buffer size."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "MapNamedBufferRange_State",
|
||||
"Offset and length exceed buffer size."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1326,8 +1310,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (accessBits & invalidFlags) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "MapNamedBufferRange_State",
|
||||
"GL_MAP_READ_BIT cannot be combined with invalidation or unsynchronized flags."));
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "MapNamedBufferRange_State",
|
||||
"GL_MAP_READ_BIT cannot be combined with invalidation or unsynchronized flags."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -1338,7 +1323,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
"GL_MAP_FLUSH_EXPLICIT_BIT requires GL_MAP_WRITE_BIT."));
|
||||
return nullptr;
|
||||
}
|
||||
if ((accessBits & BufferMappingAccessBit::Persistent) && !(accessBits & (BufferMappingAccessBit::Read | BufferMappingAccessBit::Write))) {
|
||||
if ((accessBits & BufferMappingAccessBit::Persistent) &&
|
||||
!(accessBits & (BufferMappingAccessBit::Read | BufferMappingAccessBit::Write))) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "MapNamedBufferRange_State",
|
||||
@@ -1388,10 +1374,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
auto bufferObject = GetNamedBufferObject(buffer, BufferOp::FlushMappedNamedBufferRange);
|
||||
if (!bufferObject) return;
|
||||
if (length < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedNamedBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl",
|
||||
"FlushMappedNamedBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
return;
|
||||
}
|
||||
if (!bufferObject->IsMapped()) {
|
||||
@@ -1403,25 +1389,25 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
const auto mappedRange = bufferObject->GetMappedRange();
|
||||
if (static_cast<SizeT>(offset) + static_cast<SizeT>(length) > mappedRange.end - mappedRange.start) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedNamedBufferRange_State",
|
||||
"Offset and length exceed mapped range."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl",
|
||||
"FlushMappedNamedBufferRange_State",
|
||||
"Offset and length exceed mapped range."));
|
||||
return;
|
||||
}
|
||||
const auto namedMappingAccess = bufferObject->GetMappingAccess();
|
||||
if (!(namedMappingAccess & BufferMappingAccessBit::FlushExplicit)) {
|
||||
// See FlushMappedBufferRange_State: rewritten coherent-as-flush persistent maps
|
||||
// tolerate app flushes as no-ops.
|
||||
if (MG_Config::Features.CoherentAsFlush &&
|
||||
(namedMappingAccess & BufferMappingAccessBit::Persistent) &&
|
||||
if (MG_Config::Features.CoherentAsFlush && (namedMappingAccess & BufferMappingAccessBit::Persistent) &&
|
||||
(namedMappingAccess & BufferMappingAccessBit::Coherent)) {
|
||||
return;
|
||||
}
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedNamedBufferRange_State",
|
||||
"Cannot flush a buffer object that is not mapped with GL_MAP_FLUSH_EXPLICIT_BIT."));
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "FlushMappedNamedBufferRange_State",
|
||||
"Cannot flush a buffer object that is not mapped with GL_MAP_FLUSH_EXPLICIT_BIT."));
|
||||
return;
|
||||
}
|
||||
bufferObject->FlushMemoryRange(static_cast<SizeT>(offset), static_cast<SizeT>(length));
|
||||
@@ -1548,8 +1534,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// They apply only to a non-zero buffer: buffer 0 detaches the binding point and ignores
|
||||
// offset and size, which is also how glBindBuffersRange spells "reset this element"
|
||||
// (a NULL buffers array, or a zero entry inside one).
|
||||
static Bool ValidateBufferRangeOffsetAndSize(GLenum target, GLintptr offset, GLsizeiptr size,
|
||||
const char* funcName, Bool hasBuffer = true) {
|
||||
static Bool ValidateBufferRangeOffsetAndSize(GLenum target, GLintptr offset, GLsizeiptr size, const char* funcName,
|
||||
Bool hasBuffer = true) {
|
||||
if (hasBuffer && size <= 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
@@ -1578,10 +1564,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (alignment > 0 && (offset % static_cast<GLintptr>(alignment)) != 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", funcName,
|
||||
std::format("offset ({}) must be a multiple of {} ({}).", offset,
|
||||
MG_Util::ConvertGLEnumToString(alignmentQuery), alignment)));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", funcName,
|
||||
std::format("offset ({}) must be a multiple of {} ({}).", offset,
|
||||
MG_Util::ConvertGLEnumToString(alignmentQuery),
|
||||
alignment)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ namespace MobileGL::MG_Impl::GLImpl::BufferImpl {
|
||||
Bool ValidateBufferBindingPointRange(BufferTarget target, Uint first, GLsizei count, const char* funcName) {
|
||||
if (count < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", funcName,
|
||||
"count must be non-negative."));
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", funcName, "count must be non-negative."));
|
||||
return false;
|
||||
}
|
||||
const SizeT pointCount = GetBufferBindingPointLimit(target);
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (effective < limit) {
|
||||
return true;
|
||||
}
|
||||
RecordDebugError(ErrorCode::InvalidValue, caller,
|
||||
std::format("{} length {} is not less than the {} limit of {}.", what, effective, what,
|
||||
limit));
|
||||
RecordDebugError(
|
||||
ErrorCode::InvalidValue, caller,
|
||||
std::format("{} length {} is not less than the {} limit of {}.", what, effective, what, limit));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -163,8 +163,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
state.groupStack.pop_back();
|
||||
}
|
||||
|
||||
void DebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
|
||||
const GLchar* buf) {
|
||||
void DebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf) {
|
||||
static_cast<void>(id);
|
||||
if (!ValidateInjectedSource(source, __func__)) return;
|
||||
switch (type) {
|
||||
@@ -180,8 +179,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
break;
|
||||
default:
|
||||
RecordDebugError(ErrorCode::InvalidEnum, __func__,
|
||||
std::format("type {} is not a debug message type.",
|
||||
MG_Util::ConvertGLEnumToString(type)));
|
||||
std::format("type {} is not a debug message type.", MG_Util::ConvertGLEnumToString(type)));
|
||||
return;
|
||||
}
|
||||
switch (severity) {
|
||||
@@ -191,9 +189,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
case GL_DEBUG_SEVERITY_NOTIFICATION:
|
||||
break;
|
||||
default:
|
||||
RecordDebugError(ErrorCode::InvalidEnum, __func__,
|
||||
std::format("severity {} is not a debug message severity.",
|
||||
MG_Util::ConvertGLEnumToString(severity)));
|
||||
RecordDebugError(
|
||||
ErrorCode::InvalidEnum, __func__,
|
||||
std::format("severity {} is not a debug message severity.", MG_Util::ConvertGLEnumToString(severity)));
|
||||
return;
|
||||
}
|
||||
if (!ValidateDebugStringLength(length, buf, kMaxDebugMessageLength, __func__, "message")) return;
|
||||
|
||||
@@ -31,8 +31,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// specifies), and a label written with glObjectLabel comes back from glGetObjectLabel.
|
||||
void PushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar* message);
|
||||
void PopDebugGroup();
|
||||
void DebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
|
||||
const GLchar* buf);
|
||||
void DebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf);
|
||||
void ObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar* label);
|
||||
void GetObjectLabel(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar* label);
|
||||
|
||||
|
||||
@@ -34,9 +34,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
if (!currentProgram->GetLinkStatus()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"The current program object is not linked."));
|
||||
ErrorCode::InvalidOperation, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"The current program object is not linked."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -165,13 +164,19 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
static Uint64 CountPrimitivesForDraw(GLenum mode, GLsizei count) {
|
||||
if (count <= 0) return 0;
|
||||
switch (mode) {
|
||||
case GL_POINTS: return static_cast<Uint64>(count);
|
||||
case GL_LINES: return static_cast<Uint64>(count / 2);
|
||||
case GL_LINE_STRIP: return count >= 2 ? static_cast<Uint64>(count - 1) : 0;
|
||||
case GL_LINE_LOOP: return count >= 2 ? static_cast<Uint64>(count) : 0;
|
||||
case GL_TRIANGLES: return static_cast<Uint64>(count / 3);
|
||||
case GL_POINTS:
|
||||
return static_cast<Uint64>(count);
|
||||
case GL_LINES:
|
||||
return static_cast<Uint64>(count / 2);
|
||||
case GL_LINE_STRIP:
|
||||
return count >= 2 ? static_cast<Uint64>(count - 1) : 0;
|
||||
case GL_LINE_LOOP:
|
||||
return count >= 2 ? static_cast<Uint64>(count) : 0;
|
||||
case GL_TRIANGLES:
|
||||
return static_cast<Uint64>(count / 3);
|
||||
case GL_TRIANGLE_STRIP:
|
||||
case GL_TRIANGLE_FAN: return count >= 3 ? static_cast<Uint64>(count - 2) : 0;
|
||||
case GL_TRIANGLE_FAN:
|
||||
return count >= 3 ? static_cast<Uint64>(count - 2) : 0;
|
||||
// Adjacency primitives (GL 4.6 core table 10.1). Only a geometry stage can consume
|
||||
// them, and it is the ADJACENT-free primitive count that reaches it: 4 vertices per
|
||||
// line, 6 per triangle, one per step for the strips. Answering 0 here - which is what
|
||||
@@ -179,14 +184,19 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// recorded anything, so an adjacency capture advanced neither the captured-vertex
|
||||
// counter the scattered-capture path is bounded by nor the geometry-capture-draw flag
|
||||
// that routes the transform feedback queries to the driver's own counter.
|
||||
case GL_LINES_ADJACENCY: return static_cast<Uint64>(count / 4);
|
||||
case GL_LINE_STRIP_ADJACENCY: return count >= 4 ? static_cast<Uint64>(count - 3) : 0;
|
||||
case GL_TRIANGLES_ADJACENCY: return static_cast<Uint64>(count / 6);
|
||||
case GL_TRIANGLE_STRIP_ADJACENCY: return count >= 6 ? static_cast<Uint64>((count - 4) / 2) : 0;
|
||||
case GL_LINES_ADJACENCY:
|
||||
return static_cast<Uint64>(count / 4);
|
||||
case GL_LINE_STRIP_ADJACENCY:
|
||||
return count >= 4 ? static_cast<Uint64>(count - 3) : 0;
|
||||
case GL_TRIANGLES_ADJACENCY:
|
||||
return static_cast<Uint64>(count / 6);
|
||||
case GL_TRIANGLE_STRIP_ADJACENCY:
|
||||
return count >= 6 ? static_cast<Uint64>((count - 4) / 2) : 0;
|
||||
// GL_PATCHES is deliberately absent: the tessellator's amplification is not knowable
|
||||
// on the CPU, and answering 0 is what defers GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
|
||||
// to the driver's own counter, which is the only correct source for a patch capture.
|
||||
default: return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,8 +252,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
for (SizeT i = 0; i < program->GetTransformFeedbackBufferCount(); ++i) {
|
||||
const Uint32 stride = program->GetTransformFeedbackStride(static_cast<Uint32>(i));
|
||||
if (stride == 0) continue;
|
||||
const auto& point = MG_State::pGLContext->GetBufferBindingPoint(BufferTarget::TransformFeedback,
|
||||
static_cast<Uint>(i));
|
||||
const auto& point =
|
||||
MG_State::pGLContext->GetBufferBindingPoint(BufferTarget::TransformFeedback, static_cast<Uint>(i));
|
||||
const Range1D range = point.GetRange();
|
||||
const Uint64 bytes = range.end > range.start ? static_cast<Uint64>(range.end - range.start) : 0;
|
||||
capacityVertices = std::min<Uint64>(capacityVertices, bytes / stride);
|
||||
@@ -317,8 +327,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (vao && vao->GetExternalIndex() == 0 && !MG_State::IsRelaxedSemanticsActive()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"Default vertex array object cannot be used for drawing in core profile."));
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", functionName,
|
||||
"Default vertex array object cannot be used for drawing in core profile."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -419,8 +430,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const Bool feedbackModeIsProgramDriven =
|
||||
feedbackProgram && (feedbackProgram->HasLinkedShaderStage(ShaderStage::Geometry) ||
|
||||
feedbackProgram->HasLinkedShaderStage(ShaderStage::TessEval));
|
||||
if (MG_State::pGLContext->IsTransformFeedbackActive() &&
|
||||
!MG_State::pGLContext->IsTransformFeedbackPaused() && !feedbackModeIsProgramDriven) {
|
||||
if (MG_State::pGLContext->IsTransformFeedbackActive() && !MG_State::pGLContext->IsTransformFeedbackPaused() &&
|
||||
!feedbackModeIsProgramDriven) {
|
||||
const GLenum feedbackMode = MG_State::pGLContext->GetTransformFeedbackPrimitiveMode();
|
||||
Bool compatible = false;
|
||||
switch (feedbackMode) {
|
||||
@@ -469,10 +480,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
static Bool ValidateIndirectDrawSource(const char* functionName, const void* indirect, SizeT commandBytes) {
|
||||
const auto offset = reinterpret_cast<uintptr_t>(indirect);
|
||||
if (offset % 4 != 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"indirect offset must be a multiple of 4."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"indirect offset must be a multiple of 4."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -518,9 +528,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
static Bool ValidateNonNegativeDrawArgument(const char* functionName, const char* argumentName, GLsizei value) {
|
||||
if (value >= 0) return true;
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
String(argumentName) + " must be non-negative."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
String(argumentName) + " must be non-negative."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -857,9 +866,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
GetIntegerv(GL_MAX_PATCH_VERTICES, &maxPatchVertices);
|
||||
if (value <= 0 || value > maxPatchVertices) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"value must be in [1, GL_MAX_PATCH_VERTICES]."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"value must be in [1, GL_MAX_PATCH_VERTICES]."));
|
||||
return;
|
||||
}
|
||||
MG_State::pGLContext->SetPatchVertices(static_cast<Uint>(value));
|
||||
@@ -893,8 +901,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
if (pname == GL_PATCH_DEFAULT_OUTER_LEVEL) {
|
||||
MG_State::pGLContext->SetPatchDefaultOuterLevel(
|
||||
FloatVec4(values[0], values[1], values[2], values[3]));
|
||||
MG_State::pGLContext->SetPatchDefaultOuterLevel(FloatVec4(values[0], values[1], values[2], values[3]));
|
||||
} else {
|
||||
MG_State::pGLContext->SetPatchDefaultInnerLevel(FloatVec2(values[0], values[1]));
|
||||
}
|
||||
@@ -1007,8 +1014,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// lies past its end INVALID_OPERATION
|
||||
// * maxdrawcount commands from `indirect` run past the end of the
|
||||
// buffer bound to DRAW_INDIRECT_BUFFER INVALID_OPERATION
|
||||
static Bool ValidateIndirectCountDraw(GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount,
|
||||
GLsizei stride, SizeT commandSize, const char* funcName) {
|
||||
static Bool ValidateIndirectCountDraw(GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride,
|
||||
SizeT commandSize, const char* funcName) {
|
||||
if (drawcount < 0 || (drawcount % 4) != 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
@@ -1018,8 +1025,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
const auto& parameterBuffer =
|
||||
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Parameter).GetBoundObject();
|
||||
if (!parameterBuffer ||
|
||||
static_cast<SizeT>(drawcount) + sizeof(Uint32) > parameterBuffer->GetSize()) {
|
||||
if (!parameterBuffer || static_cast<SizeT>(drawcount) + sizeof(Uint32) > parameterBuffer->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", funcName,
|
||||
@@ -1039,9 +1045,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::DrawIndirect).GetBoundObject();
|
||||
// A zero maxdrawcount sources nothing, so it cannot run past anything.
|
||||
const SizeT requiredBytes =
|
||||
maxdrawcount == 0 ? 0
|
||||
: static_cast<SizeT>(indirect) +
|
||||
static_cast<SizeT>(maxdrawcount - 1) * effectiveStride + commandSize;
|
||||
maxdrawcount == 0
|
||||
? 0
|
||||
: static_cast<SizeT>(indirect) + static_cast<SizeT>(maxdrawcount - 1) * effectiveStride + commandSize;
|
||||
if (!indirectBuffer || requiredBytes > indirectBuffer->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
@@ -1083,8 +1089,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
MultiDrawElementsIndirectCount_Backend(mode, type, indirect, drawcount, maxdrawcount, stride);
|
||||
}
|
||||
|
||||
void MultiDrawArraysIndirectCount(GLenum mode, const void* indirect, GLintptr drawcount,
|
||||
GLsizei maxdrawcount, GLsizei stride) {
|
||||
void MultiDrawArraysIndirectCount(GLenum mode, const void* indirect, GLintptr drawcount, GLsizei maxdrawcount,
|
||||
GLsizei stride) {
|
||||
// Argument validation before the backend-availability check: see DispatchComputeIndirect.
|
||||
// DrawArraysIndirectCommand: count, instanceCount, first, baseInstance.
|
||||
if (!ValidateIndirectCountDraw(reinterpret_cast<GLintptr>(indirect), drawcount, maxdrawcount, stride,
|
||||
@@ -1279,9 +1285,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!program || !program->GetLinkStatus() || program->GetTransformFeedbackVaryingCount() == 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", __func__,
|
||||
"No program with transform feedback varyings is active."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"No program with transform feedback varyings is active."));
|
||||
return;
|
||||
}
|
||||
// Every capture buffer slot the program's mode uses must have a buffer bound. A slot
|
||||
@@ -1290,14 +1295,14 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const SizeT usedBufferCount = program->GetTransformFeedbackBufferCount();
|
||||
for (SizeT i = 0; i < usedBufferCount; ++i) {
|
||||
if (program->GetTransformFeedbackStride(static_cast<Uint32>(i)) == 0) continue;
|
||||
const auto& point = MG_State::pGLContext->GetBufferBindingPoint(BufferTarget::TransformFeedback,
|
||||
static_cast<Uint>(i));
|
||||
const auto& point =
|
||||
MG_State::pGLContext->GetBufferBindingPoint(BufferTarget::TransformFeedback, static_cast<Uint>(i));
|
||||
if (point.GetBoundObject() == nullptr) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", __func__,
|
||||
"Transform feedback buffer binding point " + std::to_string(i) + " has no buffer bound."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"Transform feedback buffer binding point " + std::to_string(i) +
|
||||
" has no buffer bound."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1352,9 +1357,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
for (SizeT bufferIndex = 0; bufferIndex < program->GetTransformFeedbackBufferCount(); ++bufferIndex) {
|
||||
const Uint32 stride = program->GetTransformFeedbackStride(static_cast<Uint32>(bufferIndex));
|
||||
if (stride == 0) continue;
|
||||
const auto& bindingPoint =
|
||||
MG_State::pGLContext->GetBufferBindingPoint(BufferTarget::TransformFeedback,
|
||||
static_cast<Uint>(bufferIndex));
|
||||
const auto& bindingPoint = MG_State::pGLContext->GetBufferBindingPoint(BufferTarget::TransformFeedback,
|
||||
static_cast<Uint>(bufferIndex));
|
||||
const auto& buffer = bindingPoint.GetBoundObject();
|
||||
if (buffer == nullptr) continue;
|
||||
// This fixup READS the captured bytes back through the shadow, so it is the one
|
||||
@@ -1426,8 +1430,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// shape a verb barrier cannot make cheap, because it is the driver's wait and not the
|
||||
// barrier's.
|
||||
auto& backendGL = MG_Backend::gBackendFunctionsTable.GL;
|
||||
const Bool waitForTheCapture =
|
||||
MG_Config::Transport == MG_Config::TransportMode::Monolith;
|
||||
const Bool waitForTheCapture = MG_Config::Transport == MG_Config::TransportMode::Monolith;
|
||||
if (waitForTheCapture && backendGL.FenceSync && backendGL.ClientWaitSync) {
|
||||
MGP_FILL(FenceSync);
|
||||
if (auto sync = backendGL.FenceSync()) {
|
||||
@@ -1443,8 +1446,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void PauseTransformFeedback(void) {
|
||||
if (!MG_State::pGLContext->IsTransformFeedbackActive() ||
|
||||
MG_State::pGLContext->IsTransformFeedbackPaused()) {
|
||||
if (!MG_State::pGLContext->IsTransformFeedbackActive() || MG_State::pGLContext->IsTransformFeedbackPaused()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
@@ -1459,8 +1461,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ResumeTransformFeedback(void) {
|
||||
if (!MG_State::pGLContext->IsTransformFeedbackActive() ||
|
||||
!MG_State::pGLContext->IsTransformFeedbackPaused()) {
|
||||
if (!MG_State::pGLContext->IsTransformFeedbackActive() || !MG_State::pGLContext->IsTransformFeedbackPaused()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "Transform feedback is not paused."));
|
||||
@@ -1542,7 +1543,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
SharedPtr<MG_State::GLState::BufferObject> ResolveTransformFeedbackBuffer(GLuint buffer,
|
||||
const char* functionName) {
|
||||
const char* functionName) {
|
||||
if (buffer == 0) return nullptr;
|
||||
if (!MG_State::pGLContext->ValidateBufferName(buffer)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
@@ -1566,9 +1567,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
std::to_string(buffer) + " is not a buffer object."));
|
||||
return;
|
||||
}
|
||||
MG_State::pGLContext->SetNamedTransformFeedbackBinding(xfb, index,
|
||||
ResolveTransformFeedbackBuffer(buffer, __func__), {},
|
||||
false);
|
||||
MG_State::pGLContext->SetNamedTransformFeedbackBinding(
|
||||
xfb, index, ResolveTransformFeedbackBuffer(buffer, __func__), {}, false);
|
||||
}
|
||||
|
||||
void TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) {
|
||||
@@ -1689,8 +1689,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
// A running capture pins its object; only a paused one may be swapped out.
|
||||
if (MG_State::pGLContext->IsTransformFeedbackActive() &&
|
||||
!MG_State::pGLContext->IsTransformFeedbackPaused()) {
|
||||
if (MG_State::pGLContext->IsTransformFeedbackActive() && !MG_State::pGLContext->IsTransformFeedbackPaused()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void MultiDrawArraysIndirect(GLenum mode, const void* indirect, GLsizei drawcount, GLsizei stride);
|
||||
void MultiDrawElementsIndirectCount(GLenum mode, GLenum type, const void* indirect, GLintptr drawcount,
|
||||
GLsizei maxdrawcount, GLsizei stride);
|
||||
void MultiDrawArraysIndirectCount(GLenum mode, const void* indirect, GLintptr drawcount,
|
||||
GLsizei maxdrawcount, GLsizei stride);
|
||||
void MultiDrawArraysIndirectCount(GLenum mode, const void* indirect, GLintptr drawcount, GLsizei maxdrawcount,
|
||||
GLsizei stride);
|
||||
void DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type,
|
||||
const void* indices, GLint basevertex);
|
||||
void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices);
|
||||
|
||||
@@ -59,8 +59,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
const auto& depthAttachment = framebufferObject.GetAttachment(FramebufferAttachmentType::Depth);
|
||||
const auto& stencilAttachment = framebufferObject.GetAttachment(FramebufferAttachmentType::Stencil);
|
||||
if (!depthAttachment.IsComplete() || !stencilAttachment.IsComplete() ||
|
||||
!depthAttachment.IsTexture() || !stencilAttachment.IsTexture()) {
|
||||
if (!depthAttachment.IsComplete() || !stencilAttachment.IsComplete() || !depthAttachment.IsTexture() ||
|
||||
!stencilAttachment.IsTexture()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -214,9 +214,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void RecordUnsupportedFramebufferTextureAttachmentError(const char* functionName, const char* detail) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName, detail));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName, detail));
|
||||
}
|
||||
|
||||
GLint ClassifyAttachmentComponentType(TextureInternalFormat internalFormat,
|
||||
@@ -290,10 +289,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const auto reject = [&]() {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", caller,
|
||||
std::format("Attachment {} is not queryable on this framebuffer.",
|
||||
MG_Util::ConvertGLEnumToString(attachment))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
std::format("Attachment {} is not queryable on this framebuffer.",
|
||||
MG_Util::ConvertGLEnumToString(attachment))));
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -354,10 +352,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", caller,
|
||||
std::format("pname {} is only defined for a texture attachment.",
|
||||
MG_Util::ConvertGLEnumToString(pname))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
std::format("pname {} is only defined for a texture attachment.",
|
||||
MG_Util::ConvertGLEnumToString(pname))));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -385,10 +382,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// attachment name has no single answer.
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", caller,
|
||||
"GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE cannot be queried on "
|
||||
"GL_DEPTH_STENCIL_ATTACHMENT."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
"GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE cannot be queried on "
|
||||
"GL_DEPTH_STENCIL_ATTACHMENT."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -431,8 +427,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
|
||||
*params = (internalFormat == TextureInternalFormat::SRGB8 ||
|
||||
internalFormat == TextureInternalFormat::SRGB8Alpha8)
|
||||
? GL_SRGB
|
||||
: GL_LINEAR;
|
||||
? GL_SRGB
|
||||
: GL_LINEAR;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
|
||||
*params = ClassifyAttachmentComponentType(internalFormat, attachmentType);
|
||||
@@ -498,10 +494,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// one another in that section and a CTS case that walks the family must not get five
|
||||
// different answers - which is exactly what happened when these lived in one helper that
|
||||
// only two of the five went through.
|
||||
Bool ValidateFramebufferTextureAttachmentPoint(const char* functionName,
|
||||
const SharedPtr<MG_State::GLState::FramebufferObject>&
|
||||
framebufferObject,
|
||||
FramebufferAttachmentType attachmentType) {
|
||||
Bool ValidateFramebufferTextureAttachmentPoint(
|
||||
const char* functionName, const SharedPtr<MG_State::GLState::FramebufferObject>& framebufferObject,
|
||||
FramebufferAttachmentType attachmentType) {
|
||||
// "An INVALID_OPERATION error is generated if COLOR_ATTACHMENTm is used with m greater
|
||||
// than or equal to MAX_COLOR_ATTACHMENTS."
|
||||
if (!FramebufferImpl::ValidateColorAttachmentInRange(attachmentType, functionName)) return false;
|
||||
@@ -533,10 +528,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const SharedPtr<MG_State::GLState::ITextureObject>& textureObject,
|
||||
GLint level) {
|
||||
if (level < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"Texture level must be non-negative."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"Texture level must be non-negative."));
|
||||
return false;
|
||||
}
|
||||
if (!textureObject || !textureObject->IsImmutable()) {
|
||||
@@ -585,13 +579,14 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// texture_cube_map_array.stencil_attachments_*_layered and
|
||||
// geometry_shader.layered_framebuffer.stencil_support are built on.
|
||||
AttachFramebufferTextureWithUploadTarget(functionName, target, GL_DEPTH_ATTACHMENT, texture, level,
|
||||
textureUploadTarget, layered);
|
||||
textureUploadTarget, layered);
|
||||
AttachFramebufferTextureWithUploadTarget(functionName, target, GL_STENCIL_ATTACHMENT, texture, level,
|
||||
textureUploadTarget, layered);
|
||||
textureUploadTarget, layered);
|
||||
return;
|
||||
}
|
||||
|
||||
const FramebufferAttachmentType attachmentType = MG_Util::ConvertGLEnumToFramebufferAttachmentType(attachment);
|
||||
const FramebufferAttachmentType attachmentType =
|
||||
MG_Util::ConvertGLEnumToFramebufferAttachmentType(attachment);
|
||||
const FramebufferTarget framebufferTarget = MG_Util::ConvertGLEnumToFramebufferTarget(target);
|
||||
if (!FramebufferImpl::ValidateFramebufferAttachmentType(attachmentType)) return;
|
||||
if (!FramebufferImpl::ValidateFramebufferTarget(framebufferTarget)) return;
|
||||
@@ -679,8 +674,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
PipePublishFramebufferByName(readFramebuffer);
|
||||
PipePublishFramebufferByName(drawFramebuffer);
|
||||
MGP_FILL(BlitNamedFramebuffer);
|
||||
blitNamedFramebuffer(readFramebuffer, drawFramebuffer, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1,
|
||||
dstY1, mask, filter);
|
||||
blitNamedFramebuffer(readFramebuffer, drawFramebuffer, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
|
||||
mask, filter);
|
||||
}
|
||||
|
||||
void ClearNamedFramebufferfv_Backend(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer,
|
||||
@@ -791,10 +786,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
GLenum normalizedInternalFormat = MG_Util::ConvertTextureInternalFormatToGLEnum(format);
|
||||
GLenum normalizedFormat = GL_RGBA;
|
||||
GLenum normalizedType = GL_UNSIGNED_BYTE;
|
||||
MG_Util::TextureFormatProcessor::NormalizePixelFormat(normalizedInternalFormat,
|
||||
PixelFormatNormalizeOptionBit::None,
|
||||
&normalizedInternalFormat, &normalizedFormat,
|
||||
&normalizedType);
|
||||
MG_Util::TextureFormatProcessor::NormalizePixelFormat(
|
||||
normalizedInternalFormat, PixelFormatNormalizeOptionBit::None, &normalizedInternalFormat, &normalizedFormat,
|
||||
&normalizedType);
|
||||
const Bool isIntegerFormat = normalizedFormat == GL_RED_INTEGER || normalizedFormat == GL_RG_INTEGER ||
|
||||
normalizedFormat == GL_RGB_INTEGER || normalizedFormat == GL_RGBA_INTEGER;
|
||||
// The per-format probe first, for the same reason the texture path takes it first: GL 4.6
|
||||
@@ -913,7 +907,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!FramebufferImpl::ValidateRenderbufferTarget(rbTarget)) return;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetRenderbufferBindingSlot(rbTarget);
|
||||
auto& renderbufferObject = bindingSlot.GetBoundObject();
|
||||
AllocateRenderbufferStorage_State(renderbufferObject, internalformat, width, height, "RenderbufferStorage_State");
|
||||
AllocateRenderbufferStorage_State(renderbufferObject, internalformat, width, height,
|
||||
"RenderbufferStorage_State");
|
||||
}
|
||||
|
||||
GLboolean IsRenderbuffer_State(GLuint renderbuffer) {
|
||||
@@ -950,8 +945,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
const Bool depthStencilAlias = attachment == GL_DEPTH_STENCIL_ATTACHMENT;
|
||||
FramebufferAttachmentType attachmentType = depthStencilAlias
|
||||
? FramebufferAttachmentType::Depth
|
||||
: MG_Util::ConvertGLEnumToFramebufferAttachmentType(attachment);
|
||||
? FramebufferAttachmentType::Depth
|
||||
: MG_Util::ConvertGLEnumToFramebufferAttachmentType(attachment);
|
||||
if (!FramebufferImpl::ValidateFramebufferAttachmentType(attachmentType)) return;
|
||||
|
||||
Bool depthStencilMismatch = false;
|
||||
@@ -965,7 +960,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const Bool depthLive = depthAttachment.IsValid() && !depthAttachment.IsEmpty();
|
||||
const Bool stencilLive = stencilAttachment.IsValid() && !stencilAttachment.IsEmpty();
|
||||
if (depthLive && stencilLive) {
|
||||
const Bool sameObject = depthAttachment.IsTexture() == stencilAttachment.IsTexture() &&
|
||||
const Bool sameObject =
|
||||
depthAttachment.IsTexture() == stencilAttachment.IsTexture() &&
|
||||
(!depthAttachment.IsTexture() || depthAttachment.GetTexture() == stencilAttachment.GetTexture()) &&
|
||||
(!depthAttachment.IsRenderbuffer() ||
|
||||
depthAttachment.GetRenderbuffer() == stencilAttachment.GetRenderbuffer());
|
||||
@@ -1017,8 +1013,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
break;
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
|
||||
*params = (attachmentObject != nullptr && attachmentObject->IsTexture() && attachmentObject->IsValid())
|
||||
? static_cast<GLint>(attachmentObject->GetTextureLevel())
|
||||
: 0;
|
||||
? static_cast<GLint>(attachmentObject->GetTextureLevel())
|
||||
: 0;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
|
||||
if (attachmentObject != nullptr && attachmentObject->IsTexture() && attachmentObject->IsValid()) {
|
||||
@@ -1043,14 +1039,14 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
break;
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
|
||||
*params = (attachmentObject != nullptr && attachmentObject->IsTexture() && attachmentObject->IsValid())
|
||||
? static_cast<GLint>(attachmentObject->GetTextureLayer())
|
||||
: 0;
|
||||
? static_cast<GLint>(attachmentObject->GetTextureLayer())
|
||||
: 0;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_LAYERED:
|
||||
*params = (attachmentObject != nullptr && attachmentObject->IsTexture() && attachmentObject->IsValid() &&
|
||||
attachmentObject->IsLayered())
|
||||
? GL_TRUE
|
||||
: GL_FALSE;
|
||||
? GL_TRUE
|
||||
: GL_FALSE;
|
||||
break;
|
||||
default:
|
||||
if (TryAnswerAttachmentFormatQuery(attachmentObject, attachmentType, depthStencilAlias, pname, params,
|
||||
@@ -1087,9 +1083,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
if (n > 0 && !renderbuffers) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "CreateRenderbuffers_State",
|
||||
"Renderbuffer output pointer cannot be null."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "CreateRenderbuffers_State",
|
||||
"Renderbuffer output pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1102,7 +1097,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
SharedPtr<MG_State::GLState::RenderbufferObject> GetNamedRenderbufferObject_State(GLuint renderbuffer,
|
||||
const char* caller) {
|
||||
const char* caller) {
|
||||
if (!FramebufferImpl::ValidateRenderbufferName(renderbuffer, false)) return nullptr;
|
||||
|
||||
auto& renderbufferObject = MG_State::pGLContext->GetRenderbufferObject(renderbuffer);
|
||||
@@ -1161,9 +1156,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
if (n > 0 && !framebuffers) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "CreateFramebuffers_State",
|
||||
"Framebuffer output pointer cannot be null."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "CreateFramebuffers_State",
|
||||
"Framebuffer output pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1176,7 +1170,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
SharedPtr<MG_State::GLState::FramebufferObject> GetNamedFramebufferObject_State(GLuint framebuffer,
|
||||
const char* caller) {
|
||||
const char* caller) {
|
||||
if (!FramebufferImpl::ValidateFramebufferName(framebuffer, false)) return nullptr;
|
||||
|
||||
auto& framebufferObject = MG_State::pGLContext->GetFramebufferObject(framebuffer);
|
||||
@@ -1311,9 +1305,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
if (textarget != GL_TEXTURE_3D) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"FramebufferTexture3D requires GL_TEXTURE_3D."));
|
||||
ErrorCode::InvalidEnum, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"FramebufferTexture3D requires GL_TEXTURE_3D."));
|
||||
return;
|
||||
}
|
||||
AttachFramebufferTextureLayer(__func__, target, attachment, texture, level, zoffset,
|
||||
@@ -1376,15 +1369,13 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!ValidateFramebufferTextureLevel("FramebufferTexture2D_State", textureObject, level)) return;
|
||||
|
||||
const auto expectedTextureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadTarget);
|
||||
if (expectedTextureTarget == TextureTarget::Unknown ||
|
||||
textureObject->GetTarget() != expectedTextureTarget) {
|
||||
if (expectedTextureTarget == TextureTarget::Unknown || textureObject->GetTarget() != expectedTextureTarget) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "FramebufferTexture2D_State",
|
||||
std::format("Attachment target {} does not match texture {} target {}.",
|
||||
MG_Util::ConvertGLEnumToString(textarget),
|
||||
texture,
|
||||
MG_Util::ConvertGLEnumToString(textarget), texture,
|
||||
MG_Util::ConvertTextureTargetToString(textureObject->GetTarget()))));
|
||||
return;
|
||||
}
|
||||
@@ -1429,8 +1420,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
Bool layered = false;
|
||||
if (!ResolveRepresentableFramebufferTextureUploadTarget(*textureObject, textureUploadTarget, layered)) {
|
||||
RecordUnsupportedFramebufferTextureAttachmentError(
|
||||
__func__,
|
||||
"Layered or multi-image framebuffer texture targets are not fully represented by the current framebuffer attachment model.");
|
||||
__func__, "Layered or multi-image framebuffer texture targets are not fully represented by the current "
|
||||
"framebuffer attachment model.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1455,7 +1446,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
if (texture == 0) {
|
||||
framebufferObject->Detach(attachmentType);
|
||||
PipePublishFramebufferByName(framebufferObject);
|
||||
PipePublishFramebufferByName(framebufferObject);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1476,8 +1467,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
Bool layered = false;
|
||||
if (!ResolveRepresentableFramebufferTextureUploadTarget(*textureObject, textureUploadTarget, layered)) {
|
||||
RecordUnsupportedFramebufferTextureAttachmentError(
|
||||
"NamedFramebufferTexture_State",
|
||||
"Layered or multi-image framebuffer texture targets are not fully represented by the current framebuffer attachment model.");
|
||||
"NamedFramebufferTexture_State", "Layered or multi-image framebuffer texture targets are not fully "
|
||||
"represented by the current framebuffer attachment model.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1490,9 +1481,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
TextureUploadTarget textureUploadTarget) {
|
||||
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
|
||||
NamedFramebufferTextureWithUploadTarget_State(functionName, framebuffer, GL_DEPTH_ATTACHMENT, texture,
|
||||
level, textureUploadTarget);
|
||||
level, textureUploadTarget);
|
||||
NamedFramebufferTextureWithUploadTarget_State(functionName, framebuffer, GL_STENCIL_ATTACHMENT, texture,
|
||||
level, textureUploadTarget);
|
||||
level, textureUploadTarget);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1506,7 +1497,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
if (texture == 0) {
|
||||
framebufferObject->Detach(attachmentType);
|
||||
PipePublishFramebufferByName(framebufferObject);
|
||||
PipePublishFramebufferByName(framebufferObject);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1520,15 +1511,13 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
const auto expectedTextureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadTarget);
|
||||
if (expectedTextureTarget == TextureTarget::Unknown ||
|
||||
textureObject->GetTarget() != expectedTextureTarget) {
|
||||
if (expectedTextureTarget == TextureTarget::Unknown || textureObject->GetTarget() != expectedTextureTarget) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", functionName,
|
||||
std::format("Attachment target {} does not match texture {} target {}.",
|
||||
MG_Util::ConvertTextureUploadTargetToString(textureUploadTarget),
|
||||
texture,
|
||||
MG_Util::ConvertTextureUploadTargetToString(textureUploadTarget), texture,
|
||||
MG_Util::ConvertTextureTargetToString(textureObject->GetTarget()))));
|
||||
return;
|
||||
}
|
||||
@@ -1567,9 +1556,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
static_cast<void>(texture);
|
||||
static_cast<void>(level);
|
||||
static_cast<void>(zoffset);
|
||||
RecordUnsupportedFramebufferTextureAttachmentError(
|
||||
__func__,
|
||||
"3D framebuffer texture slice attachments are not represented by the current framebuffer attachment model.");
|
||||
RecordUnsupportedFramebufferTextureAttachmentError(__func__,
|
||||
"3D framebuffer texture slice attachments are not "
|
||||
"represented by the current framebuffer attachment model.");
|
||||
}
|
||||
|
||||
void NamedFramebufferTextureLayer_State(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level,
|
||||
@@ -1589,7 +1578,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
if (texture == 0) {
|
||||
framebufferObject->Detach(attachmentType);
|
||||
PipePublishFramebufferByName(framebufferObject);
|
||||
PipePublishFramebufferByName(framebufferObject);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1619,9 +1608,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
// GL 4.6 core 9.2.8: only the layered targets have layers to select, and the largest layer
|
||||
// each one admits comes from a different implementation limit.
|
||||
const auto& limits = MG_Backend::pActiveBackendObject
|
||||
? MG_Backend::pActiveBackendObject->GetDynamicParameters()
|
||||
: MG_Backend::DynamicBackendParameters{};
|
||||
const auto& limits = MG_Backend::pActiveBackendObject ? MG_Backend::pActiveBackendObject->GetDynamicParameters()
|
||||
: MG_Backend::DynamicBackendParameters{};
|
||||
TextureUploadTarget textureUploadTarget = TextureUploadTarget::Unknown;
|
||||
Int layerLimit = 0;
|
||||
switch (textureObject->GetTarget()) {
|
||||
@@ -1659,9 +1647,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (layer >= layerLimit) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
std::format("Layer {} is beyond the limit ({}) for this texture target.",
|
||||
layer, layerLimit)));
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", __func__,
|
||||
std::format("Layer {} is beyond the limit ({}) for this texture target.", layer, layerLimit)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1682,8 +1670,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// already express, so it stays legal even where per-layer selection is not backed. A cube map
|
||||
// array has no such fallback: layer zero is still one face of one cube inside a
|
||||
// cube-compatible image, so it needs the same support layer 5 does.
|
||||
const Bool needsPerLayerSupport =
|
||||
layer != 0 || layeredTextureTarget == TextureTarget::TextureCubeMapArray;
|
||||
const Bool needsPerLayerSupport = layer != 0 || layeredTextureTarget == TextureTarget::TextureCubeMapArray;
|
||||
if (needsPerLayerSupport && !backsThisTargetsLayers) {
|
||||
RecordUnsupportedFramebufferTextureAttachmentError(
|
||||
__func__, "This backend does not resolve a framebuffer attachment's layer onto its image.");
|
||||
@@ -1762,13 +1749,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
if (renderbuffer == 0) {
|
||||
framebufferObject->Detach(attachmentType);
|
||||
PipePublishFramebufferByName(framebufferObject);
|
||||
PipePublishFramebufferByName(framebufferObject);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FramebufferImpl::ValidateRenderbufferName(renderbuffer, false)) return;
|
||||
auto renderbufferObject =
|
||||
GetNamedRenderbufferObject_State(renderbuffer, "NamedFramebufferRenderbuffer_State");
|
||||
auto renderbufferObject = GetNamedRenderbufferObject_State(renderbuffer, "NamedFramebufferRenderbuffer_State");
|
||||
if (!renderbufferObject) return;
|
||||
|
||||
framebufferObject->AttachRenderbuffer(attachmentType, renderbufferObject);
|
||||
@@ -1819,10 +1805,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!allowDefaultFBOAliases && bufs[i] == GL_FRONT) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", __func__,
|
||||
std::format("glDrawBuffers cannot use the multi-buffer name {}.",
|
||||
MG_Util::ConvertGLEnumToString(bufs[i]))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
std::format("glDrawBuffers cannot use the multi-buffer name {}.",
|
||||
MG_Util::ConvertGLEnumToString(bufs[i]))));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1918,10 +1903,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const Bool isMultiBufferName = src == GL_LEFT || src == GL_RIGHT || src == GL_FRONT_AND_BACK;
|
||||
MG_State::pGLContext->RecordError(
|
||||
isMultiBufferName ? ErrorCode::InvalidOperation : ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", caller,
|
||||
std::format("`src` = {} does not name a single readable colour buffer.",
|
||||
MG_Util::ConvertGLEnumToString(src))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
std::format("`src` = {} does not name a single readable colour buffer.",
|
||||
MG_Util::ConvertGLEnumToString(src))));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1939,9 +1923,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
(attType < FramebufferAttachmentType::FrontLeft || attType > FramebufferAttachmentType::BackRight)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", caller,
|
||||
std::format("Default framebuffer read buffer {} is not valid.", MG_Util::ConvertGLEnumToString(src))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
std::format("Default framebuffer read buffer {} is not valid.",
|
||||
MG_Util::ConvertGLEnumToString(src))));
|
||||
return;
|
||||
}
|
||||
if (!isDefaultFBO && attType != FramebufferAttachmentType::None &&
|
||||
@@ -1967,9 +1951,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void NamedFramebufferDrawBuffers_State(GLuint framebuffer, GLsizei n, const GLenum* bufs) {
|
||||
// Zero names the default framebuffer, whose accepted buffer names are a different set - so
|
||||
// it cannot go through the framebuffer-object lookup, which rejects the name outright.
|
||||
auto framebufferObject = framebuffer == 0
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "NamedFramebufferDrawBuffers_State");
|
||||
auto framebufferObject =
|
||||
framebuffer == 0 ? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "NamedFramebufferDrawBuffers_State");
|
||||
if (!framebufferObject) return;
|
||||
DrawBuffersForFramebuffer_State(framebufferObject, framebuffer == 0, n, bufs, false);
|
||||
PipePublishFramebufferByName(framebufferObject);
|
||||
@@ -1977,8 +1961,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
void NamedFramebufferDrawBuffer_State(GLuint framebuffer, GLenum buf) {
|
||||
auto framebufferObject = framebuffer == 0
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "NamedFramebufferDrawBuffer_State");
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "NamedFramebufferDrawBuffer_State");
|
||||
if (!framebufferObject) return;
|
||||
|
||||
if (buf == GL_NONE) {
|
||||
@@ -1992,11 +1976,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
void NamedFramebufferReadBuffer_State(GLuint framebuffer, GLenum src) {
|
||||
auto framebufferObject = framebuffer == 0
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "NamedFramebufferReadBuffer_State");
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "NamedFramebufferReadBuffer_State");
|
||||
if (!framebufferObject) return;
|
||||
ReadBufferForFramebuffer_State(framebufferObject, framebuffer == 0, src,
|
||||
"NamedFramebufferReadBuffer_State");
|
||||
ReadBufferForFramebuffer_State(framebufferObject, framebuffer == 0, src, "NamedFramebufferReadBuffer_State");
|
||||
PipePublishFramebufferByName(framebufferObject);
|
||||
}
|
||||
|
||||
@@ -2035,10 +2018,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
default:
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", caller,
|
||||
std::format("buffer {} is not accepted for glClearNamedFramebufferfv.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
std::format("buffer {} is not accepted for glClearNamedFramebufferfv.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2047,10 +2029,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (buffer != GL_DEPTH_STENCIL) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", caller,
|
||||
std::format("buffer {} is not accepted for glClearNamedFramebufferfi.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
std::format("buffer {} is not accepted for glClearNamedFramebufferfi.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
return false;
|
||||
}
|
||||
if (drawbuffer != 0) {
|
||||
@@ -2070,7 +2051,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ClearNamedFramebufferfi_State(GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth,
|
||||
GLint stencil) {
|
||||
GLint stencil) {
|
||||
auto framebufferObject = GetFramebufferObjectForNamedClear(framebuffer, "ClearNamedFramebufferfi_State");
|
||||
if (!framebufferObject) return;
|
||||
if (!ValidateNamedClearfi_State(buffer, drawbuffer, "ClearNamedFramebufferfi_State")) return;
|
||||
@@ -2176,11 +2157,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
continue;
|
||||
default:
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", caller,
|
||||
std::format("{} does not name a buffer of the default framebuffer.",
|
||||
MG_Util::ConvertGLEnumToString(attachment))));
|
||||
ErrorCode::InvalidEnum, MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", caller,
|
||||
std::format("{} does not name a buffer of the default framebuffer.",
|
||||
MG_Util::ConvertGLEnumToString(attachment))));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2217,7 +2197,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
SharedPtr<MG_State::GLState::FramebufferObject> GetFramebufferObjectForInvalidate_State(GLenum target,
|
||||
const char* caller) {
|
||||
const char* caller) {
|
||||
const FramebufferTarget framebufferTarget =
|
||||
MG_Util::ConvertGLEnumToFramebufferTarget(target == GL_FRAMEBUFFER ? GL_DRAW_FRAMEBUFFER : target);
|
||||
if (!FramebufferImpl::ValidateFramebufferTarget(framebufferTarget)) return nullptr;
|
||||
@@ -2232,16 +2212,14 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void InvalidateNamedFramebufferData_State(GLuint framebuffer, GLsizei numAttachments, const GLenum* attachments) {
|
||||
auto framebufferObject =
|
||||
GetFramebufferObjectForNamedClear(framebuffer, "InvalidateNamedFramebufferData_State");
|
||||
auto framebufferObject = GetFramebufferObjectForNamedClear(framebuffer, "InvalidateNamedFramebufferData_State");
|
||||
if (!framebufferObject) return;
|
||||
ValidateInvalidateAttachments_State(framebufferObject, numAttachments, attachments,
|
||||
"InvalidateNamedFramebufferData_State");
|
||||
}
|
||||
|
||||
void InvalidateNamedFramebufferSubData_State(GLuint framebuffer, GLsizei numAttachments,
|
||||
const GLenum* attachments, GLint x, GLint y, GLsizei width,
|
||||
GLsizei height) {
|
||||
void InvalidateNamedFramebufferSubData_State(GLuint framebuffer, GLsizei numAttachments, const GLenum* attachments,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height) {
|
||||
(void)x;
|
||||
(void)y;
|
||||
auto framebufferObject =
|
||||
@@ -2355,9 +2333,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER && target != GL_READ_FRAMEBUFFER) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "CheckNamedFramebufferStatus_State",
|
||||
std::format("target {} is not accepted.",
|
||||
MG_Util::ConvertGLEnumToString(target))));
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "CheckNamedFramebufferStatus_State",
|
||||
std::format("target {} is not accepted.", MG_Util::ConvertGLEnumToString(target))));
|
||||
return GL_FRAMEBUFFER_UNDEFINED;
|
||||
}
|
||||
|
||||
@@ -2502,8 +2480,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
const Bool depthStencilAlias = attachment == GL_DEPTH_STENCIL_ATTACHMENT;
|
||||
FramebufferAttachmentType attachmentType = depthStencilAlias
|
||||
? FramebufferAttachmentType::Depth
|
||||
: MG_Util::ConvertGLEnumToFramebufferAttachmentType(attachment);
|
||||
? FramebufferAttachmentType::Depth
|
||||
: MG_Util::ConvertGLEnumToFramebufferAttachmentType(attachment);
|
||||
if (!FramebufferImpl::ValidateFramebufferAttachmentType(attachmentType)) return;
|
||||
|
||||
Bool depthStencilMismatch = false;
|
||||
@@ -2517,7 +2495,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const Bool depthLive = depthAttachment.IsValid() && !depthAttachment.IsEmpty();
|
||||
const Bool stencilLive = stencilAttachment.IsValid() && !stencilAttachment.IsEmpty();
|
||||
if (depthLive && stencilLive) {
|
||||
const Bool sameObject = depthAttachment.IsTexture() == stencilAttachment.IsTexture() &&
|
||||
const Bool sameObject =
|
||||
depthAttachment.IsTexture() == stencilAttachment.IsTexture() &&
|
||||
(!depthAttachment.IsTexture() || depthAttachment.GetTexture() == stencilAttachment.GetTexture()) &&
|
||||
(!depthAttachment.IsRenderbuffer() ||
|
||||
depthAttachment.GetRenderbuffer() == stencilAttachment.GetRenderbuffer());
|
||||
@@ -2569,22 +2548,22 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
break;
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
|
||||
*params = (attachmentObject != nullptr && attachmentObject->IsTexture() && attachmentObject->IsValid())
|
||||
? static_cast<GLint>(attachmentObject->GetTextureLevel())
|
||||
: 0;
|
||||
? static_cast<GLint>(attachmentObject->GetTextureLevel())
|
||||
: 0;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
|
||||
*params = 0;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
|
||||
*params = (attachmentObject != nullptr && attachmentObject->IsTexture() && attachmentObject->IsValid())
|
||||
? static_cast<GLint>(attachmentObject->GetTextureLayer())
|
||||
: 0;
|
||||
? static_cast<GLint>(attachmentObject->GetTextureLayer())
|
||||
: 0;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_LAYERED:
|
||||
*params = (attachmentObject != nullptr && attachmentObject->IsTexture() && attachmentObject->IsValid() &&
|
||||
attachmentObject->IsLayered())
|
||||
? GL_TRUE
|
||||
: GL_FALSE;
|
||||
? GL_TRUE
|
||||
: GL_FALSE;
|
||||
break;
|
||||
default:
|
||||
if (TryAnswerAttachmentFormatQuery(attachmentObject, attachmentType, depthStencilAlias, pname, params,
|
||||
@@ -2601,15 +2580,16 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void GetNamedFramebufferAttachmentParameteriv_State(GLuint framebuffer, GLenum attachment, GLenum pname,
|
||||
GLint* params) {
|
||||
GLint* params) {
|
||||
// Zero names the default framebuffer here rather than being rejected: the DSA queries take
|
||||
// it in place of a binding (GL 4.6 core 9.2.3).
|
||||
auto framebufferObject = framebuffer == 0
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "GetNamedFramebufferAttachmentParameteriv_State");
|
||||
auto framebufferObject =
|
||||
framebuffer == 0
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "GetNamedFramebufferAttachmentParameteriv_State");
|
||||
if (!framebufferObject) return;
|
||||
GetFramebufferAttachmentParameteriv_Object(framebufferObject, attachment, pname, params,
|
||||
"GetNamedFramebufferAttachmentParameteriv_State");
|
||||
"GetNamedFramebufferAttachmentParameteriv_State");
|
||||
}
|
||||
|
||||
// The by-target forms resolve the binding; the by-name forms take zero as the default
|
||||
@@ -2645,30 +2625,30 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void GetNamedFramebufferParameteriv_State(GLuint framebuffer, GLenum pname, GLint* params) {
|
||||
auto framebufferObject = framebuffer == 0
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "GetNamedFramebufferParameteriv_State");
|
||||
auto framebufferObject =
|
||||
framebuffer == 0 ? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "GetNamedFramebufferParameteriv_State");
|
||||
if (!framebufferObject) return;
|
||||
GetFramebufferParameteriv_Object(framebufferObject, pname, params, "GetNamedFramebufferParameteriv_State");
|
||||
}
|
||||
|
||||
void NamedFramebufferParameteri_State(GLuint framebuffer, GLenum pname, GLint param) {
|
||||
auto framebufferObject = framebuffer == 0
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "NamedFramebufferParameteri_State");
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(framebuffer, "NamedFramebufferParameteri_State");
|
||||
if (!framebufferObject) return;
|
||||
FramebufferParameteri_Object(framebufferObject, pname, param, "NamedFramebufferParameteri_State");
|
||||
}
|
||||
|
||||
void BlitNamedFramebuffer_State(GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0,
|
||||
GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
||||
GLbitfield mask, GLenum filter) {
|
||||
GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
||||
GLbitfield mask, GLenum filter) {
|
||||
auto readObject = readFramebuffer == 0
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(readFramebuffer, "BlitNamedFramebuffer_State");
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(readFramebuffer, "BlitNamedFramebuffer_State");
|
||||
auto drawObject = drawFramebuffer == 0
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(drawFramebuffer, "BlitNamedFramebuffer_State");
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(drawFramebuffer, "BlitNamedFramebuffer_State");
|
||||
if (!readObject || !drawObject) return;
|
||||
|
||||
BlitNamedFramebuffer_Backend(readObject, drawObject, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
|
||||
@@ -2716,9 +2696,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
bindingSlot.Bind(framebufferObject);
|
||||
}
|
||||
|
||||
void GetRenderbufferParameterivForObject_State(const SharedPtr<MG_State::GLState::RenderbufferObject>&
|
||||
renderbufferObject,
|
||||
GLenum pname, GLint* params, const char* caller) {
|
||||
void GetRenderbufferParameterivForObject_State(
|
||||
const SharedPtr<MG_State::GLState::RenderbufferObject>& renderbufferObject, GLenum pname, GLint* params,
|
||||
const char* caller) {
|
||||
if (!params) return;
|
||||
|
||||
if (!renderbufferObject) {
|
||||
@@ -2774,7 +2754,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!FramebufferImpl::ValidateRenderbufferTarget(renderbufferTarget)) return;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetRenderbufferBindingSlot(renderbufferTarget);
|
||||
auto& renderbufferObject = bindingSlot.GetBoundObject();
|
||||
GetRenderbufferParameterivForObject_State(renderbufferObject, pname, params, "GetRenderbufferParameteriv_State");
|
||||
GetRenderbufferParameterivForObject_State(renderbufferObject, pname, params,
|
||||
"GetRenderbufferParameteriv_State");
|
||||
}
|
||||
|
||||
void GetNamedRenderbufferParameteriv_State(GLuint renderbuffer, GLenum pname, GLint* params) {
|
||||
@@ -2782,7 +2763,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
GetNamedRenderbufferObject_State(renderbuffer, "GetNamedRenderbufferParameteriv_State");
|
||||
if (!renderbufferObject) return;
|
||||
GetRenderbufferParameterivForObject_State(renderbufferObject, pname, params,
|
||||
"GetNamedRenderbufferParameteriv_State");
|
||||
"GetNamedRenderbufferParameteriv_State");
|
||||
}
|
||||
|
||||
void ClearBufferfi_Backend(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) {
|
||||
@@ -2839,10 +2820,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (buffer != GL_COLOR && buffer != GL_DEPTH) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateClearBufferfv_State",
|
||||
std::format("buffer {} is not accepted for glClearBufferfv.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateClearBufferfv_State",
|
||||
std::format("buffer {} is not accepted for glClearBufferfv.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
return false;
|
||||
}
|
||||
return ValidateClearBufferDrawbuffer_State(buffer, drawbuffer, "ValidateClearBufferfv_State");
|
||||
@@ -2852,10 +2832,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (buffer != GL_COLOR && buffer != GL_STENCIL) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateClearBufferiv_State",
|
||||
std::format("buffer {} is not accepted for glClearBufferiv.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateClearBufferiv_State",
|
||||
std::format("buffer {} is not accepted for glClearBufferiv.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
return false;
|
||||
}
|
||||
return ValidateClearBufferDrawbuffer_State(buffer, drawbuffer, "ValidateClearBufferiv_State");
|
||||
@@ -2865,10 +2844,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (buffer != GL_COLOR && buffer != GL_STENCIL) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateClearBufferuiv_State",
|
||||
std::format("buffer {} is not accepted for glClearBufferuiv.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateClearBufferuiv_State",
|
||||
std::format("buffer {} is not accepted for glClearBufferuiv.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
return false;
|
||||
}
|
||||
return ValidateClearBufferDrawbuffer_State(buffer, drawbuffer, "ValidateClearBufferuiv_State");
|
||||
@@ -2878,10 +2856,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (buffer != GL_DEPTH_STENCIL) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateClearBufferfi_State",
|
||||
std::format("buffer {} is not accepted for glClearBufferfi.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateClearBufferfi_State",
|
||||
std::format("buffer {} is not accepted for glClearBufferfi.",
|
||||
MG_Util::ConvertGLEnumToString(buffer))));
|
||||
return false;
|
||||
}
|
||||
return ValidateClearBufferDrawbuffer_State(buffer, drawbuffer, "ValidateClearBufferfi_State");
|
||||
@@ -2973,10 +2950,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const FramebufferAttachmentType readBuffer = framebufferObject->GetReadBuffer();
|
||||
if (readBuffer == FramebufferAttachmentType::None ||
|
||||
!framebufferObject->GetAttachment(readBuffer).IsValid()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "ReadPixels_State",
|
||||
"No color buffer for color format"));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "ReadPixels_State",
|
||||
"No color buffer for color format"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3042,7 +3018,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
// Check multisampling
|
||||
const FramebufferAttachmentType readBuffer = framebufferObject->GetReadBuffer();
|
||||
if (readBuffer != FramebufferAttachmentType::None && framebufferObject->GetAttachment(readBuffer).IsRenderbuffer()) {
|
||||
if (readBuffer != FramebufferAttachmentType::None &&
|
||||
framebufferObject->GetAttachment(readBuffer).IsRenderbuffer()) {
|
||||
auto& rbo = framebufferObject->GetAttachment(readBuffer).GetRenderbuffer();
|
||||
if (rbo && rbo->GetSamples() > 1) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
@@ -3075,18 +3052,16 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// wide, and the skip parameters offset the first texel. The last row is not padded - nothing
|
||||
// follows it to align - which is what makes a tightly-sized destination legal.
|
||||
static SizeT ComputePackedReadSizeInBytes(GLsizei width, GLsizei height, GLenum format, GLenum type) {
|
||||
const SizeT bytesPerPixel =
|
||||
MG_Util::GetInputBytesPerPixel(MG_Util::ConvertGLEnumToTextureInputFormat(format),
|
||||
MG_Util::ConvertGLEnumToTexturePixelDataType(type));
|
||||
const SizeT bytesPerPixel = MG_Util::GetInputBytesPerPixel(MG_Util::ConvertGLEnumToTextureInputFormat(format),
|
||||
MG_Util::ConvertGLEnumToTexturePixelDataType(type));
|
||||
if (bytesPerPixel == 0 || width <= 0 || height <= 0) return 0;
|
||||
|
||||
const auto packParam = [](PixelStoreParam param) {
|
||||
return static_cast<SizeT>(std::max(0, MG_State::pGLContext->GetPixelStoreParam(param)));
|
||||
};
|
||||
const SizeT rowLengthInPixels =
|
||||
packParam(PixelStoreParam::PackRowLength) != 0
|
||||
? packParam(PixelStoreParam::PackRowLength)
|
||||
: static_cast<SizeT>(width);
|
||||
const SizeT rowLengthInPixels = packParam(PixelStoreParam::PackRowLength) != 0
|
||||
? packParam(PixelStoreParam::PackRowLength)
|
||||
: static_cast<SizeT>(width);
|
||||
const SizeT alignment = std::max<SizeT>(1, packParam(PixelStoreParam::PackAlignment));
|
||||
|
||||
const SizeT unalignedRowBytes = rowLengthInPixels * bytesPerPixel;
|
||||
@@ -3203,8 +3178,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
NamedRenderbufferStorage_State(renderbuffer, internalformat, width, height);
|
||||
}
|
||||
|
||||
void NamedRenderbufferStorageMultisample(GLuint renderbuffer, GLsizei samples, GLenum internalformat,
|
||||
GLsizei width, GLsizei height) {
|
||||
void NamedRenderbufferStorageMultisample(GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width,
|
||||
GLsizei height) {
|
||||
NamedRenderbufferStorageMultisample_State(renderbuffer, samples, internalformat, width, height);
|
||||
}
|
||||
|
||||
@@ -3255,13 +3230,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
NamedFramebufferTexture2D_State(framebuffer, attachment, textarget, texture, level);
|
||||
}
|
||||
|
||||
void NamedFramebufferTexture3D(GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture,
|
||||
GLint level, GLint zoffset) {
|
||||
void NamedFramebufferTexture3D(GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level,
|
||||
GLint zoffset) {
|
||||
NamedFramebufferTexture3D_State(framebuffer, attachment, textarget, texture, level, zoffset);
|
||||
}
|
||||
|
||||
void NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level,
|
||||
GLint layer) {
|
||||
void NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer) {
|
||||
NamedFramebufferTextureLayer_State(framebuffer, attachment, texture, level, layer);
|
||||
}
|
||||
|
||||
@@ -3361,10 +3335,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return false;
|
||||
}
|
||||
if (filter != GL_NEAREST && filter != GL_LINEAR) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"filter must be GL_NEAREST or GL_LINEAR."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"filter must be GL_NEAREST or GL_LINEAR."));
|
||||
return false;
|
||||
}
|
||||
// Depth and stencil have no meaningful interpolation, so GL_LINEAR is rejected outright
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void GenRenderbuffers(GLsizei n, GLuint* renderbuffers);
|
||||
void CreateRenderbuffers(GLsizei n, GLuint* renderbuffers);
|
||||
void NamedRenderbufferStorage(GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
void NamedRenderbufferStorageMultisample(GLuint renderbuffer, GLsizei samples, GLenum internalformat,
|
||||
GLsizei width, GLsizei height);
|
||||
void NamedRenderbufferStorageMultisample(GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width,
|
||||
GLsizei height);
|
||||
void GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname, GLint* params);
|
||||
void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
||||
void NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget,
|
||||
@@ -48,8 +48,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void FramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||
void FramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level);
|
||||
void NamedFramebufferTexture(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
|
||||
void NamedFramebufferTexture1D(GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||
void NamedFramebufferTexture2D(GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||
void NamedFramebufferTexture1D(GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture,
|
||||
GLint level);
|
||||
void NamedFramebufferTexture2D(GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture,
|
||||
GLint level);
|
||||
void NamedFramebufferTexture3D(GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level,
|
||||
GLint zoffset);
|
||||
void NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
|
||||
|
||||
@@ -66,10 +66,10 @@ namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl {
|
||||
const auto index = static_cast<SizeT>(attachment);
|
||||
if (index < first) return true;
|
||||
const auto colorIndex = index - first;
|
||||
const auto limit = static_cast<SizeT>(
|
||||
MG_Backend::pActiveBackendObject ? MG_Backend::pActiveBackendObject->GetDynamicParameters()
|
||||
.MaxColorAttachments
|
||||
: static_cast<Int>(MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS));
|
||||
const auto limit =
|
||||
static_cast<SizeT>(MG_Backend::pActiveBackendObject
|
||||
? MG_Backend::pActiveBackendObject->GetDynamicParameters().MaxColorAttachments
|
||||
: static_cast<Int>(MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS));
|
||||
if (colorIndex >= limit) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
@@ -140,10 +140,9 @@ namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl {
|
||||
if (forSetter) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl/FramebufferImpl", caller,
|
||||
std::format("pname {} is not settable on a framebuffer.",
|
||||
MG_Util::ConvertGLEnumToString(pname))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl/FramebufferImpl", caller,
|
||||
std::format("pname {} is not settable on a framebuffer.",
|
||||
MG_Util::ConvertGLEnumToString(pname))));
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -152,8 +151,7 @@ namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl {
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl/FramebufferImpl", caller,
|
||||
std::format("pname {} is not a framebuffer parameter.",
|
||||
MG_Util::ConvertGLEnumToString(pname))));
|
||||
std::format("pname {} is not a framebuffer parameter.", MG_Util::ConvertGLEnumToString(pname))));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -162,10 +160,9 @@ namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl {
|
||||
if (isDefaultFramebuffer && isDefaultParameter) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl/FramebufferImpl", caller,
|
||||
std::format("pname {} does not apply to the default framebuffer.",
|
||||
MG_Util::ConvertGLEnumToString(pname))));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl/FramebufferImpl", caller,
|
||||
std::format("pname {} does not apply to the default framebuffer.",
|
||||
MG_Util::ConvertGLEnumToString(pname))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -183,8 +180,7 @@ namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl {
|
||||
}
|
||||
|
||||
const FramebufferAttachmentType readBuffer = framebufferObject->GetReadBuffer();
|
||||
if (readBuffer == FramebufferAttachmentType::None ||
|
||||
!framebufferObject->GetAttachment(readBuffer).IsValid()) {
|
||||
if (readBuffer == FramebufferAttachmentType::None || !framebufferObject->GetAttachment(readBuffer).IsValid()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl/FramebufferImpl", caller,
|
||||
@@ -201,8 +197,8 @@ namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl {
|
||||
isMultisampled = readAttachment.GetRenderbuffer()->GetSamples() > 0;
|
||||
} else if (readAttachment.IsTexture() && readAttachment.GetTexture()) {
|
||||
const auto target = readAttachment.GetTexture()->GetTarget();
|
||||
isMultisampled = target == TextureTarget::Texture2DMultisample ||
|
||||
target == TextureTarget::Texture2DMultisampleArray;
|
||||
isMultisampled =
|
||||
target == TextureTarget::Texture2DMultisample || target == TextureTarget::Texture2DMultisampleArray;
|
||||
}
|
||||
if (isMultisampled) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
|
||||
@@ -29,6 +29,5 @@ namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl {
|
||||
// of the contract: a name outside the table is INVALID_ENUM, and only then is a name that the
|
||||
// DEFAULT framebuffer does not answer INVALID_OPERATION. Testing the framebuffer kind first
|
||||
// would turn GL_FRAMEBUFFER_DEFAULT_WIDTH on framebuffer zero into the wrong error.
|
||||
Bool ValidateFramebufferParameterPname(GLenum pname, Bool isDefaultFramebuffer, Bool forSetter,
|
||||
const char* caller);
|
||||
Bool ValidateFramebufferParameterPname(GLenum pname, Bool isDefaultFramebuffer, Bool forSetter, const char* caller);
|
||||
} // namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl
|
||||
|
||||
@@ -130,8 +130,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
kFrontendMaxFragmentUniformBlocks + kFrontendMaxComputeUniformBlocksShare;
|
||||
constexpr GLint kFrontendMaxVaryingComponents =
|
||||
static_cast<GLint>(MG_Util::ShaderTranspiler::MAX_VARYING_COMPONENTS);
|
||||
constexpr GLint kFrontendMaxVaryingVectors =
|
||||
static_cast<GLint>(MG_Util::ShaderTranspiler::MAX_VARYING_VECTORS);
|
||||
constexpr GLint kFrontendMaxVaryingVectors = static_cast<GLint>(MG_Util::ShaderTranspiler::MAX_VARYING_VECTORS);
|
||||
constexpr GLint kFrontendMaxProgramTexelOffset = 7;
|
||||
constexpr GLint kFrontendMinProgramTexelOffset = -8;
|
||||
constexpr GLint kFrontendMaxTransformFeedbackInterleavedComponents = 64;
|
||||
@@ -148,8 +147,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// the ceiling here.
|
||||
constexpr GLint kFrontendMinUniformBufferBindings = 84;
|
||||
constexpr GLint kFrontendSubpixelBits = 4;
|
||||
constexpr GLint kFrontendMaxSamples =
|
||||
static_cast<GLint>(MG_Util::ShaderTranspiler::MIN_ADVERTISED_MAX_SAMPLES);
|
||||
constexpr GLint kFrontendMaxSamples = static_cast<GLint>(MG_Util::ShaderTranspiler::MIN_ADVERTISED_MAX_SAMPLES);
|
||||
// ARB_shader_subroutine's two limits. NOTHING IMPLEMENTS SUBROUTINES: there is no
|
||||
// glGetSubroutineIndex / glUniformSubroutinesuiv, only the program-interface enum
|
||||
// plumbing. These are answered - with the GL 4.5 core minimums - because the conformance
|
||||
@@ -315,7 +313,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
: kBackendlessDefaults);
|
||||
}
|
||||
|
||||
GLint StageStorageBlockCount(Int MG_Backend::DynamicBackendParameters::*stageLimit) {
|
||||
GLint StageStorageBlockCount(Int MG_Backend::DynamicBackendParameters::* stageLimit) {
|
||||
static const MG_Backend::DynamicBackendParameters kBackendlessDefaults{};
|
||||
const MG_Backend::DynamicBackendParameters& parameters =
|
||||
MG_Backend::pActiveBackendObject ? MG_Backend::pActiveBackendObject->GetDynamicParameters()
|
||||
@@ -367,10 +365,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void RecordIndexedOnlyGetterError(const char* functionName, GLenum pname) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", functionName,
|
||||
"pname " + MG_Util::ConvertGLEnumToString(pname) +
|
||||
" is only valid with indexed getter entrypoints."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"pname " + MG_Util::ConvertGLEnumToString(pname) +
|
||||
" is only valid with indexed getter entrypoints."));
|
||||
}
|
||||
|
||||
bool ValidateIndexedBufferQueryIndex(GLenum pname, GLuint index, const char* functionName,
|
||||
@@ -393,10 +390,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (index >= GetIndexedBufferQueryPointCount(bufferTarget)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", functionName,
|
||||
"index " + std::to_string(index) + " is out of range for indexed buffer query " +
|
||||
std::to_string(pname) + "."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"index " + std::to_string(index) +
|
||||
" is out of range for indexed buffer query " +
|
||||
std::to_string(pname) + "."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -408,21 +405,44 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// pname -> target decode, so it lives here instead of being spelled out twice.
|
||||
bool TryDecodeTextureUnitBindingPname(GLenum pname, TextureTarget& outTarget) {
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_BINDING_1D: outTarget = TextureTarget::Texture1D; return true;
|
||||
case GL_TEXTURE_BINDING_1D_ARRAY: outTarget = TextureTarget::Texture1DArray; return true;
|
||||
case GL_TEXTURE_BINDING_2D: outTarget = TextureTarget::Texture2D; return true;
|
||||
case GL_TEXTURE_BINDING_2D_ARRAY: outTarget = TextureTarget::Texture2DArray; return true;
|
||||
case GL_TEXTURE_BINDING_2D_MULTISAMPLE: outTarget = TextureTarget::Texture2DMultisample; return true;
|
||||
case GL_TEXTURE_BINDING_1D:
|
||||
outTarget = TextureTarget::Texture1D;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_1D_ARRAY:
|
||||
outTarget = TextureTarget::Texture1DArray;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_2D:
|
||||
outTarget = TextureTarget::Texture2D;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_2D_ARRAY:
|
||||
outTarget = TextureTarget::Texture2DArray;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_2D_MULTISAMPLE:
|
||||
outTarget = TextureTarget::Texture2DMultisample;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY:
|
||||
outTarget = TextureTarget::Texture2DMultisampleArray;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_3D: outTarget = TextureTarget::Texture3D; return true;
|
||||
case GL_TEXTURE_BINDING_BUFFER: outTarget = TextureTarget::TextureBuffer; return true;
|
||||
case GL_TEXTURE_BINDING_CUBE_MAP: outTarget = TextureTarget::TextureCubeMap; return true;
|
||||
case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: outTarget = TextureTarget::TextureCubeMapArray; return true;
|
||||
case GL_TEXTURE_BINDING_RECTANGLE: outTarget = TextureTarget::TextureRectangle; return true;
|
||||
case GL_TEXTURE_BINDING_EXTERNAL_OES: outTarget = TextureTarget::External; return true;
|
||||
default: return false;
|
||||
case GL_TEXTURE_BINDING_3D:
|
||||
outTarget = TextureTarget::Texture3D;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_BUFFER:
|
||||
outTarget = TextureTarget::TextureBuffer;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_CUBE_MAP:
|
||||
outTarget = TextureTarget::TextureCubeMap;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
|
||||
outTarget = TextureTarget::TextureCubeMapArray;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_RECTANGLE:
|
||||
outTarget = TextureTarget::TextureRectangle;
|
||||
return true;
|
||||
case GL_TEXTURE_BINDING_EXTERNAL_OES:
|
||||
outTarget = TextureTarget::External;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,7 +559,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// see the note on GetAdvertisedMaxSamples. A zero would be a probe that never ran, so it is
|
||||
// floored rather than trusted.
|
||||
namespace {
|
||||
GLint AdvertisedCategoryMaxSamples(Int MG_Backend::DynamicBackendParameters::*categoryLimit) {
|
||||
GLint AdvertisedCategoryMaxSamples(Int MG_Backend::DynamicBackendParameters::* categoryLimit) {
|
||||
if (MG_Backend::pActiveBackendObject == nullptr) {
|
||||
return 1;
|
||||
}
|
||||
@@ -562,8 +582,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// Declared in GL_Getter.h, so that the draw path can feed the same number to the reserved
|
||||
// gl_NumSamples stand-in that glGetIntegerv(GL_SAMPLES) reports.
|
||||
GLint ResolveDrawFramebufferSampleCount() {
|
||||
const auto& drawFbo =
|
||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Draw).GetBoundObject();
|
||||
const auto& drawFbo = MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Draw).GetBoundObject();
|
||||
if (!drawFbo) return 0;
|
||||
|
||||
GLint maxSamples = 0;
|
||||
@@ -585,8 +604,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// One list for glGetString and glGetStringi, so the two forms always agree.
|
||||
const Vector<const char*>& ClientSideExtensions() {
|
||||
const Bool images = MG_Impl::EGLImpl::SharedImagesAvailable();
|
||||
const Bool esApi = MG_State::pEGLContext &&
|
||||
MG_State::pEGLContext->GetCurrentContextClientAPI() == EGL_OPENGL_ES_API;
|
||||
const Bool esApi =
|
||||
MG_State::pEGLContext && MG_State::pEGLContext->GetCurrentContextClientAPI() == EGL_OPENGL_ES_API;
|
||||
const Bool external =
|
||||
images && ClientSideExternalImageExtensionsAllowed() && MG_Impl::EGLImpl::SharedImageYuvAvailable();
|
||||
return ClientSideExtensionList(images, external, EsIdentityActive(), esApi);
|
||||
@@ -689,14 +708,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return list;
|
||||
};
|
||||
static const Vector<const char*> lists[16] = {
|
||||
build(false, false, false, false), build(false, false, false, true),
|
||||
build(false, false, true, false), build(false, false, true, true),
|
||||
build(false, true, false, false), build(false, true, false, true),
|
||||
build(false, true, true, false), build(false, true, true, true),
|
||||
build(true, false, false, false), build(true, false, false, true),
|
||||
build(true, false, true, false), build(true, false, true, true),
|
||||
build(true, true, false, false), build(true, true, false, true),
|
||||
build(true, true, true, false), build(true, true, true, true)};
|
||||
build(false, false, false, false), build(false, false, false, true), build(false, false, true, false),
|
||||
build(false, false, true, true), build(false, true, false, false), build(false, true, false, true),
|
||||
build(false, true, true, false), build(false, true, true, true), build(true, false, false, false),
|
||||
build(true, false, false, true), build(true, false, true, false), build(true, false, true, true),
|
||||
build(true, true, false, false), build(true, true, false, true), build(true, true, true, false),
|
||||
build(true, true, true, true)};
|
||||
return lists[(images ? 8 : 0) + (external ? 4 : 0) + (es ? 2 : 0) + (esApi ? 1 : 0)];
|
||||
}
|
||||
|
||||
@@ -746,16 +763,15 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
backendName.replace(at, sizeof("OpenGL ES") - 1, "GLES");
|
||||
}
|
||||
if (EsIdentityActive()) {
|
||||
versionStr = std::format("OpenGL ES 3.2 {} {}, {} Backend, GIT@" GIT_COMMIT_HASH_SHORT, MG_Config::ProjectName,
|
||||
MG_Config::CoreVersion.toFormattedString(MG_Config::DefaultVersionStringFormatAttrib),
|
||||
backendName);
|
||||
versionStr = std::format(
|
||||
"OpenGL ES 3.2 {} {}, {} Backend, GIT@" GIT_COMMIT_HASH_SHORT, MG_Config::ProjectName,
|
||||
MG_Config::CoreVersion.toFormattedString(MG_Config::DefaultVersionStringFormatAttrib), backendName);
|
||||
return (const GLubyte*)versionStr.c_str();
|
||||
}
|
||||
versionStr =
|
||||
std::format("{} {} {}, {} Backend, GIT@" GIT_COMMIT_HASH_SHORT,
|
||||
rendererInfo.RendererGLInfo.TargetGLVersion.toString(), MG_Config::ProjectName,
|
||||
MG_Config::CoreVersion.toFormattedString(MG_Config::DefaultVersionStringFormatAttrib),
|
||||
backendName);
|
||||
versionStr = std::format(
|
||||
"{} {} {}, {} Backend, GIT@" GIT_COMMIT_HASH_SHORT,
|
||||
rendererInfo.RendererGLInfo.TargetGLVersion.toString(), MG_Config::ProjectName,
|
||||
MG_Config::CoreVersion.toFormattedString(MG_Config::DefaultVersionStringFormatAttrib), backendName);
|
||||
MGLOG_D("versionStr: %s", versionStr.c_str());
|
||||
return (const GLubyte*)versionStr.c_str();
|
||||
}
|
||||
@@ -768,9 +784,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
case GL_SHADING_LANGUAGE_VERSION:
|
||||
if (EsIdentityActive()) return (const GLubyte*)"OpenGL ES GLSL ES 3.20";
|
||||
shadingLanguageVersion =
|
||||
std::format("{} {}", rendererInfo.RendererGLInfo.TargetGLSLVersion.toString({true, false}),
|
||||
MG_Config::ProjectName);
|
||||
shadingLanguageVersion = std::format(
|
||||
"{} {}", rendererInfo.RendererGLInfo.TargetGLSLVersion.toString({true, false}), MG_Config::ProjectName);
|
||||
MGLOG_D("shadingLanguageVersion: %s", shadingLanguageVersion.c_str());
|
||||
return (const GLubyte*)shadingLanguageVersion.c_str();
|
||||
case GL_EXTENSIONS:
|
||||
@@ -796,7 +811,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// GL 4.6 core 22.2: an index at or past the list's GL_NUM_* count is INVALID_VALUE, and a
|
||||
// name glGetStringi does not index is INVALID_ENUM; both return NULL.
|
||||
const auto recordError = [](ErrorCode code, const char* message) -> const GLubyte* {
|
||||
MG_State::pGLContext->RecordError(code, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetStringi", message));
|
||||
MG_State::pGLContext->RecordError(code,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetStringi", message));
|
||||
return nullptr;
|
||||
};
|
||||
if (name == GL_SPIR_V_EXTENSIONS) {
|
||||
@@ -903,31 +919,25 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::PolygonOffsetFill) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_PRIMITIVE_RESTART_FIXED_INDEX:
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::PrimitiveRestartFixedIndex)
|
||||
? GL_TRUE
|
||||
: GL_FALSE;
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::PrimitiveRestartFixedIndex) ? GL_TRUE
|
||||
: GL_FALSE;
|
||||
return;
|
||||
case GL_RASTERIZER_DISCARD:
|
||||
*params =
|
||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::RasterizerDiscard) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_SAMPLE_ALPHA_TO_COVERAGE:
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleAlphaToCoverage)
|
||||
? GL_TRUE
|
||||
: GL_FALSE;
|
||||
*params =
|
||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleAlphaToCoverage) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_SAMPLE_ALPHA_TO_ONE:
|
||||
*params =
|
||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleAlphaToOne) ? GL_TRUE : GL_FALSE;
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleAlphaToOne) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_SAMPLE_COVERAGE:
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleCoverage)
|
||||
? GL_TRUE
|
||||
: GL_FALSE;
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleCoverage) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_SAMPLE_MASK:
|
||||
*params =
|
||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleMask) ? GL_TRUE : GL_FALSE;
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleMask) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_SCISSOR_TEST:
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::ScissorTest) ? GL_TRUE : GL_FALSE;
|
||||
@@ -1211,8 +1221,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
*data = target == GL_SAMPLER_BINDING
|
||||
? QuerySamplerBindingOnUnit(static_cast<Int>(index))
|
||||
: QueryTextureBindingOnUnit(static_cast<Int>(index), textureBindingTarget);
|
||||
? QuerySamplerBindingOnUnit(static_cast<Int>(index))
|
||||
: QueryTextureBindingOnUnit(static_cast<Int>(index), textureBindingTarget);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1282,9 +1292,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
case GL_IMAGE_BINDING_LAYER:
|
||||
case GL_IMAGE_BINDING_ACCESS:
|
||||
case GL_IMAGE_BINDING_FORMAT: {
|
||||
const auto maxImageUnits = static_cast<GLuint>(std::min<GLint>(
|
||||
MG_Backend::pActiveBackendObject->GetDynamicParameters().MaxImageUnits,
|
||||
MG_State::GLState::TextureState::MAX_TEXTURE_IMAGE_UNITS));
|
||||
const auto maxImageUnits = static_cast<GLuint>(
|
||||
std::min<GLint>(MG_Backend::pActiveBackendObject->GetDynamicParameters().MaxImageUnits,
|
||||
MG_State::GLState::TextureState::MAX_TEXTURE_IMAGE_UNITS));
|
||||
if (index >= maxImageUnits) {
|
||||
*data = 0;
|
||||
MG_State::pGLContext->RecordError(
|
||||
@@ -1326,15 +1336,13 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (index >= 3) {
|
||||
*data = 0;
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"Compute work group index is out of range."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"Compute work group index is out of range."));
|
||||
return;
|
||||
}
|
||||
|
||||
const GLint minimum = target == GL_MAX_COMPUTE_WORK_GROUP_COUNT
|
||||
? GetMinComputeWorkGroupCount(index)
|
||||
: GetMinComputeWorkGroupSize(index);
|
||||
const GLint minimum = target == GL_MAX_COMPUTE_WORK_GROUP_COUNT ? GetMinComputeWorkGroupCount(index)
|
||||
: GetMinComputeWorkGroupSize(index);
|
||||
GLint backendValue = 0;
|
||||
if (getIntegeri) {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
@@ -1343,7 +1351,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// the apply thread before every compute dispatch validation.
|
||||
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) {
|
||||
#endif
|
||||
MGP_FILL(GetIntegeri_v);
|
||||
MGP_FILL(GetIntegeri_v);
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
}
|
||||
#endif
|
||||
@@ -1357,7 +1365,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
*data = 0;
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "Backend does not support indexed integer queries."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"Backend does not support indexed integer queries."));
|
||||
return;
|
||||
}
|
||||
getIntegeri(target, index, data);
|
||||
@@ -1939,7 +1948,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
*params = static_cast<GLint>(MG_Util::ConvertCullFaceModeToGLEnum(MG_State::pGLContext->GetCullFaceMode()));
|
||||
return;
|
||||
case GL_FRONT_FACE:
|
||||
*params = static_cast<GLint>(MG_Util::ConvertFrontFaceModeToGLEnum(MG_State::pGLContext->GetFrontFaceMode()));
|
||||
*params =
|
||||
static_cast<GLint>(MG_Util::ConvertFrontFaceModeToGLEnum(MG_State::pGLContext->GetFrontFaceMode()));
|
||||
return;
|
||||
case GL_CURRENT_PROGRAM: {
|
||||
const auto& currentProgram = MG_State::pGLContext->GetCurrentProgram();
|
||||
@@ -1968,9 +1978,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::DebugOutput) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_DEBUG_OUTPUT_SYNCHRONOUS:
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::DebugOutputSynchronous)
|
||||
? GL_TRUE
|
||||
: GL_FALSE;
|
||||
*params =
|
||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::DebugOutputSynchronous) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_DITHER:
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::Dither) ? GL_TRUE : GL_FALSE;
|
||||
@@ -2001,8 +2010,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
case GL_DRAW_BUFFER13:
|
||||
case GL_DRAW_BUFFER14:
|
||||
case GL_DRAW_BUFFER15:
|
||||
if (const auto& fbo = MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Draw)
|
||||
.GetBoundObject()) {
|
||||
if (const auto& fbo =
|
||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Draw).GetBoundObject()) {
|
||||
SizeT drawBufferIndex = 0;
|
||||
const bool decoded = TryDecodeDrawBufferQuery(pname, drawBufferIndex);
|
||||
MOBILEGL_ASSERT(decoded, "Draw buffer query enum should have been decoded already: 0x%X", pname);
|
||||
@@ -2340,7 +2349,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
*params = MG_State::pGLContext->GetPixelStoreParam(PixelStoreParam::PackSwapBytes);
|
||||
return;
|
||||
case GL_PIXEL_PACK_BUFFER_BINDING:
|
||||
if (const auto& obj = MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::PixelPack).GetBoundObject()) {
|
||||
if (const auto& obj =
|
||||
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::PixelPack).GetBoundObject()) {
|
||||
*params = static_cast<GLint>(obj->GetExternalIndex());
|
||||
} else {
|
||||
*params = 0;
|
||||
@@ -2366,8 +2376,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
*params = static_cast<GLint>(MG_State::pGLContext->GetPointSpriteCoordOrigin());
|
||||
return;
|
||||
case GL_PRIMITIVE_RESTART:
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::PrimitiveRestart) ? GL_TRUE
|
||||
: GL_FALSE;
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::PrimitiveRestart) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_PRIMITIVE_RESTART_INDEX:
|
||||
*params = static_cast<GLint>(MG_State::pGLContext->GetPrimitiveRestartIndex());
|
||||
@@ -2422,17 +2431,16 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
*params = static_cast<GLint>(MG_State::pGLContext->GetHint(pname));
|
||||
return;
|
||||
case GL_READ_BUFFER:
|
||||
if (const auto& fbo = MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Read)
|
||||
.GetBoundObject()) {
|
||||
*params =
|
||||
static_cast<GLint>(MG_Util::ConvertFramebufferAttachmentTypeToGLEnum(fbo->GetReadBuffer()));
|
||||
if (const auto& fbo =
|
||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Read).GetBoundObject()) {
|
||||
*params = static_cast<GLint>(MG_Util::ConvertFramebufferAttachmentTypeToGLEnum(fbo->GetReadBuffer()));
|
||||
} else {
|
||||
*params = 0;
|
||||
}
|
||||
return;
|
||||
case GL_RENDERBUFFER_BINDING:
|
||||
if (const auto& obj =
|
||||
MG_State::pGLContext->GetRenderbufferBindingSlot(RenderbufferTarget::Renderbuffer).GetBoundObject()) {
|
||||
if (const auto& obj = MG_State::pGLContext->GetRenderbufferBindingSlot(RenderbufferTarget::Renderbuffer)
|
||||
.GetBoundObject()) {
|
||||
*params = static_cast<GLint>(obj->GetExternalIndex());
|
||||
} else {
|
||||
*params = 0;
|
||||
@@ -2452,12 +2460,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleAlphaToCoverage) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_SAMPLE_ALPHA_TO_ONE:
|
||||
*params =
|
||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleAlphaToOne) ? GL_TRUE : GL_FALSE;
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleAlphaToOne) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_SAMPLE_COVERAGE:
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleCoverage) ? GL_TRUE
|
||||
: GL_FALSE;
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleCoverage) ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_SAMPLE_MASK:
|
||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::SampleMask) ? GL_TRUE : GL_FALSE;
|
||||
@@ -2504,24 +2510,20 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
RecordIndexedOnlyGetterError(__func__, pname);
|
||||
return;
|
||||
case GL_STENCIL_BACK_FAIL:
|
||||
*params = static_cast<GLint>(
|
||||
MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Back).FailOp));
|
||||
*params = static_cast<GLint>(MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Back).FailOp));
|
||||
return;
|
||||
case GL_STENCIL_BACK_FUNC:
|
||||
*params = static_cast<GLint>(
|
||||
MG_Util::ConvertDepthTestFuncToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Back).Func));
|
||||
MG_Util::ConvertDepthTestFuncToGLEnum(MG_State::pGLContext->GetStencilState(StencilFace::Back).Func));
|
||||
return;
|
||||
case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
|
||||
*params = static_cast<GLint>(
|
||||
MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Back).PassDepthFailOp));
|
||||
*params = static_cast<GLint>(MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Back).PassDepthFailOp));
|
||||
return;
|
||||
case GL_STENCIL_BACK_PASS_DEPTH_PASS:
|
||||
*params = static_cast<GLint>(
|
||||
MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Back).PassDepthPassOp));
|
||||
*params = static_cast<GLint>(MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Back).PassDepthPassOp));
|
||||
return;
|
||||
case GL_STENCIL_BACK_REF:
|
||||
*params = MG_State::pGLContext->GetStencilState(StencilFace::Back).Ref;
|
||||
@@ -2536,24 +2538,20 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
*params = static_cast<GLint>(MG_State::pGLContext->GetClearStencil());
|
||||
return;
|
||||
case GL_STENCIL_FAIL:
|
||||
*params = static_cast<GLint>(
|
||||
MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Front).FailOp));
|
||||
*params = static_cast<GLint>(MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Front).FailOp));
|
||||
return;
|
||||
case GL_STENCIL_FUNC:
|
||||
*params = static_cast<GLint>(
|
||||
MG_Util::ConvertDepthTestFuncToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Front).Func));
|
||||
MG_Util::ConvertDepthTestFuncToGLEnum(MG_State::pGLContext->GetStencilState(StencilFace::Front).Func));
|
||||
return;
|
||||
case GL_STENCIL_PASS_DEPTH_FAIL:
|
||||
*params = static_cast<GLint>(
|
||||
MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Front).PassDepthFailOp));
|
||||
*params = static_cast<GLint>(MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Front).PassDepthFailOp));
|
||||
return;
|
||||
case GL_STENCIL_PASS_DEPTH_PASS:
|
||||
*params = static_cast<GLint>(
|
||||
MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Front).PassDepthPassOp));
|
||||
*params = static_cast<GLint>(MG_Util::ConvertStencilOperationToGLEnum(
|
||||
MG_State::pGLContext->GetStencilState(StencilFace::Front).PassDepthPassOp));
|
||||
return;
|
||||
case GL_STENCIL_REF:
|
||||
*params = MG_State::pGLContext->GetStencilState(StencilFace::Front).Ref;
|
||||
@@ -2767,8 +2765,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
dynamicParameters.MaxUniformBlockSize);
|
||||
break;
|
||||
case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS:
|
||||
*params = std::max(dynamicParameters.MaxComputeWorkGroupInvocations,
|
||||
kFrontendMaxComputeWorkGroupInvocations);
|
||||
*params =
|
||||
std::max(dynamicParameters.MaxComputeWorkGroupInvocations, kFrontendMaxComputeWorkGroupInvocations);
|
||||
break;
|
||||
case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
|
||||
GetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, ¶ms[0]);
|
||||
@@ -2880,12 +2878,14 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// everything its own switch does not handle, does not report INVALID_ENUM for them.
|
||||
case GL_PATCH_DEFAULT_OUTER_LEVEL: {
|
||||
const FloatVec4& outer = MG_State::pGLContext->GetPatchDefaultOuterLevel();
|
||||
for (Uint i = 0; i < 4; ++i) params[i] = static_cast<GLint>(std::lround(outer[i]));
|
||||
for (Uint i = 0; i < 4; ++i)
|
||||
params[i] = static_cast<GLint>(std::lround(outer[i]));
|
||||
break;
|
||||
}
|
||||
case GL_PATCH_DEFAULT_INNER_LEVEL: {
|
||||
const FloatVec2& inner = MG_State::pGLContext->GetPatchDefaultInnerLevel();
|
||||
for (Uint i = 0; i < 2; ++i) params[i] = static_cast<GLint>(std::lround(inner[i]));
|
||||
for (Uint i = 0; i < 2; ++i)
|
||||
params[i] = static_cast<GLint>(std::lround(inner[i]));
|
||||
break;
|
||||
}
|
||||
// GL 4.6 core table 23.66: whether the primitive-restart index terminates a patch.
|
||||
@@ -2937,8 +2937,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
case GL_MAX_SHADER_STORAGE_BLOCK_SIZE:
|
||||
// 64-bit state (see GetInteger64v); the 32-bit query saturates, per the GL
|
||||
// state-query conversion rules.
|
||||
*params = static_cast<GLint>(std::min<Uint64>(dynamicParameters.MaxShaderStorageBlockSize,
|
||||
static_cast<Uint64>(INT32_MAX)));
|
||||
*params = static_cast<GLint>(
|
||||
std::min<Uint64>(dynamicParameters.MaxShaderStorageBlockSize, static_cast<Uint64>(INT32_MAX)));
|
||||
break;
|
||||
case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS:
|
||||
// NOT the frontend's binding-point array size: GetIndexedBufferQueryPointCount
|
||||
|
||||
@@ -41,14 +41,13 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// entry point handed a program name reported INVALID_VALUE; the conformance suite
|
||||
// reads exactly that code back from glSpecializeShader.
|
||||
const ErrorCode error = (shader != 0 && MG_State::pGLContext->ValidateProgramName(shader))
|
||||
? ErrorCode::InvalidOperation
|
||||
: ErrorCode::InvalidValue;
|
||||
? ErrorCode::InvalidOperation
|
||||
: ErrorCode::InvalidValue;
|
||||
MG_State::pGLContext->RecordError(
|
||||
error,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
std::to_string(shader) +
|
||||
(error == ErrorCode::InvalidOperation ? " is not a shader object."
|
||||
: " is not a valid name.")));
|
||||
error, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
std::to_string(shader) + (error == ErrorCode::InvalidOperation
|
||||
? " is not a shader object."
|
||||
: " is not a valid name.")));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -74,15 +73,13 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// Programs and shaders share one name space: a name that exists but
|
||||
// belongs to a shader is INVALID_OPERATION, a name GL never handed
|
||||
// out is INVALID_VALUE (GL 3.3 core 2.11.x).
|
||||
const ErrorCode error = MG_State::pGLContext->ValidateShaderName(program)
|
||||
? ErrorCode::InvalidOperation
|
||||
: ErrorCode::InvalidValue;
|
||||
const ErrorCode error = MG_State::pGLContext->ValidateShaderName(program) ? ErrorCode::InvalidOperation
|
||||
: ErrorCode::InvalidValue;
|
||||
MG_State::pGLContext->RecordError(
|
||||
error,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
std::to_string(program) +
|
||||
(error == ErrorCode::InvalidOperation ? " is not a program object."
|
||||
: " is not a valid name.")));
|
||||
error, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
std::to_string(program) + (error == ErrorCode::InvalidOperation
|
||||
? " is not a program object."
|
||||
: " is not a valid name.")));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -103,17 +100,15 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return programObject;
|
||||
}
|
||||
|
||||
static const SharedPtr<MG_State::GLState::ProgramObject>& TryToGetLinkedProgramForInterfaceQuery(GLuint program,
|
||||
const char* caller) {
|
||||
static const SharedPtr<MG_State::GLState::ProgramObject>& TryToGetLinkedProgramForInterfaceQuery(
|
||||
GLuint program, const char* caller) {
|
||||
static const SharedPtr<MG_State::GLState::ProgramObject> nullProgramObject = nullptr;
|
||||
if (!MG_State::pGLContext->ValidateProgramName(program)) {
|
||||
const ErrorCode error = MG_State::pGLContext->ValidateShaderName(program)
|
||||
? ErrorCode::InvalidOperation
|
||||
: ErrorCode::InvalidValue;
|
||||
const ErrorCode error = MG_State::pGLContext->ValidateShaderName(program) ? ErrorCode::InvalidOperation
|
||||
: ErrorCode::InvalidValue;
|
||||
MG_State::pGLContext->RecordError(
|
||||
error,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
std::to_string(program) + " is not a linked program object."));
|
||||
error, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
std::to_string(program) + " is not a linked program object."));
|
||||
return nullProgramObject;
|
||||
}
|
||||
|
||||
@@ -137,13 +132,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const char* caller) {
|
||||
static const SharedPtr<MG_State::GLState::ProgramObject> nullProgramObject = nullptr;
|
||||
if (!MG_State::pGLContext->ValidateProgramName(program)) {
|
||||
const ErrorCode error = MG_State::pGLContext->ValidateShaderName(program)
|
||||
? ErrorCode::InvalidOperation
|
||||
: ErrorCode::InvalidValue;
|
||||
const ErrorCode error = MG_State::pGLContext->ValidateShaderName(program) ? ErrorCode::InvalidOperation
|
||||
: ErrorCode::InvalidValue;
|
||||
MG_State::pGLContext->RecordError(
|
||||
error,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
std::to_string(program) + " is not a program object."));
|
||||
error, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
std::to_string(program) + " is not a program object."));
|
||||
return nullProgramObject;
|
||||
}
|
||||
auto& programObject = MG_State::pGLContext->GetProgramObject(program);
|
||||
@@ -189,8 +182,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
break;
|
||||
case GL_MAX_NUM_ACTIVE_VARIABLES:
|
||||
valid = programInterface == GL_UNIFORM_BLOCK || programInterface == GL_ATOMIC_COUNTER_BUFFER ||
|
||||
programInterface == GL_SHADER_STORAGE_BLOCK ||
|
||||
programInterface == GL_TRANSFORM_FEEDBACK_BUFFER;
|
||||
programInterface == GL_SHADER_STORAGE_BLOCK || programInterface == GL_TRANSFORM_FEEDBACK_BUFFER;
|
||||
break;
|
||||
case GL_MAX_NUM_COMPATIBLE_SUBROUTINES:
|
||||
valid = IsSubroutineUniformInterface(programInterface);
|
||||
@@ -202,8 +194,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!valid) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"Unsupported program interface query."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "Unsupported program interface query."));
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
@@ -211,9 +202,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
static bool ValidateNamedProgramResourceInterface(GLenum programInterface, const char* caller) {
|
||||
if (!ProgramInterface::IsNamedInterface(programInterface)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
"Unsupported named program resource interface."));
|
||||
ErrorCode::InvalidEnum, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
"Unsupported named program resource interface."));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -253,8 +243,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (unit < 0 || unit >= limit) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"Opaque uniform unit is out of range."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName, "Opaque uniform unit is out of range."));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -298,8 +287,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"Shader storage block binding is out of range."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "Shader storage block binding is out of range."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -409,10 +397,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
for (GLsizei i = 0; i < count; ++i) {
|
||||
if (!seen.insert(shaders[i]).second) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"shader " + std::to_string(shaders[i]) +
|
||||
" appears more than once in `shaders`."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"shader " + std::to_string(shaders[i]) +
|
||||
" appears more than once in `shaders`."));
|
||||
return;
|
||||
}
|
||||
if (!MG_State::pGLContext->ValidateShaderName(shaders[i])) {
|
||||
@@ -433,8 +420,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// they reach SPIRV-Cross, which parses rather than validates. ARB_gl_spirv lets an
|
||||
// implementation reject an invalid module at either call; rejecting at the earlier one
|
||||
// means the application's error is reported next to the data that caused it.
|
||||
if (const auto validated = MG_Util::ShaderTranspiler::ShaderCompiler::ValidateSpirvModule(module);
|
||||
!validated) {
|
||||
if (const auto validated = MG_Util::ShaderTranspiler::ShaderCompiler::ValidateSpirvModule(module); !validated) {
|
||||
MGLOG_D("%s: rejected SPIR-V module: %s", __func__, validated.error().log.c_str());
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
@@ -514,8 +500,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
auto specialized = MG_Util::ShaderTranspiler::ShaderCompiler::SpecializeAndDecompileSpirvModule(
|
||||
shaderObject->GetSpirvBinary(), shaderType, entryPoint, constantIds, constantValues, failure);
|
||||
if (!specialized) {
|
||||
MGLOG_D("%s: specialization failed for shader %u: %s", __func__, shader,
|
||||
specialized.error().log.c_str());
|
||||
MGLOG_D("%s: specialization failed for shader %u: %s", __func__, shader, specialized.error().log.c_str());
|
||||
// The two conditions ARB_gl_spirv ENUMERATES are GL errors, and an erroring GL command
|
||||
// must have no other effect - so the shader object is left exactly as it was rather
|
||||
// than being pushed into a failed-compile state. Anything else is a genuine compile
|
||||
@@ -999,10 +984,18 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
switch (pname) {
|
||||
case GL_GEOMETRY_VERTICES_OUT: *params = programObject->GetGeometryVerticesOut(); break;
|
||||
case GL_GEOMETRY_INPUT_TYPE: *params = static_cast<GLint>(programObject->GetGeometryInputType()); break;
|
||||
case GL_GEOMETRY_OUTPUT_TYPE: *params = static_cast<GLint>(programObject->GetGeometryOutputType()); break;
|
||||
default: *params = programObject->GetGeometryShaderInvocations(); break;
|
||||
case GL_GEOMETRY_VERTICES_OUT:
|
||||
*params = programObject->GetGeometryVerticesOut();
|
||||
break;
|
||||
case GL_GEOMETRY_INPUT_TYPE:
|
||||
*params = static_cast<GLint>(programObject->GetGeometryInputType());
|
||||
break;
|
||||
case GL_GEOMETRY_OUTPUT_TYPE:
|
||||
*params = static_cast<GLint>(programObject->GetGeometryOutputType());
|
||||
break;
|
||||
default:
|
||||
*params = programObject->GetGeometryShaderInvocations();
|
||||
break;
|
||||
}
|
||||
MGLOG_D("%s: %s = %d", __func__, MG_Util::ConvertGLEnumToString(pname).c_str(), *params);
|
||||
break;
|
||||
@@ -1035,12 +1028,18 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
switch (pname) {
|
||||
case GL_TESS_GEN_MODE: *params = static_cast<GLint>(programObject->GetTessGenMode()); break;
|
||||
case GL_TESS_GEN_SPACING: *params = static_cast<GLint>(programObject->GetTessGenSpacing()); break;
|
||||
case GL_TESS_GEN_MODE:
|
||||
*params = static_cast<GLint>(programObject->GetTessGenMode());
|
||||
break;
|
||||
case GL_TESS_GEN_SPACING:
|
||||
*params = static_cast<GLint>(programObject->GetTessGenSpacing());
|
||||
break;
|
||||
case GL_TESS_GEN_VERTEX_ORDER:
|
||||
*params = static_cast<GLint>(programObject->GetTessGenVertexOrder());
|
||||
break;
|
||||
default: *params = programObject->GetTessGenPointMode() ? GL_TRUE : GL_FALSE; break;
|
||||
default:
|
||||
*params = programObject->GetTessGenPointMode() ? GL_TRUE : GL_FALSE;
|
||||
break;
|
||||
}
|
||||
MGLOG_D("%s: %s = %d", __func__, MG_Util::ConvertGLEnumToString(pname).c_str(), *params);
|
||||
break;
|
||||
@@ -1254,8 +1253,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const SizeT span = UniformStorageSpanInBytes(ttype, size, nativeFloat64);
|
||||
if (pUBO == nullptr || offset == MG_State::GLState::ProgramObject::kInvalidUniformOffset ||
|
||||
offset + span > programObject->GetUBOSize()) {
|
||||
MGLOG_E_ONCE("%s: uniform at program %u location %d has no backing storage; returning nothing", __func__,
|
||||
program, location);
|
||||
MGLOG_E_ONCE("%s: uniform at program %u location %d has no backing storage; returning nothing",
|
||||
__func__, program, location);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1310,7 +1309,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (pUBO == nullptr || offset == MG_State::GLState::ProgramObject::kInvalidUniformOffset ||
|
||||
offset + span > programObject->GetUBOSize()) {
|
||||
MGLOG_E_ONCE("%s: uniform at program %u location %d has no backing storage; returning nothing", __func__,
|
||||
program, location);
|
||||
program, location);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1332,8 +1331,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// glUniform*d that stored it and not here.
|
||||
if (ttype.isDouble) {
|
||||
const Int columns = ttype.isMatrix ? ttype.matrixCols : 1;
|
||||
const Int rows = ttype.isMatrix ? ttype.matrixRows
|
||||
: (ttype.isVector ? ttype.vectorSize : 1);
|
||||
const Int rows = ttype.isMatrix ? ttype.matrixRows : (ttype.isVector ? ttype.vectorSize : 1);
|
||||
// A non-matrix is one tightly packed run and never reaches the stride at all.
|
||||
const SizeT columnStride =
|
||||
MG_State::GLState::ProgramObject::UniformMatrixColumnStride(ttype, nativeFloat64);
|
||||
@@ -1346,8 +1344,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
sizeof(GLdouble));
|
||||
} else {
|
||||
GLfloat narrow = 0.0f;
|
||||
Memcpy(&narrow, pUBO + offset + column * columnStride + row * componentSize,
|
||||
sizeof(narrow));
|
||||
Memcpy(&narrow, pUBO + offset + column * columnStride + row * componentSize, sizeof(narrow));
|
||||
component = static_cast<GLdouble>(narrow);
|
||||
}
|
||||
if constexpr (std::is_integral_v<T>) {
|
||||
@@ -1438,9 +1435,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
MG_State::pGLContext->GetTransformFeedbackProgram().get() == programObject.get()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", __func__,
|
||||
"The program used by active transform feedback cannot be relinked."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"The program used by active transform feedback cannot be relinked."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1489,8 +1485,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// The program in use may not change while transform feedback is active - unless
|
||||
// the capture is paused, which is exactly what ARB_transform_feedback2 added the
|
||||
// pause for (GL 4.6 core 7.3).
|
||||
if (MG_State::pGLContext->IsTransformFeedbackActive() &&
|
||||
!MG_State::pGLContext->IsTransformFeedbackPaused()) {
|
||||
if (MG_State::pGLContext->IsTransformFeedbackActive() && !MG_State::pGLContext->IsTransformFeedbackPaused()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
@@ -1538,9 +1533,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
SizeT writeSize = ItemCount * sizeof(T);
|
||||
if (size < writeSize) {
|
||||
// Metadata bug: degrade to a clamped copy instead of killing the process.
|
||||
MGLOG_E_ONCE("%s: uniform size mismatch at program %u location %u: expected at least %zu bytes, got %zu "
|
||||
"bytes; clamping",
|
||||
__func__, programObject.GetExternalIndex(), location, ItemCount * sizeof(T), size);
|
||||
MGLOG_E_ONCE(
|
||||
"%s: uniform size mismatch at program %u location %u: expected at least %zu bytes, got %zu "
|
||||
"bytes; clamping",
|
||||
__func__, programObject.GetExternalIndex(), location, ItemCount * sizeof(T), size);
|
||||
writeSize = size;
|
||||
}
|
||||
// The uniform shadow's LAYOUT is phase-B data, so a write that lands while the
|
||||
@@ -1560,9 +1556,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// Should not happen: linking gives every settable uniform backing
|
||||
// storage. Log and drop the write instead of faulting.
|
||||
MGLOG_E_ONCE("%s: uniform at program %u location %u has no backing storage (ubo=%p offset=%u size=%zu "
|
||||
"uboSize=%zu); dropping write",
|
||||
__func__, programObject.GetExternalIndex(), location, static_cast<void*>(pUBO), offset,
|
||||
writeSize, uboSize);
|
||||
"uboSize=%zu); dropping write",
|
||||
__func__, programObject.GetExternalIndex(), location, static_cast<void*>(pUBO), offset,
|
||||
writeSize, uboSize);
|
||||
return;
|
||||
}
|
||||
MGLOG_D("%s: program = %d, location = %d, byteOffset = %d", __func__, programObject.GetExternalIndex(),
|
||||
@@ -1659,8 +1655,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
break;
|
||||
}
|
||||
if (!programObject->IsValidUniformLocation(location + offset)) {
|
||||
RecordInvalidUniformLocationError(__func__, location + offset,
|
||||
"program " + std::to_string(program));
|
||||
RecordInvalidUniformLocationError(__func__, location + offset, "program " + std::to_string(program));
|
||||
return;
|
||||
}
|
||||
Uniform_State<ItemCount>(*programObject, location + offset, value + offset * ItemCount);
|
||||
@@ -1719,7 +1714,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
Vector<GLfloat> narrowed(static_cast<SizeT>(count) * ItemCount);
|
||||
for (SizeT i = 0; i < narrowed.size(); ++i) narrowed[i] = static_cast<GLfloat>(value[i]);
|
||||
for (SizeT i = 0; i < narrowed.size(); ++i)
|
||||
narrowed[i] = static_cast<GLfloat>(value[i]);
|
||||
Uniformv_State<ItemCount>(location, count, narrowed.data());
|
||||
}
|
||||
|
||||
@@ -1734,7 +1730,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
Vector<GLfloat> narrowed(static_cast<SizeT>(count) * ItemCount);
|
||||
for (SizeT i = 0; i < narrowed.size(); ++i) narrowed[i] = static_cast<GLfloat>(value[i]);
|
||||
for (SizeT i = 0; i < narrowed.size(); ++i)
|
||||
narrowed[i] = static_cast<GLfloat>(value[i]);
|
||||
ProgramUniformv_State<ItemCount>(program, location, count, narrowed.data());
|
||||
}
|
||||
|
||||
@@ -1776,9 +1773,15 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
const SizeT byteOffset = static_cast<SizeT>(c) * kColumnStride;
|
||||
switch (rows) {
|
||||
case 2: Uniform_State<2>(programObject, location + matrix, column, byteOffset); break;
|
||||
case 3: Uniform_State<3>(programObject, location + matrix, column, byteOffset); break;
|
||||
default: Uniform_State<4>(programObject, location + matrix, column, byteOffset); break;
|
||||
case 2:
|
||||
Uniform_State<2>(programObject, location + matrix, column, byteOffset);
|
||||
break;
|
||||
case 3:
|
||||
Uniform_State<3>(programObject, location + matrix, column, byteOffset);
|
||||
break;
|
||||
default:
|
||||
Uniform_State<4>(programObject, location + matrix, column, byteOffset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1793,8 +1796,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// Minecraft calls thousands of times a frame for a case no shader pack ever takes.
|
||||
template <typename Program>
|
||||
void UniformMatrixdvNative_Object(Program& programObject, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value, Int columns, Int rows,
|
||||
const String& ownerDescription) {
|
||||
const GLdouble* value, Int columns, Int rows, const String& ownerDescription) {
|
||||
const SizeT columnStride = rows <= 2 ? 2 * sizeof(GLdouble) : 4 * sizeof(GLdouble);
|
||||
const SizeT componentCount = static_cast<SizeT>(columns) * static_cast<SizeT>(rows);
|
||||
GLdouble column[4] = {};
|
||||
@@ -1818,9 +1820,15 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
const SizeT byteOffset = static_cast<SizeT>(c) * columnStride;
|
||||
switch (rows) {
|
||||
case 2: Uniform_State<2>(programObject, location + matrix, column, byteOffset); break;
|
||||
case 3: Uniform_State<3>(programObject, location + matrix, column, byteOffset); break;
|
||||
default: Uniform_State<4>(programObject, location + matrix, column, byteOffset); break;
|
||||
case 2:
|
||||
Uniform_State<2>(programObject, location + matrix, column, byteOffset);
|
||||
break;
|
||||
case 3:
|
||||
Uniform_State<3>(programObject, location + matrix, column, byteOffset);
|
||||
break;
|
||||
default:
|
||||
Uniform_State<4>(programObject, location + matrix, column, byteOffset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1843,9 +1851,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
const SizeT componentCount = static_cast<SizeT>(columns) * static_cast<SizeT>(rows);
|
||||
Vector<GLfloat> narrowed(static_cast<SizeT>(count) * componentCount);
|
||||
for (SizeT i = 0; i < narrowed.size(); ++i) narrowed[i] = static_cast<GLfloat>(value[i]);
|
||||
UniformMatrixfv_Object(programObject, "glUniformMatrixdv", location, count, transpose, narrowed.data(),
|
||||
columns, rows, "the current program object");
|
||||
for (SizeT i = 0; i < narrowed.size(); ++i)
|
||||
narrowed[i] = static_cast<GLfloat>(value[i]);
|
||||
UniformMatrixfv_Object(programObject, "glUniformMatrixdv", location, count, transpose, narrowed.data(), columns,
|
||||
rows, "the current program object");
|
||||
}
|
||||
|
||||
// Helper function to transpose a 2x2 matrix
|
||||
@@ -2267,13 +2276,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
MGLOG_D("%s: GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = %d", __func__, *params);
|
||||
break;
|
||||
case GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER:
|
||||
*params =
|
||||
BoolToGLInt(programObject->IsUniformBlockReferencedByStage(blockIndex, EShLangTessControl));
|
||||
*params = BoolToGLInt(programObject->IsUniformBlockReferencedByStage(blockIndex, EShLangTessControl));
|
||||
MGLOG_D("%s: GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER = %d", __func__, *params);
|
||||
break;
|
||||
case GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER:
|
||||
*params =
|
||||
BoolToGLInt(programObject->IsUniformBlockReferencedByStage(blockIndex, EShLangTessEvaluation));
|
||||
*params = BoolToGLInt(programObject->IsUniformBlockReferencedByStage(blockIndex, EShLangTessEvaluation));
|
||||
MGLOG_D("%s: GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER = %d", __func__, *params);
|
||||
break;
|
||||
case GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER:
|
||||
@@ -2367,8 +2374,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const auto& dynamicParameters = MG_Backend::pActiveBackendObject->GetDynamicParameters();
|
||||
// colorNumber is bounded by GL_MAX_DRAW_BUFFERS for index 0, and by
|
||||
// GL_MAX_DUAL_SOURCE_DRAW_BUFFERS (which MobileGL reports as 1) for index 1.
|
||||
const GLuint colorNumberLimit =
|
||||
(index == 0) ? static_cast<GLuint>(dynamicParameters.MaxDrawBuffers) : 1u;
|
||||
const GLuint colorNumberLimit = (index == 0) ? static_cast<GLuint>(dynamicParameters.MaxDrawBuffers) : 1u;
|
||||
if (colorNumber >= colorNumberLimit) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
@@ -2771,7 +2777,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ProgramUniformMatrix2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value) {
|
||||
const GLdouble* value) {
|
||||
auto& programObject = TryToGetProgramObject(program);
|
||||
if (!programObject) return;
|
||||
if (!programObject->GetLinkStatus()) {
|
||||
@@ -2797,7 +2803,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ProgramUniformMatrix3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value) {
|
||||
const GLdouble* value) {
|
||||
auto& programObject = TryToGetProgramObject(program);
|
||||
if (!programObject) return;
|
||||
if (!programObject->GetLinkStatus()) {
|
||||
@@ -2823,7 +2829,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ProgramUniformMatrix4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value) {
|
||||
const GLdouble* value) {
|
||||
auto& programObject = TryToGetProgramObject(program);
|
||||
if (!programObject) return;
|
||||
if (!programObject->GetLinkStatus()) {
|
||||
@@ -2849,7 +2855,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ProgramUniformMatrix2x3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value) {
|
||||
const GLdouble* value) {
|
||||
auto& programObject = TryToGetProgramObject(program);
|
||||
if (!programObject) return;
|
||||
if (!programObject->GetLinkStatus()) {
|
||||
@@ -2875,7 +2881,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ProgramUniformMatrix2x4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value) {
|
||||
const GLdouble* value) {
|
||||
auto& programObject = TryToGetProgramObject(program);
|
||||
if (!programObject) return;
|
||||
if (!programObject->GetLinkStatus()) {
|
||||
@@ -2901,7 +2907,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ProgramUniformMatrix3x2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value) {
|
||||
const GLdouble* value) {
|
||||
auto& programObject = TryToGetProgramObject(program);
|
||||
if (!programObject) return;
|
||||
if (!programObject->GetLinkStatus()) {
|
||||
@@ -2927,7 +2933,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ProgramUniformMatrix3x4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value) {
|
||||
const GLdouble* value) {
|
||||
auto& programObject = TryToGetProgramObject(program);
|
||||
if (!programObject) return;
|
||||
if (!programObject->GetLinkStatus()) {
|
||||
@@ -2953,7 +2959,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ProgramUniformMatrix4x2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value) {
|
||||
const GLdouble* value) {
|
||||
auto& programObject = TryToGetProgramObject(program);
|
||||
if (!programObject) return;
|
||||
if (!programObject->GetLinkStatus()) {
|
||||
@@ -2979,7 +2985,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void ProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value) {
|
||||
const GLdouble* value) {
|
||||
auto& programObject = TryToGetProgramObject(program);
|
||||
if (!programObject) return;
|
||||
if (!programObject->GetLinkStatus()) {
|
||||
@@ -3335,10 +3341,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
if (propCount <= 0 || bufSize < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"propCount must be positive and bufSize "
|
||||
"non-negative."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"propCount must be positive and bufSize "
|
||||
"non-negative."));
|
||||
return;
|
||||
}
|
||||
if (props == nullptr) return;
|
||||
@@ -3372,7 +3378,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
if (params == nullptr) return;
|
||||
const GLsizei written = static_cast<GLsizei>(std::min<SizeT>(values.size(), static_cast<SizeT>(bufSize)));
|
||||
for (GLsizei i = 0; i < written; ++i) params[i] = values[i];
|
||||
for (GLsizei i = 0; i < written; ++i)
|
||||
params[i] = values[i];
|
||||
if (length) *length = written;
|
||||
}
|
||||
|
||||
@@ -3384,8 +3391,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!ProgramInterface::InterfaceHasLocations(programInterface)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"Program interface has no locations."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "Program interface has no locations."));
|
||||
return -1;
|
||||
}
|
||||
return ProgramInterface::GetResourceLocation(*programObject, programInterface, name);
|
||||
@@ -3468,7 +3474,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (params == nullptr) return;
|
||||
// GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES is the only multi-value property
|
||||
// here, and the caller sized its array from _ACTIVE_ATOMIC_COUNTERS.
|
||||
for (SizeT i = 0; i < values.size(); ++i) params[i] = values[i];
|
||||
for (SizeT i = 0; i < values.size(); ++i)
|
||||
params[i] = values[i];
|
||||
}
|
||||
|
||||
// GL 4.6 §7.6.2: <storageBlockIndex> is an active shader storage block index of <program>
|
||||
@@ -3482,8 +3489,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!programObject || !programObject->GetLinkStatus()) return;
|
||||
if (!ValidateShaderStorageBlockBinding(storageBlockBinding)) return;
|
||||
String blockName;
|
||||
if (!ProgramInterface::GetResourceName(*programObject, GL_SHADER_STORAGE_BLOCK, storageBlockIndex,
|
||||
blockName)) {
|
||||
if (!ProgramInterface::GetResourceName(*programObject, GL_SHADER_STORAGE_BLOCK, storageBlockIndex, blockName)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
@@ -3689,9 +3695,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (varying == nullptr) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", __func__,
|
||||
"index is not an active transform feedback varying of the program."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"index is not an active transform feedback varying of the program."));
|
||||
return;
|
||||
}
|
||||
if (size != nullptr) *size = varying->size;
|
||||
|
||||
@@ -146,8 +146,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
GLint GetFragDataIndex(GLuint program, const char* name);
|
||||
void GetProgramInterfaceiv(GLuint program, GLenum programInterface, GLenum pname, GLint* params);
|
||||
GLuint GetProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar* name);
|
||||
void GetProgramResourceName(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize,
|
||||
GLsizei* length, GLchar* name);
|
||||
void GetProgramResourceName(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length,
|
||||
GLchar* name);
|
||||
void GetProgramResourceiv(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount,
|
||||
const GLenum* props, GLsizei bufSize, GLsizei* length, GLint* params);
|
||||
GLint GetProgramResourceLocation(GLuint program, GLenum programInterface, const GLchar* name);
|
||||
@@ -171,23 +171,32 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void ProgramUniform4d(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
|
||||
void ProgramUniform4dv(GLuint program, GLint location, GLsizei count, const GLdouble* value);
|
||||
void UniformMatrix2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value);
|
||||
void UniformMatrix3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value);
|
||||
void UniformMatrix4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value);
|
||||
void UniformMatrix2x3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix2x3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix2x3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value);
|
||||
void UniformMatrix2x4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix2x4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix2x4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value);
|
||||
void UniformMatrix3x2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix3x2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix3x2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value);
|
||||
void UniformMatrix3x4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix3x4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix3x4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value);
|
||||
void UniformMatrix4x2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix4x2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix4x2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value);
|
||||
void UniformMatrix4x3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);
|
||||
void ProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLdouble* value);
|
||||
void GetUniformdv(GLuint program, GLint location, GLdouble* params);
|
||||
void ValidateProgram(GLuint program);
|
||||
void ProgramParameteri(GLuint program, GLenum pname, GLint value);
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace {
|
||||
void RecordPipelineError(ErrorCode code, const char* function, String message) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
code, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", function, Move(message)));
|
||||
MG_State::pGLContext->RecordError(code,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", function, Move(message)));
|
||||
}
|
||||
|
||||
// GL 4.6 core 7.4 asks only that the name came from GenProgramPipelines and has not been
|
||||
@@ -31,7 +31,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// rejected calls' error was left in the queue for the harness to find. One cause, both
|
||||
// symptoms.
|
||||
const SharedPtr<MG_State::GLState::ProgramPipelineObject>* TryGetPipeline(GLuint pipeline,
|
||||
const char* function) {
|
||||
const char* function) {
|
||||
const auto& object = MG_State::pGLContext->MaterializeProgramPipelineObject(pipeline);
|
||||
if (!object) {
|
||||
RecordPipelineError(ErrorCode::InvalidOperation, function,
|
||||
@@ -52,19 +52,32 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// GL 4.6 core table 7.1 maps each stage bit onto a shader stage.
|
||||
Bool TryResolveStageBit(GLbitfield bit, ShaderStage& outStage) {
|
||||
switch (bit) {
|
||||
case GL_VERTEX_SHADER_BIT: outStage = ShaderStage::Vertex; return true;
|
||||
case GL_TESS_CONTROL_SHADER_BIT: outStage = ShaderStage::TessControl; return true;
|
||||
case GL_TESS_EVALUATION_SHADER_BIT: outStage = ShaderStage::TessEval; return true;
|
||||
case GL_GEOMETRY_SHADER_BIT: outStage = ShaderStage::Geometry; return true;
|
||||
case GL_FRAGMENT_SHADER_BIT: outStage = ShaderStage::Fragment; return true;
|
||||
case GL_COMPUTE_SHADER_BIT: outStage = ShaderStage::Compute; return true;
|
||||
default: return false;
|
||||
case GL_VERTEX_SHADER_BIT:
|
||||
outStage = ShaderStage::Vertex;
|
||||
return true;
|
||||
case GL_TESS_CONTROL_SHADER_BIT:
|
||||
outStage = ShaderStage::TessControl;
|
||||
return true;
|
||||
case GL_TESS_EVALUATION_SHADER_BIT:
|
||||
outStage = ShaderStage::TessEval;
|
||||
return true;
|
||||
case GL_GEOMETRY_SHADER_BIT:
|
||||
outStage = ShaderStage::Geometry;
|
||||
return true;
|
||||
case GL_FRAGMENT_SHADER_BIT:
|
||||
outStage = ShaderStage::Fragment;
|
||||
return true;
|
||||
case GL_COMPUTE_SHADER_BIT:
|
||||
outStage = ShaderStage::Compute;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr GLbitfield kAllStageBits = GL_VERTEX_SHADER_BIT | GL_TESS_CONTROL_SHADER_BIT |
|
||||
GL_TESS_EVALUATION_SHADER_BIT | GL_GEOMETRY_SHADER_BIT |
|
||||
GL_FRAGMENT_SHADER_BIT | GL_COMPUTE_SHADER_BIT;
|
||||
GL_TESS_EVALUATION_SHADER_BIT | GL_GEOMETRY_SHADER_BIT |
|
||||
GL_FRAGMENT_SHADER_BIT | GL_COMPUTE_SHADER_BIT;
|
||||
} // namespace
|
||||
|
||||
void GenProgramPipelines(GLsizei n, GLuint* pipelines) {
|
||||
@@ -126,13 +139,27 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
*params = active ? static_cast<GLint>(active->GetExternalIndex()) : 0;
|
||||
break;
|
||||
}
|
||||
case GL_VERTEX_SHADER: *params = stageProgramName(ShaderStage::Vertex); break;
|
||||
case GL_TESS_CONTROL_SHADER: *params = stageProgramName(ShaderStage::TessControl); break;
|
||||
case GL_TESS_EVALUATION_SHADER: *params = stageProgramName(ShaderStage::TessEval); break;
|
||||
case GL_GEOMETRY_SHADER: *params = stageProgramName(ShaderStage::Geometry); break;
|
||||
case GL_FRAGMENT_SHADER: *params = stageProgramName(ShaderStage::Fragment); break;
|
||||
case GL_COMPUTE_SHADER: *params = stageProgramName(ShaderStage::Compute); break;
|
||||
case GL_VALIDATE_STATUS: *params = (*pipelineObject)->GetValidateStatus() ? GL_TRUE : GL_FALSE; break;
|
||||
case GL_VERTEX_SHADER:
|
||||
*params = stageProgramName(ShaderStage::Vertex);
|
||||
break;
|
||||
case GL_TESS_CONTROL_SHADER:
|
||||
*params = stageProgramName(ShaderStage::TessControl);
|
||||
break;
|
||||
case GL_TESS_EVALUATION_SHADER:
|
||||
*params = stageProgramName(ShaderStage::TessEval);
|
||||
break;
|
||||
case GL_GEOMETRY_SHADER:
|
||||
*params = stageProgramName(ShaderStage::Geometry);
|
||||
break;
|
||||
case GL_FRAGMENT_SHADER:
|
||||
*params = stageProgramName(ShaderStage::Fragment);
|
||||
break;
|
||||
case GL_COMPUTE_SHADER:
|
||||
*params = stageProgramName(ShaderStage::Compute);
|
||||
break;
|
||||
case GL_VALIDATE_STATUS:
|
||||
*params = (*pipelineObject)->GetValidateStatus() ? GL_TRUE : GL_FALSE;
|
||||
break;
|
||||
case GL_INFO_LOG_LENGTH: {
|
||||
// GL counts the null terminator, and reports 0 rather than 1 for an empty log.
|
||||
const auto& log = (*pipelineObject)->GetInfoLog();
|
||||
@@ -140,9 +167,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
RecordPipelineError(ErrorCode::InvalidEnum, __func__,
|
||||
std::format("pname {} is not a program pipeline parameter.",
|
||||
MG_Util::ConvertGLEnumToString(pname)));
|
||||
RecordPipelineError(
|
||||
ErrorCode::InvalidEnum, __func__,
|
||||
std::format("pname {} is not a program pipeline parameter.", MG_Util::ConvertGLEnumToString(pname)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
constexpr GLenum kObjectTypeArb = 0x8B4E;
|
||||
constexpr GLenum kObjectSubtypeArb = 0x8B4F;
|
||||
|
||||
enum class ObjectKind { None, Program, Shader };
|
||||
enum class ObjectKind {
|
||||
None,
|
||||
Program,
|
||||
Shader
|
||||
};
|
||||
|
||||
ObjectKind KindOf(GLuint obj) {
|
||||
if (obj == 0) return ObjectKind::None;
|
||||
@@ -52,9 +56,14 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void DeleteObjectARB(GLuint obj) {
|
||||
if (obj == 0) return;
|
||||
switch (KindOf(obj)) {
|
||||
case ObjectKind::Program: DeleteProgram(obj); return;
|
||||
case ObjectKind::Shader: DeleteShader(obj); return;
|
||||
case ObjectKind::None: break;
|
||||
case ObjectKind::Program:
|
||||
DeleteProgram(obj);
|
||||
return;
|
||||
case ObjectKind::Shader:
|
||||
DeleteShader(obj);
|
||||
return;
|
||||
case ObjectKind::None:
|
||||
break;
|
||||
}
|
||||
Fail(ErrorCode::InvalidValue, __func__, std::to_string(obj) + " is not a shader or program object.");
|
||||
}
|
||||
@@ -81,18 +90,26 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
switch (pname) {
|
||||
case kObjectTypeArb:
|
||||
case GL_DELETE_STATUS:
|
||||
case GL_INFO_LOG_LENGTH: programParam = shaderParam = true; break;
|
||||
case GL_INFO_LOG_LENGTH:
|
||||
programParam = shaderParam = true;
|
||||
break;
|
||||
case kObjectSubtypeArb:
|
||||
case GL_COMPILE_STATUS:
|
||||
case GL_SHADER_SOURCE_LENGTH: shaderParam = true; break;
|
||||
case GL_SHADER_SOURCE_LENGTH:
|
||||
shaderParam = true;
|
||||
break;
|
||||
case GL_LINK_STATUS:
|
||||
case GL_VALIDATE_STATUS:
|
||||
case GL_ATTACHED_SHADERS:
|
||||
case GL_ACTIVE_UNIFORMS:
|
||||
case GL_ACTIVE_UNIFORM_MAX_LENGTH:
|
||||
case GL_ACTIVE_ATTRIBUTES:
|
||||
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: programParam = true; break;
|
||||
default: Fail(ErrorCode::InvalidEnum, func, "pname is not a GetObjectParameterARB parameter."); return false;
|
||||
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
|
||||
programParam = true;
|
||||
break;
|
||||
default:
|
||||
Fail(ErrorCode::InvalidEnum, func, "pname is not a GetObjectParameterARB parameter.");
|
||||
return false;
|
||||
}
|
||||
const ObjectKind kind = KindOf(obj);
|
||||
if (kind == ObjectKind::None) {
|
||||
@@ -123,14 +140,20 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
void GetObjectParameterfvARB(GLuint obj, GLenum pname, GLfloat* params) {
|
||||
GLint value = 0;
|
||||
if (QueryObjectParameter(obj, pname, &value, __func__) && params != nullptr) *params = static_cast<GLfloat>(value);
|
||||
if (QueryObjectParameter(obj, pname, &value, __func__) && params != nullptr)
|
||||
*params = static_cast<GLfloat>(value);
|
||||
}
|
||||
|
||||
void GetInfoLogARB(GLuint obj, GLsizei maxLength, GLsizei* length, GLchar* infoLog) {
|
||||
switch (KindOf(obj)) {
|
||||
case ObjectKind::Program: GetProgramInfoLog(obj, maxLength, length, infoLog); return;
|
||||
case ObjectKind::Shader: GetShaderInfoLog(obj, maxLength, length, infoLog); return;
|
||||
case ObjectKind::None: break;
|
||||
case ObjectKind::Program:
|
||||
GetProgramInfoLog(obj, maxLength, length, infoLog);
|
||||
return;
|
||||
case ObjectKind::Shader:
|
||||
GetShaderInfoLog(obj, maxLength, length, infoLog);
|
||||
return;
|
||||
case ObjectKind::None:
|
||||
break;
|
||||
}
|
||||
Fail(ErrorCode::InvalidValue, __func__, std::to_string(obj) + " is not a shader or program object.");
|
||||
}
|
||||
|
||||
@@ -99,8 +99,7 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
// "[0]" the enumeration appends to an array.
|
||||
Bool NamesMatch(const String& resourceName, const String& query) {
|
||||
if (resourceName == query) return true;
|
||||
if (EndsWithZeroSubscript(resourceName) &&
|
||||
resourceName.compare(0, resourceName.length() - 3, query) == 0) {
|
||||
if (EndsWithZeroSubscript(resourceName) && resourceName.compare(0, resourceName.length() - 3, query) == 0) {
|
||||
return true;
|
||||
}
|
||||
return EndsWithZeroSubscript(query) && query.compare(0, query.length() - 3, resourceName) == 0;
|
||||
@@ -189,7 +188,7 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
const bool rowMajor = type.layoutMatrix == static_cast<Int>(glslang::ElmRowMajor);
|
||||
const int strideVectorComponents = rowMajor ? type.matrixCols : type.matrixRows;
|
||||
constexpr int scalarSize = 4;
|
||||
const int vectorAlignment = (strideVectorComponents <= 1) ? scalarSize
|
||||
const int vectorAlignment = (strideVectorComponents <= 1) ? scalarSize
|
||||
: (strideVectorComponents == 2) ? 2 * scalarSize
|
||||
: 4 * scalarSize;
|
||||
return (vectorAlignment + 15) & ~15;
|
||||
@@ -225,8 +224,7 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
// Note the union is used even when it is empty: an array element nobody dereferenced has
|
||||
// no member bits and is genuinely referenced by nobody, which is the whole point - falling
|
||||
// back to the block's own mask there would restore the over-approximation.
|
||||
Vector<Uint32> BuildBlockStagesFromMembers(const ProgramObject::LinkArtifacts& reflection,
|
||||
Int blockCount) {
|
||||
Vector<Uint32> BuildBlockStagesFromMembers(const ProgramObject::LinkArtifacts& reflection, Int blockCount) {
|
||||
Vector<Uint32> stagesByBlock(static_cast<SizeT>(blockCount < 0 ? 0 : blockCount), 0u);
|
||||
const Int uniformCount = static_cast<Int>(reflection.uniformReflection.size());
|
||||
for (Int index = 0; index < uniformCount; ++index) {
|
||||
@@ -313,20 +311,19 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
const Int blockIndex = program.BlockIndexFromGlUniformBlock(static_cast<Uint>(glIndex));
|
||||
Resource resource;
|
||||
resource.name = program.GetUniformBlockName(static_cast<Uint>(blockIndex));
|
||||
resource.bufferBinding = static_cast<GLint>(program.GetUniformBlockBinding(static_cast<Uint>(blockIndex)));
|
||||
resource.bufferBinding =
|
||||
static_cast<GLint>(program.GetUniformBlockBinding(static_cast<Uint>(blockIndex)));
|
||||
resource.bufferDataSize = static_cast<GLint>(program.GetUBOSizeAt(static_cast<Uint>(blockIndex)));
|
||||
const Int tIndex = program.TProgramBlockIndex(static_cast<Uint>(blockIndex));
|
||||
if (tIndex >= 0 && tIndex < blockCount) {
|
||||
resource.stages = UniformBlockStages(reflection.blockReflection[tIndex],
|
||||
stagesFromMembers, tIndex);
|
||||
resource.stages = UniformBlockStages(reflection.blockReflection[tIndex], stagesFromMembers, tIndex);
|
||||
}
|
||||
model.uniformBlocks.push_back(Move(resource));
|
||||
}
|
||||
}
|
||||
|
||||
void BuildUniformsAndBufferVariables(ProgramObject& program,
|
||||
const ProgramObject::LinkArtifacts& reflection, Model& model,
|
||||
const Vector<BlockKind>& blockKind,
|
||||
void BuildUniformsAndBufferVariables(ProgramObject& program, const ProgramObject::LinkArtifacts& reflection,
|
||||
Model& model, const Vector<BlockKind>& blockKind,
|
||||
const Vector<Int>& blockInterfaceIndex) {
|
||||
// Walks the TPROGRAM uniform space, not the GL one. A buffer variable is not a GL
|
||||
// uniform (GL 4.6 core 7.3.1) and DoReflection therefore keeps it out of the GL
|
||||
@@ -388,8 +385,7 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
// A member of a named uniform block has no location, whatever the
|
||||
// frontend's own location table says (it hands one out to every uniform
|
||||
// so glUniform* can address block members through the global UBO).
|
||||
resource.location =
|
||||
resource.blockIndex >= 0 ? -1 : program.GetUniformLocation(refl.name);
|
||||
resource.location = resource.blockIndex >= 0 ? -1 : program.GetUniformLocation(refl.name);
|
||||
}
|
||||
model.uniforms.push_back(Move(resource));
|
||||
}
|
||||
@@ -432,7 +428,9 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
// program that redeclares `out gl_PerVertex { vec4 gl_Position; }` still carries
|
||||
// gl_PointSize and gl_ClipDistance through the block-unwrapping reflection, and they
|
||||
// are not part of its output interface.
|
||||
Bool IsHiddenBlockMember(const ProgramObject::TypeFacts& type) { return type.isVoid; }
|
||||
Bool IsHiddenBlockMember(const ProgramObject::TypeFacts& type) {
|
||||
return type.isVoid;
|
||||
}
|
||||
|
||||
void BuildStageIO(ProgramObject& program, const ProgramObject::LinkArtifacts& reflection, Model& model) {
|
||||
const Int inputCount = static_cast<Int>(reflection.pipeInputReflection.size());
|
||||
@@ -663,12 +661,12 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
programInterface == GL_VERTEX_SUBROUTINE || programInterface == GL_TESS_CONTROL_SUBROUTINE ||
|
||||
programInterface == GL_TESS_EVALUATION_SUBROUTINE || programInterface == GL_GEOMETRY_SUBROUTINE ||
|
||||
programInterface == GL_FRAGMENT_SUBROUTINE || programInterface == GL_COMPUTE_SUBROUTINE;
|
||||
const Bool isSubroutineUniform =
|
||||
programInterface == GL_VERTEX_SUBROUTINE_UNIFORM ||
|
||||
programInterface == GL_TESS_CONTROL_SUBROUTINE_UNIFORM ||
|
||||
programInterface == GL_TESS_EVALUATION_SUBROUTINE_UNIFORM ||
|
||||
programInterface == GL_GEOMETRY_SUBROUTINE_UNIFORM ||
|
||||
programInterface == GL_FRAGMENT_SUBROUTINE_UNIFORM || programInterface == GL_COMPUTE_SUBROUTINE_UNIFORM;
|
||||
const Bool isSubroutineUniform = programInterface == GL_VERTEX_SUBROUTINE_UNIFORM ||
|
||||
programInterface == GL_TESS_CONTROL_SUBROUTINE_UNIFORM ||
|
||||
programInterface == GL_TESS_EVALUATION_SUBROUTINE_UNIFORM ||
|
||||
programInterface == GL_GEOMETRY_SUBROUTINE_UNIFORM ||
|
||||
programInterface == GL_FRAGMENT_SUBROUTINE_UNIFORM ||
|
||||
programInterface == GL_COMPUTE_SUBROUTINE_UNIFORM;
|
||||
|
||||
switch (prop) {
|
||||
case GL_NAME_LENGTH:
|
||||
@@ -677,8 +675,7 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
case GL_ARRAY_SIZE:
|
||||
return programInterface == GL_UNIFORM || programInterface == GL_PROGRAM_INPUT ||
|
||||
programInterface == GL_PROGRAM_OUTPUT || programInterface == GL_BUFFER_VARIABLE ||
|
||||
programInterface == GL_TRANSFORM_FEEDBACK_VARYING ||
|
||||
(prop == GL_ARRAY_SIZE && isSubroutineUniform);
|
||||
programInterface == GL_TRANSFORM_FEEDBACK_VARYING || (prop == GL_ARRAY_SIZE && isSubroutineUniform);
|
||||
case GL_OFFSET:
|
||||
return programInterface == GL_UNIFORM || programInterface == GL_BUFFER_VARIABLE ||
|
||||
programInterface == GL_TRANSFORM_FEEDBACK_VARYING;
|
||||
@@ -697,8 +694,7 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
// ends in an error - but INVALID_VALUE for the out-of-range index, not the
|
||||
// INVALID_OPERATION a narrower table would invent.
|
||||
return programInterface == GL_UNIFORM_BLOCK || programInterface == GL_ATOMIC_COUNTER_BUFFER ||
|
||||
programInterface == GL_SHADER_STORAGE_BLOCK ||
|
||||
programInterface == GL_TRANSFORM_FEEDBACK_BUFFER;
|
||||
programInterface == GL_SHADER_STORAGE_BLOCK || programInterface == GL_TRANSFORM_FEEDBACK_BUFFER;
|
||||
case GL_BUFFER_DATA_SIZE:
|
||||
return programInterface == GL_UNIFORM_BLOCK || programInterface == GL_ATOMIC_COUNTER_BUFFER ||
|
||||
programInterface == GL_SHADER_STORAGE_BLOCK;
|
||||
@@ -767,8 +763,7 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
// The layout controls of an interleaved capture are enumerable but not addressable
|
||||
// by name (GL 4.6 §7.3.1.1).
|
||||
if (programInterface == GL_TRANSFORM_FEEDBACK_VARYING &&
|
||||
(query == "gl_NextBuffer" ||
|
||||
(query.size() == 18 && query.compare(0, 17, "gl_SkipComponents") == 0))) {
|
||||
(query == "gl_NextBuffer" || (query.size() == 18 && query.compare(0, 17, "gl_SkipComponents") == 0))) {
|
||||
return GL_INVALID_INDEX;
|
||||
}
|
||||
for (SizeT i = 0; i < resources.size(); ++i) {
|
||||
@@ -834,7 +829,8 @@ namespace MobileGL::MG_Impl::GLImpl::ProgramInterface {
|
||||
outValues.push_back(static_cast<GLint>(resource.activeVariables.size()));
|
||||
break;
|
||||
case GL_ACTIVE_VARIABLES:
|
||||
for (const GLuint variable : resource.activeVariables) outValues.push_back(static_cast<GLint>(variable));
|
||||
for (const GLuint variable : resource.activeVariables)
|
||||
outValues.push_back(static_cast<GLint>(variable));
|
||||
break;
|
||||
case GL_REFERENCED_BY_VERTEX_SHADER:
|
||||
outValues.push_back(referencedBy(EShLangVertex));
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace MobileGL::MG_State::GLState {
|
||||
class ProgramObject;
|
||||
}
|
||||
} // namespace MobileGL::MG_State::GLState
|
||||
|
||||
// The GL program interface (ARB_program_interface_query / GL 4.3 §7.3.1) as a frontend
|
||||
// resource model.
|
||||
|
||||
@@ -126,8 +126,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
void RecordQueryError(ErrorCode code, const char* function, const char* message) {
|
||||
MG_State::pGLContext->RecordError(code,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", function, message));
|
||||
MG_State::pGLContext->RecordError(code, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", function, message));
|
||||
}
|
||||
|
||||
// The by-buffer query getters write the result into a buffer object instead of client
|
||||
@@ -197,9 +196,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// stage assembled - a paused span included - for GL_PRIMITIVES_GENERATED. One counter
|
||||
// for both targets would report the clamped written count as the generated one.
|
||||
Uint64 TransformFeedbackCounterForTarget(GLenum target) {
|
||||
return target == GL_PRIMITIVES_GENERATED
|
||||
? MG_State::pGLContext->GetTransformFeedbackGeneratedCounter()
|
||||
: MG_State::pGLContext->GetTransformFeedbackPrimitiveCounter();
|
||||
return target == GL_PRIMITIVES_GENERATED ? MG_State::pGLContext->GetTransformFeedbackGeneratedCounter()
|
||||
: MG_State::pGLContext->GetTransformFeedbackPrimitiveCounter();
|
||||
}
|
||||
|
||||
// The span's CPU accounting delta. Saturating: a snapshot left above its counter (a
|
||||
@@ -308,8 +306,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (queryObject->backendHandle) {
|
||||
const auto getQueryResult64 = MG_Backend::gBackendFunctionsTable.GL.GetQueryResult64;
|
||||
MGP_FILL(GetQueryResult64);
|
||||
if (getQueryResult64 &&
|
||||
!getQueryResult64(queryObject->backendHandle, /*wait=*/true, &result)) {
|
||||
if (getQueryResult64 && !getQueryResult64(queryObject->backendHandle, /*wait=*/true, &result)) {
|
||||
// The backend could not produce the result YET (e.g. a
|
||||
// Vulkan wait refusing to block on a not-yet-submitted
|
||||
// frame serial). Per the documented no-stall tradeoff
|
||||
@@ -479,13 +476,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void BeginQuery(GLenum target, GLuint id) {
|
||||
const Bool isTransformFeedbackQuery =
|
||||
target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN || target == GL_PRIMITIVES_GENERATED;
|
||||
const Bool isOcclusionQuery =
|
||||
(target == GL_SAMPLES_PASSED || target == GL_ANY_SAMPLES_PASSED ||
|
||||
target == GL_ANY_SAMPLES_PASSED_CONSERVATIVE) &&
|
||||
MGL_BACKEND_SLOT_CAP(BeginOcclusionQuery, MG_Pipe::kCapOcclusionQuery);
|
||||
const Bool isOcclusionQuery = (target == GL_SAMPLES_PASSED || target == GL_ANY_SAMPLES_PASSED ||
|
||||
target == GL_ANY_SAMPLES_PASSED_CONSERVATIVE) &&
|
||||
MGL_BACKEND_SLOT_CAP(BeginOcclusionQuery, MG_Pipe::kCapOcclusionQuery);
|
||||
const Bool isPipelineStatisticsQuery = IsPipelineStatisticsQueryTarget(target);
|
||||
if (target != GL_TIME_ELAPSED && !isTransformFeedbackQuery && !isOcclusionQuery &&
|
||||
!isPipelineStatisticsQuery) {
|
||||
if (target != GL_TIME_ELAPSED && !isTransformFeedbackQuery && !isOcclusionQuery && !isPipelineStatisticsQuery) {
|
||||
// GL_TIMESTAMP is not a valid BeginQuery target; the occlusion targets
|
||||
// need backend support.
|
||||
RecordQueryError(ErrorCode::InvalidEnum, __FUNCTION__, "Query target is not supported.");
|
||||
@@ -501,15 +496,15 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
RecordQueryError(ErrorCode::InvalidOperation, __FUNCTION__, "Query object does not exist.");
|
||||
return;
|
||||
}
|
||||
GLuint& activeQueryId = isPipelineStatisticsQuery
|
||||
? g_activePipelineStatisticsQueryIds[target]
|
||||
: (isTransformFeedbackQuery
|
||||
? (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN ? g_activePrimitivesWrittenQueryId
|
||||
: g_activePrimitivesGeneratedQueryId)
|
||||
: (isOcclusionQuery ? g_activeSamplesPassedQueryId : g_activeTimeElapsedQueryId));
|
||||
GLuint& activeQueryId =
|
||||
isPipelineStatisticsQuery
|
||||
? g_activePipelineStatisticsQueryIds[target]
|
||||
: (isTransformFeedbackQuery
|
||||
? (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN ? g_activePrimitivesWrittenQueryId
|
||||
: g_activePrimitivesGeneratedQueryId)
|
||||
: (isOcclusionQuery ? g_activeSamplesPassedQueryId : g_activeTimeElapsedQueryId));
|
||||
if (activeQueryId != 0) {
|
||||
RecordQueryError(ErrorCode::InvalidOperation, __FUNCTION__,
|
||||
"A query is already active on this target.");
|
||||
RecordQueryError(ErrorCode::InvalidOperation, __FUNCTION__, "A query is already active on this target.");
|
||||
return;
|
||||
}
|
||||
if (queryObject->active) {
|
||||
@@ -541,14 +536,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
queryObject->counterSnapshot = TransformFeedbackCounterForTarget(target);
|
||||
queryObject->accountedCaptureDrawSnapshot =
|
||||
MG_State::pGLContext->GetTransformFeedbackAccountedCaptureDraws();
|
||||
queryObject->geometryCaptureDrawSnapshot =
|
||||
MG_State::pGLContext->GetTransformFeedbackGeometryCaptureDraws();
|
||||
queryObject->geometryCaptureDrawSnapshot = MG_State::pGLContext->GetTransformFeedbackGeometryCaptureDraws();
|
||||
} else if (isOcclusionQuery) {
|
||||
MGP_FILL(BeginOcclusionQuery);
|
||||
queryObject->backendHandle = MG_Backend::gBackendFunctionsTable.GL.BeginOcclusionQuery();
|
||||
} else {
|
||||
const Bool timerQuerySupported =
|
||||
MGL_BACKEND_SLOT_CAP(BeginTimeElapsedQuery, MG_Pipe::kCapTimerQuery);
|
||||
const Bool timerQuerySupported = MGL_BACKEND_SLOT_CAP(BeginTimeElapsedQuery, MG_Pipe::kCapTimerQuery);
|
||||
const auto beginTimeElapsedQuery = MG_Backend::gBackendFunctionsTable.GL.BeginTimeElapsedQuery;
|
||||
MGP_FILL(BeginTimeElapsedQuery);
|
||||
queryObject->backendHandle =
|
||||
@@ -560,23 +553,22 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void EndQuery(GLenum target) {
|
||||
const Bool isTransformFeedbackQuery =
|
||||
target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN || target == GL_PRIMITIVES_GENERATED;
|
||||
const Bool isOcclusionQuery =
|
||||
(target == GL_SAMPLES_PASSED || target == GL_ANY_SAMPLES_PASSED ||
|
||||
target == GL_ANY_SAMPLES_PASSED_CONSERVATIVE) &&
|
||||
MGL_BACKEND_SLOT_CAP(BeginOcclusionQuery, MG_Pipe::kCapOcclusionQuery);
|
||||
const Bool isOcclusionQuery = (target == GL_SAMPLES_PASSED || target == GL_ANY_SAMPLES_PASSED ||
|
||||
target == GL_ANY_SAMPLES_PASSED_CONSERVATIVE) &&
|
||||
MGL_BACKEND_SLOT_CAP(BeginOcclusionQuery, MG_Pipe::kCapOcclusionQuery);
|
||||
const Bool isPipelineStatisticsQuery = IsPipelineStatisticsQueryTarget(target);
|
||||
if (target != GL_TIME_ELAPSED && !isTransformFeedbackQuery && !isOcclusionQuery &&
|
||||
!isPipelineStatisticsQuery) {
|
||||
if (target != GL_TIME_ELAPSED && !isTransformFeedbackQuery && !isOcclusionQuery && !isPipelineStatisticsQuery) {
|
||||
RecordQueryError(ErrorCode::InvalidEnum, __FUNCTION__, "Query target is not supported.");
|
||||
return;
|
||||
}
|
||||
const std::lock_guard<std::mutex> lock(g_queryObjectsMutex);
|
||||
GLuint& activeQueryId = isPipelineStatisticsQuery
|
||||
? g_activePipelineStatisticsQueryIds[target]
|
||||
: (isTransformFeedbackQuery
|
||||
? (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN ? g_activePrimitivesWrittenQueryId
|
||||
: g_activePrimitivesGeneratedQueryId)
|
||||
: (isOcclusionQuery ? g_activeSamplesPassedQueryId : g_activeTimeElapsedQueryId));
|
||||
GLuint& activeQueryId =
|
||||
isPipelineStatisticsQuery
|
||||
? g_activePipelineStatisticsQueryIds[target]
|
||||
: (isTransformFeedbackQuery
|
||||
? (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN ? g_activePrimitivesWrittenQueryId
|
||||
: g_activePrimitivesGeneratedQueryId)
|
||||
: (isOcclusionQuery ? g_activeSamplesPassedQueryId : g_activeTimeElapsedQueryId));
|
||||
if (activeQueryId == 0) {
|
||||
RecordQueryError(ErrorCode::InvalidOperation, __FUNCTION__, "No query is active on this target.");
|
||||
return;
|
||||
@@ -665,8 +657,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
ResetQueryObjectLocked(queryObject); // discard any previous result
|
||||
queryObject->target = target;
|
||||
const Bool timerQuerySupported =
|
||||
MGL_BACKEND_SLOT_CAP(QueryCounterTimestamp, MG_Pipe::kCapTimerQuery);
|
||||
const Bool timerQuerySupported = MGL_BACKEND_SLOT_CAP(QueryCounterTimestamp, MG_Pipe::kCapTimerQuery);
|
||||
const auto queryCounterTimestamp =
|
||||
timerQuerySupported ? MG_Backend::gBackendFunctionsTable.GL.QueryCounterTimestamp : nullptr;
|
||||
MGP_FILL(QueryCounterTimestamp);
|
||||
|
||||
@@ -46,12 +46,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
if (index >= limit) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
String(indexName) + " index " + std::to_string(index) +
|
||||
" is out of range. Max supported is " + std::to_string(limit - 1) +
|
||||
"."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
String(indexName) + " index " +
|
||||
std::to_string(index) +
|
||||
" is out of range. Max supported is " +
|
||||
std::to_string(limit - 1) + "."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"first (" + std::to_string(first) + ") + count (" +
|
||||
std::to_string(count) + ") exceeds GL_MAX_VIEWPORTS (" +
|
||||
"first (" + std::to_string(first) + ") + count (" + std::to_string(count) +
|
||||
") exceeds GL_MAX_VIEWPORTS (" +
|
||||
std::to_string(RenderStateParameters::MAX_VIEWPORTS) + ")."));
|
||||
return false;
|
||||
}
|
||||
@@ -133,16 +133,15 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return false;
|
||||
}
|
||||
|
||||
static Bool TryConvertBlendEquation(GLenum mode, const char* functionName,
|
||||
::MobileGL::BlendEquation& outEquation) {
|
||||
static Bool TryConvertBlendEquation(GLenum mode, const char* functionName, ::MobileGL::BlendEquation& outEquation) {
|
||||
outEquation = MG_Util::ConvertGLEnumToBlendEquation(mode);
|
||||
if (outEquation != ::MobileGL::BlendEquation::Unknown) return true;
|
||||
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"Blend equation enum " + MG_Util::ConvertGLEnumToString(mode) +
|
||||
" is not supported."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"Blend equation enum " +
|
||||
MG_Util::ConvertGLEnumToString(mode) +
|
||||
" is not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -161,11 +160,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
applyBack = true;
|
||||
return true;
|
||||
default:
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"Stencil face enum " + MG_Util::ConvertGLEnumToString(face) +
|
||||
" is not supported."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"Stencil face enum " +
|
||||
MG_Util::ConvertGLEnumToString(face) +
|
||||
" is not supported."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -175,11 +174,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
outOperation = MG_Util::ConvertGLEnumToStencilOperation(value);
|
||||
if (outOperation != StencilOperation::Unknown) return true;
|
||||
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
String(paramName) + " enum " + MG_Util::ConvertGLEnumToString(value) +
|
||||
" is not supported."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
String(paramName) + " enum " +
|
||||
MG_Util::ConvertGLEnumToString(value) +
|
||||
" is not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -234,10 +233,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!ValidateNonNullArray(v, "DepthRangeArrayv_State")) return;
|
||||
|
||||
for (GLsizei i = 0; i < count; ++i) {
|
||||
MG_State::pGLContext->SetDepthRangeIndexed(
|
||||
first + static_cast<GLuint>(i),
|
||||
FloatVec2(ClampUnitFloat(static_cast<GLfloat>(v[i * 2 + 0])),
|
||||
ClampUnitFloat(static_cast<GLfloat>(v[i * 2 + 1]))));
|
||||
MG_State::pGLContext->SetDepthRangeIndexed(first + static_cast<GLuint>(i),
|
||||
FloatVec2(ClampUnitFloat(static_cast<GLfloat>(v[i * 2 + 0])),
|
||||
ClampUnitFloat(static_cast<GLfloat>(v[i * 2 + 1]))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,10 +453,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
void PointSize_State(GLfloat size) {
|
||||
if (size <= 0.0f) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "PointSize_State",
|
||||
"Point size must be greater than zero."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "PointSize_State",
|
||||
"Point size must be greater than zero."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -502,7 +499,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
}
|
||||
|
||||
void PointParameterf_State(GLenum pname, GLfloat param) { PointParameter_State(pname, param); }
|
||||
void PointParameterf_State(GLenum pname, GLfloat param) {
|
||||
PointParameter_State(pname, param);
|
||||
}
|
||||
|
||||
void PointParameteri_State(GLenum pname, GLint param) {
|
||||
PointParameter_State(pname, static_cast<GLfloat>(param));
|
||||
@@ -547,11 +546,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void LogicOp_State(GLenum opcode) {
|
||||
LogicOperation logicOp = MG_Util::ConvertGLEnumToLogicOperation(opcode);
|
||||
if (logicOp == LogicOperation::Unknown) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "LogicOp_State",
|
||||
"Logic op enum " + MG_Util::ConvertGLEnumToString(opcode) +
|
||||
" is not supported."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "LogicOp_State",
|
||||
"Logic op enum " +
|
||||
MG_Util::ConvertGLEnumToString(opcode) +
|
||||
" is not supported."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -560,10 +559,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
void LineWidth_State(GLfloat width) {
|
||||
if (width <= 0.0f) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "LineWidth_State",
|
||||
"Line width must be greater than zero."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "LineWidth_State",
|
||||
"Line width must be greater than zero."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -592,8 +590,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!data) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetBooleani_v_State",
|
||||
"data pointer cannot be null."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetBooleani_v_State", "data pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -601,11 +598,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// Indexed per-draw-buffer color writemask writes 4 booleans (R,G,B,A) for draw buffer
|
||||
// `index`. The non-indexed glGetBooleanv(GL_COLOR_WRITEMASK) reports draw buffer 0.
|
||||
if (index >= MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetBooleani_v_State",
|
||||
"Color writemask draw buffer index " + std::to_string(index) +
|
||||
" is out of range."));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "GetBooleani_v_State",
|
||||
"Color writemask draw buffer index " +
|
||||
std::to_string(index) +
|
||||
" is out of range."));
|
||||
return;
|
||||
}
|
||||
const BoolVec4 mask = MG_State::pGLContext->GetColorMaskIndexed(index);
|
||||
@@ -629,9 +626,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
GetIntegeri_v(target, index, values);
|
||||
// The ARB_viewport_array rectangles are the only multi-component indexed state that
|
||||
// reaches here; writing element 0 alone would leave the caller's other three untouched.
|
||||
const GLsizei components = target == GL_VIEWPORT || target == GL_SCISSOR_BOX
|
||||
? 4
|
||||
: (target == GL_DEPTH_RANGE ? 2 : 1);
|
||||
const GLsizei components =
|
||||
target == GL_VIEWPORT || target == GL_SCISSOR_BOX ? 4 : (target == GL_DEPTH_RANGE ? 2 : 1);
|
||||
for (GLsizei i = 0; i < components; ++i) {
|
||||
data[i] = values[i] != 0 ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
@@ -927,8 +923,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
BlendFactor dstRGBM = MG_Util::ConvertGLEnumToBlendFactor(dstRGB);
|
||||
BlendFactor srcAlphaM = MG_Util::ConvertGLEnumToBlendFactor(srcAlpha);
|
||||
BlendFactor dstAlphaM = MG_Util::ConvertGLEnumToBlendFactor(dstAlpha);
|
||||
if (srcRGBM == BlendFactor::Unknown || dstRGBM == BlendFactor::Unknown ||
|
||||
srcAlphaM == BlendFactor::Unknown || dstAlphaM == BlendFactor::Unknown) {
|
||||
if (srcRGBM == BlendFactor::Unknown || dstRGBM == BlendFactor::Unknown || srcAlphaM == BlendFactor::Unknown ||
|
||||
dstAlphaM == BlendFactor::Unknown) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "BlendFuncSeparatei_State",
|
||||
|
||||
@@ -119,8 +119,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// both to the same setter - which is what this file used to do - meant glSamplerParameteriv
|
||||
// stored raw integers (so a border of 255 became float 255.0 instead of the spec's ~1.19e-7)
|
||||
// and glSamplerParameterIiv lost the fact that it was ever an integer at all.
|
||||
void SetSamplerParam_State(GLuint sampler, GLenum pname, const void* param, bool isFloat,
|
||||
bool isUnsignedInteger, bool isIntegerCommand) {
|
||||
void SetSamplerParam_State(GLuint sampler, GLenum pname, const void* param, bool isFloat, bool isUnsignedInteger,
|
||||
bool isIntegerCommand) {
|
||||
if (param == nullptr) return;
|
||||
if (!SamplerImpl::ValidateSamplerName(sampler)) return;
|
||||
|
||||
@@ -203,8 +203,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
}
|
||||
|
||||
void GetSamplerParam_State(GLuint sampler, GLenum pname, void* params, bool isFloat,
|
||||
bool isUnsignedInteger, bool isIntegerCommand) {
|
||||
void GetSamplerParam_State(GLuint sampler, GLenum pname, void* params, bool isFloat, bool isUnsignedInteger,
|
||||
bool isIntegerCommand) {
|
||||
if (params == nullptr) return;
|
||||
if (!SamplerImpl::ValidateSamplerName(sampler)) return;
|
||||
|
||||
@@ -239,14 +239,14 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
MG_Util::ConvertSamplerWrapModeToGLEnum(samplerObj->GetWrapR()));
|
||||
break;
|
||||
case GL_TEXTURE_MIN_FILTER:
|
||||
StoreSamplerEnum(params, isFloat, isUnsignedInteger,
|
||||
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerObj->GetMinFilter(),
|
||||
samplerObj->GetMipmapMode()));
|
||||
StoreSamplerEnum(
|
||||
params, isFloat, isUnsignedInteger,
|
||||
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerObj->GetMinFilter(), samplerObj->GetMipmapMode()));
|
||||
break;
|
||||
case GL_TEXTURE_MAG_FILTER:
|
||||
StoreSamplerEnum(params, isFloat, isUnsignedInteger,
|
||||
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerObj->GetMagFilter(),
|
||||
SamplerMipmapMode::None));
|
||||
StoreSamplerEnum(
|
||||
params, isFloat, isUnsignedInteger,
|
||||
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerObj->GetMagFilter(), SamplerMipmapMode::None));
|
||||
break;
|
||||
case GL_TEXTURE_MIN_LOD:
|
||||
StoreSamplerScalar(params, isFloat, isUnsignedInteger, samplerObj->GetMinLod());
|
||||
|
||||
@@ -196,8 +196,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
case GL_SYNC_STATUS: {
|
||||
const auto backendGetSyncStatus = MG_Backend::gBackendFunctionsTable.GL.GetSyncStatus;
|
||||
MGP_FILL(GetSyncStatus);
|
||||
const Bool signaled = !backendGetSyncStatus || !syncObject->backendHandle ||
|
||||
backendGetSyncStatus(syncObject->backendHandle);
|
||||
const Bool signaled =
|
||||
!backendGetSyncStatus || !syncObject->backendHandle || backendGetSyncStatus(syncObject->backendHandle);
|
||||
value = signaled ? GL_SIGNALED : GL_UNSIGNALED;
|
||||
break;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -88,10 +88,10 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height,
|
||||
GLsizei depth);
|
||||
void TexStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width,
|
||||
GLsizei height, GLboolean fixedsamplelocations);
|
||||
void TexStorage3DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
|
||||
void TexStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height,
|
||||
GLboolean fixedsamplelocations);
|
||||
void TexStorage3DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height,
|
||||
GLsizei depth, GLboolean fixedsamplelocations);
|
||||
void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels);
|
||||
void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
Uint End = 0; // logical end-exclusive, including the source base level
|
||||
};
|
||||
|
||||
inline MipmapGenerationRange ComputeMipmapGenerationRange(
|
||||
const MG_State::GLState::TextureObjectMipmap& texture, TextureUploadTarget uploadTarget) {
|
||||
inline MipmapGenerationRange ComputeMipmapGenerationRange(const MG_State::GLState::TextureObjectMipmap& texture,
|
||||
TextureUploadTarget uploadTarget) {
|
||||
const auto range = texture.GetLevelRange();
|
||||
MipmapGenerationRange result{range.x(), range.x()};
|
||||
const Uint available = texture.GetMipmapLevelCount();
|
||||
@@ -29,18 +29,19 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
const auto extent = texture.GetMipmapTexelSize(uploadTarget, result.Base);
|
||||
if (extent.x() <= 0 || extent.y() <= 0 || extent.z() <= 0) return result;
|
||||
Int largest = extent.x();
|
||||
if (texture.GetTarget() != TextureTarget::Texture1D &&
|
||||
texture.GetTarget() != TextureTarget::Texture1DArray)
|
||||
if (texture.GetTarget() != TextureTarget::Texture1D && texture.GetTarget() != TextureTarget::Texture1DArray)
|
||||
largest = std::max(largest, extent.y());
|
||||
if (texture.GetTarget() == TextureTarget::Texture3D) largest = std::max(largest, extent.z());
|
||||
Uint levels = 1;
|
||||
while (largest > 1) { largest /= 2; ++levels; }
|
||||
Uint64 end = std::min(static_cast<Uint64>(result.Base) + levels,
|
||||
static_cast<Uint64>(range.y()) + 1);
|
||||
while (largest > 1) {
|
||||
largest /= 2;
|
||||
++levels;
|
||||
}
|
||||
Uint64 end = std::min(static_cast<Uint64>(result.Base) + levels, static_cast<Uint64>(range.y()) + 1);
|
||||
// A view's level count is already relative to its own window. Neither
|
||||
// immutable storage nor a view may acquire levels beyond that allocation.
|
||||
if (texture.IsImmutable()) end = std::min(end, static_cast<Uint64>(available));
|
||||
result.End = static_cast<Uint>(end);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace MobileGL::MG_Impl::GLImpl
|
||||
|
||||
@@ -208,53 +208,53 @@ namespace MobileGL::MG_Impl::GLImpl::TextureImpl {
|
||||
|
||||
Bool IsIntegerColorInternalFormat(TextureInternalFormat internalFormat) {
|
||||
switch (internalFormat) {
|
||||
case TextureInternalFormat::R8I:
|
||||
case TextureInternalFormat::R8UI:
|
||||
case TextureInternalFormat::R16I:
|
||||
case TextureInternalFormat::R16UI:
|
||||
case TextureInternalFormat::R32I:
|
||||
case TextureInternalFormat::R32UI:
|
||||
case TextureInternalFormat::RG8I:
|
||||
case TextureInternalFormat::RG8UI:
|
||||
case TextureInternalFormat::RG16I:
|
||||
case TextureInternalFormat::RG16UI:
|
||||
case TextureInternalFormat::RG32I:
|
||||
case TextureInternalFormat::RG32UI:
|
||||
case TextureInternalFormat::RGB8I:
|
||||
case TextureInternalFormat::RGB8UI:
|
||||
case TextureInternalFormat::RGB16I:
|
||||
case TextureInternalFormat::RGB16UI:
|
||||
case TextureInternalFormat::RGB32I:
|
||||
case TextureInternalFormat::RGB32UI:
|
||||
case TextureInternalFormat::RGBA8I:
|
||||
case TextureInternalFormat::RGBA8UI:
|
||||
case TextureInternalFormat::RGBA16I:
|
||||
case TextureInternalFormat::RGBA16UI:
|
||||
case TextureInternalFormat::RGBA32I:
|
||||
case TextureInternalFormat::RGBA32UI:
|
||||
case TextureInternalFormat::RGB10A2UI:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case TextureInternalFormat::R8I:
|
||||
case TextureInternalFormat::R8UI:
|
||||
case TextureInternalFormat::R16I:
|
||||
case TextureInternalFormat::R16UI:
|
||||
case TextureInternalFormat::R32I:
|
||||
case TextureInternalFormat::R32UI:
|
||||
case TextureInternalFormat::RG8I:
|
||||
case TextureInternalFormat::RG8UI:
|
||||
case TextureInternalFormat::RG16I:
|
||||
case TextureInternalFormat::RG16UI:
|
||||
case TextureInternalFormat::RG32I:
|
||||
case TextureInternalFormat::RG32UI:
|
||||
case TextureInternalFormat::RGB8I:
|
||||
case TextureInternalFormat::RGB8UI:
|
||||
case TextureInternalFormat::RGB16I:
|
||||
case TextureInternalFormat::RGB16UI:
|
||||
case TextureInternalFormat::RGB32I:
|
||||
case TextureInternalFormat::RGB32UI:
|
||||
case TextureInternalFormat::RGBA8I:
|
||||
case TextureInternalFormat::RGBA8UI:
|
||||
case TextureInternalFormat::RGBA16I:
|
||||
case TextureInternalFormat::RGBA16UI:
|
||||
case TextureInternalFormat::RGBA32I:
|
||||
case TextureInternalFormat::RGBA32UI:
|
||||
case TextureInternalFormat::RGB10A2UI:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static Bool IsDepthLikeInternalFormat(TextureInternalFormat internalFormat) {
|
||||
switch (internalFormat) {
|
||||
case TextureInternalFormat::DepthComponent:
|
||||
case TextureInternalFormat::DepthComponent16:
|
||||
case TextureInternalFormat::DepthComponent24:
|
||||
case TextureInternalFormat::DepthComponent32: // not core, kept for Minecraft 1.21.5+
|
||||
case TextureInternalFormat::DepthComponent32F:
|
||||
case TextureInternalFormat::Depth24Stencil8:
|
||||
case TextureInternalFormat::Depth32FStencil8:
|
||||
case TextureInternalFormat::DepthStencil:
|
||||
// Stencil-only is not a colour format either: a colour client format read against a
|
||||
// STENCIL_INDEX8 texture has to be the same INVALID_OPERATION as against a depth one.
|
||||
case TextureInternalFormat::StencilIndex8:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case TextureInternalFormat::DepthComponent:
|
||||
case TextureInternalFormat::DepthComponent16:
|
||||
case TextureInternalFormat::DepthComponent24:
|
||||
case TextureInternalFormat::DepthComponent32: // not core, kept for Minecraft 1.21.5+
|
||||
case TextureInternalFormat::DepthComponent32F:
|
||||
case TextureInternalFormat::Depth24Stencil8:
|
||||
case TextureInternalFormat::Depth32FStencil8:
|
||||
case TextureInternalFormat::DepthStencil:
|
||||
// Stencil-only is not a colour format either: a colour client format read against a
|
||||
// STENCIL_INDEX8 texture has to be the same INVALID_OPERATION as against a depth one.
|
||||
case TextureInternalFormat::StencilIndex8:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,8 +339,7 @@ namespace MobileGL::MG_Impl::GLImpl::TextureImpl {
|
||||
// pairs with stencil-only storage: against a depth, depth-stencil or colour internal format
|
||||
// STENCIL_INDEX keeps the pre-4.4 answer (GL CTS packed_pixels feeds exactly that pairing
|
||||
// and expects INVALID_OPERATION).
|
||||
if (format == TextureInputFormat::StencilIndex &&
|
||||
internalFormat != TextureInternalFormat::StencilIndex8) {
|
||||
if (format == TextureInputFormat::StencilIndex && internalFormat != TextureInternalFormat::StencilIndex8) {
|
||||
return recordInvalidOperation("STENCIL_INDEX requires a stencil-only internal format");
|
||||
}
|
||||
|
||||
@@ -396,8 +395,7 @@ namespace MobileGL::MG_Impl::GLImpl::TextureImpl {
|
||||
// dereference a backend texture it never created.
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
"Texture has no mipmap levels to address."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller, "Texture has no mipmap levels to address."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -423,15 +421,13 @@ namespace MobileGL::MG_Impl::GLImpl::TextureImpl {
|
||||
// copy names is an incomplete texture.
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
"Texture has no image defined at any level."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller, "Texture has no image defined at any level."));
|
||||
return false;
|
||||
}
|
||||
if (level < 0 || static_cast<Uint>(level) >= levelCount) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
"Texture level does not exist in this texture."));
|
||||
ErrorCode::InvalidValue, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
"Texture level does not exist in this texture."));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -592,8 +588,7 @@ namespace MobileGL::MG_Impl::GLImpl::TextureImpl {
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateCopyImageFormatCompatibility",
|
||||
std::format("The two compressed images have different block dimensions ({}x{} vs. {}x{}).",
|
||||
srcBlock.blockWidth, srcBlock.blockHeight, dstBlock.blockWidth,
|
||||
dstBlock.blockHeight)));
|
||||
srcBlock.blockWidth, srcBlock.blockHeight, dstBlock.blockWidth, dstBlock.blockHeight)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -76,8 +76,7 @@ namespace MobileGL::MG_Impl::GLImpl::TextureImpl {
|
||||
// blocks are the same SIZE - not that they share a base internal format. RGBA32UI into
|
||||
// RGBA32F is legal (both 128-bit) while RGBA8 into RGBA32F is not, and a compressed image
|
||||
// pairs with an uncompressed one whose texel is as big as the compressed block.
|
||||
Bool ValidateCopyImageFormatCompatibility(const CopyImageTexelBlock& srcBlock,
|
||||
const CopyImageTexelBlock& dstBlock);
|
||||
Bool ValidateCopyImageFormatCompatibility(const CopyImageTexelBlock& srcBlock, const CopyImageTexelBlock& dstBlock);
|
||||
// GL 4.6 core 18.3.2: for a compressed image the region's origin must sit on a block
|
||||
// boundary and its size must be a whole number of blocks - unless the edge it runs to is
|
||||
// the edge of the image.
|
||||
|
||||
@@ -26,19 +26,19 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// form here -- it is not GL 3.3 Core. Unsigned normalization (f = c/(2^b-1)) is unchanged.
|
||||
// The bit width fixes the arithmetic type: 8/16-bit stay exact in int/float, but the 32-bit forms
|
||||
// must use double because 2*INT_MAX overflows int32 and neither 2^32-1 nor 2^31-1 is float-exact.
|
||||
constexpr GLfloat NormalizeSignedByte(GLbyte c) { // b = 8, divisor 2^8 - 1 = 255
|
||||
constexpr GLfloat NormalizeSignedByte(GLbyte c) { // b = 8, divisor 2^8 - 1 = 255
|
||||
return (2 * static_cast<int>(c) + 1) / 255.0f;
|
||||
}
|
||||
constexpr GLfloat NormalizeSignedShort(GLshort c) { // b = 16, divisor 2^16 - 1 = 65535
|
||||
return (2 * static_cast<int>(c) + 1) / 65535.0f;
|
||||
}
|
||||
constexpr GLfloat NormalizeSignedInt(GLint c) { // b = 32, divisor 2^32 - 1 (double!)
|
||||
constexpr GLfloat NormalizeSignedInt(GLint c) { // b = 32, divisor 2^32 - 1 (double!)
|
||||
return static_cast<GLfloat>((2.0 * static_cast<double>(c) + 1.0) / 4294967295.0);
|
||||
}
|
||||
constexpr GLfloat NormalizeUnsignedShort(GLushort c) { // b = 16
|
||||
return static_cast<GLfloat>(c) / 65535.0f;
|
||||
}
|
||||
constexpr GLfloat NormalizeUnsignedInt(GLuint c) { // b = 32 (double!)
|
||||
constexpr GLfloat NormalizeUnsignedInt(GLuint c) { // b = 32 (double!)
|
||||
return static_cast<GLfloat>(static_cast<double>(c) / 4294967295.0);
|
||||
}
|
||||
// (b = 8 unsigned normalization is VertexAttrib4Nub's x * (1/255).)
|
||||
@@ -232,8 +232,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedPtr<MG_State::GLState::VertexArrayObject> GetNamedVertexArrayObject_State(GLuint vaobj,
|
||||
const char* caller) {
|
||||
SharedPtr<MG_State::GLState::VertexArrayObject> GetNamedVertexArrayObject_State(GLuint vaobj, const char* caller) {
|
||||
// Name zero is not a vertex array object in a core profile: it names the default vertex
|
||||
// array, which the by-name (direct state access) entry points never accept. MobileGL keeps a
|
||||
// real object at index 0 for the compatibility paths, so the generic name validation below
|
||||
@@ -326,7 +325,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!VertexArrayImpl::ValidateVertexAttributeIndex(index)) return;
|
||||
|
||||
DataType dataType = MG_Util::ConvertGLEnumToDataType(type);
|
||||
if (!VertexArrayImpl::ValidateVertexAttribFormat(index, size, type, dataType, normalized == GL_TRUE, stride, false))
|
||||
if (!VertexArrayImpl::ValidateVertexAttribFormat(index, size, type, dataType, normalized == GL_TRUE, stride,
|
||||
false))
|
||||
return;
|
||||
|
||||
auto& vao = MG_State::pGLContext->GetBoundVertexArray();
|
||||
@@ -457,8 +457,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (static_cast<Uint>(stride) > VertexArrayImpl::GetMaxVertexAttribStride()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller,
|
||||
"stride exceeds GL_MAX_VERTEX_ATTRIB_STRIDE."));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", caller, "stride exceeds GL_MAX_VERTEX_ATTRIB_STRIDE."));
|
||||
return;
|
||||
}
|
||||
auto bufferObject = GetVertexArrayBufferObject_State(buffer, caller);
|
||||
@@ -505,8 +504,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!VertexArrayImpl::ValidateVertexAttribRelativeOffset(relativeoffset)) return;
|
||||
|
||||
const Bool isBgra = (size == static_cast<GLint>(GL_BGRA));
|
||||
vao->SetAttributeFormatSeparate(attribindex, isBgra ? 4 : size, dataType, normalized, isInteger,
|
||||
relativeoffset, isBgra);
|
||||
vao->SetAttributeFormatSeparate(attribindex, isBgra ? 4 : size, dataType, normalized, isInteger, relativeoffset,
|
||||
isBgra);
|
||||
}
|
||||
|
||||
// The long (64-bit) attribute format: the values reach the shader as doubles, unconverted
|
||||
@@ -526,8 +525,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// MG_Util/SelfTest/DriverPost.cpp; the draw-side narrowing is DirectGLES/Managers.cpp and, on
|
||||
// DirectVulkan, VertexInputStateFactory's Float64 case.
|
||||
static void VertexAttribLFormatSeparate_State(const SharedPtr<MG_State::GLState::VertexArrayObject>& vao,
|
||||
GLuint attribindex, GLint size, GLenum type,
|
||||
GLuint relativeoffset) {
|
||||
GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset) {
|
||||
if (!VertexArrayImpl::ValidateVertexAttributeIndex(attribindex)) return;
|
||||
if (!VertexArrayImpl::ValidateVertexAttribLFormat(attribindex, size, type)) return;
|
||||
if (!VertexArrayImpl::ValidateVertexAttribRelativeOffset(relativeoffset)) return;
|
||||
@@ -535,11 +533,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!MG_Backend::pActiveBackendObject ||
|
||||
!MG_Backend::pActiveBackendObject->GetDynamicParameters().SupportsFloat64VertexAttributes) {
|
||||
MGLOG_W_ONCE("VertexAttribLFormat: attribute %u asked for a 64-bit (GL_DOUBLE) format, but this "
|
||||
"backend has no double-precision vertex attribute support - the format is recorded "
|
||||
"and queryable, and the array is FETCHED AT FLOAT32 PRECISION at draw (the same "
|
||||
"narrowing the shader's dvec inputs already get); see the \"64-bit vertex "
|
||||
"attributes\" / \"shaderFloat64\" POST row for what that costs",
|
||||
attribindex);
|
||||
"backend has no double-precision vertex attribute support - the format is recorded "
|
||||
"and queryable, and the array is FETCHED AT FLOAT32 PRECISION at draw (the same "
|
||||
"narrowing the shader's dvec inputs already get); see the \"64-bit vertex "
|
||||
"attributes\" / \"shaderFloat64\" POST row for what that costs",
|
||||
attribindex);
|
||||
}
|
||||
|
||||
vao->SetAttributeFormatSeparate(attribindex, size, MG_Util::ConvertGLEnumToDataType(type),
|
||||
@@ -547,8 +545,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
/*isBgra: */ false, /*isLong: */ true);
|
||||
}
|
||||
|
||||
void VertexArrayAttribFormat_State(GLuint vaobj, GLuint attribindex, GLint size, GLenum type,
|
||||
GLboolean normalized, GLuint relativeoffset) {
|
||||
void VertexArrayAttribFormat_State(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized,
|
||||
GLuint relativeoffset) {
|
||||
auto vao = GetNamedVertexArrayObject_State(vaobj, "VertexArrayAttribFormat_State");
|
||||
if (!vao) return;
|
||||
VertexAttribFormatSeparate_State(vao, attribindex, size, type, normalized, relativeoffset, false,
|
||||
@@ -693,8 +691,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// path), so they take the float current-value funnel. The single packed word is always fully
|
||||
// decoded, but only the first `componentCount` components are written; the rest keep the generic
|
||||
// attribute defaults (0, 0, 0, 1). type must be one of the two 2_10_10_10_REV packed enums.
|
||||
static void VertexAttribP_Common(GLuint index, GLenum type, GLboolean normalized, GLuint value,
|
||||
int componentCount, const char* funcName) {
|
||||
static void VertexAttribP_Common(GLuint index, GLenum type, GLboolean normalized, GLuint value, int componentCount,
|
||||
const char* funcName) {
|
||||
if (!ValidateCurrentVertexAttribIndex(index, funcName)) return;
|
||||
|
||||
bool signedType;
|
||||
@@ -714,7 +712,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
const Array<GLfloat, 4> decoded = DecodePacked2101010(value, signedType, normalized == GL_TRUE);
|
||||
Array<GLfloat, 4> out = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
for (int i = 0; i < componentCount; ++i) out[i] = decoded[i];
|
||||
for (int i = 0; i < componentCount; ++i)
|
||||
out[i] = decoded[i];
|
||||
MG_State::pGLContext->SetCurrentVertexAttributeFloat(index, out);
|
||||
}
|
||||
|
||||
@@ -802,14 +801,16 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// components are 0, unspecified w is 1 (integer 1 for the I* forms).
|
||||
#define MG_ATTRIB_NULL_GUARD(ptr) \
|
||||
if (!(ptr)) { \
|
||||
MG_State::pGLContext->RecordError( \
|
||||
MG_State::pGLContext->RecordError( \
|
||||
ErrorCode::InvalidValue, \
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "value pointer cannot be null.")); \
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "value pointer cannot be null.")); \
|
||||
return; \
|
||||
}
|
||||
|
||||
// Family A -- GLdouble, value-preserving narrowing to float.
|
||||
void VertexAttrib1d(GLuint index, GLdouble x) { VertexAttrib4f(index, static_cast<GLfloat>(x), 0.0f, 0.0f, 1.0f); }
|
||||
void VertexAttrib1d(GLuint index, GLdouble x) {
|
||||
VertexAttrib4f(index, static_cast<GLfloat>(x), 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
void VertexAttrib2d(GLuint index, GLdouble x, GLdouble y) {
|
||||
VertexAttrib4f(index, static_cast<GLfloat>(x), static_cast<GLfloat>(y), 0.0f, 1.0f);
|
||||
}
|
||||
@@ -820,8 +821,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
VertexAttrib4f(index, static_cast<GLfloat>(x), static_cast<GLfloat>(y), static_cast<GLfloat>(z),
|
||||
static_cast<GLfloat>(w));
|
||||
}
|
||||
void VertexAttrib1dv(GLuint index, const GLdouble* v) { MG_ATTRIB_NULL_GUARD(v) VertexAttrib1d(index, v[0]); }
|
||||
void VertexAttrib2dv(GLuint index, const GLdouble* v) { MG_ATTRIB_NULL_GUARD(v) VertexAttrib2d(index, v[0], v[1]); }
|
||||
void VertexAttrib1dv(GLuint index, const GLdouble* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttrib1d(index, v[0]);
|
||||
}
|
||||
void VertexAttrib2dv(GLuint index, const GLdouble* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttrib2d(index, v[0], v[1]);
|
||||
}
|
||||
void VertexAttrib3dv(GLuint index, const GLdouble* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttrib3d(index, v[0], v[1], v[2]);
|
||||
}
|
||||
@@ -830,7 +835,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
|
||||
// Family A -- GLshort, value-preserving (sign kept), NOT normalized.
|
||||
void VertexAttrib1s(GLuint index, GLshort x) { VertexAttrib4f(index, static_cast<GLfloat>(x), 0.0f, 0.0f, 1.0f); }
|
||||
void VertexAttrib1s(GLuint index, GLshort x) {
|
||||
VertexAttrib4f(index, static_cast<GLfloat>(x), 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
void VertexAttrib2s(GLuint index, GLshort x, GLshort y) {
|
||||
VertexAttrib4f(index, static_cast<GLfloat>(x), static_cast<GLfloat>(y), 0.0f, 1.0f);
|
||||
}
|
||||
@@ -841,8 +848,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
VertexAttrib4f(index, static_cast<GLfloat>(x), static_cast<GLfloat>(y), static_cast<GLfloat>(z),
|
||||
static_cast<GLfloat>(w));
|
||||
}
|
||||
void VertexAttrib1sv(GLuint index, const GLshort* v) { MG_ATTRIB_NULL_GUARD(v) VertexAttrib1s(index, v[0]); }
|
||||
void VertexAttrib2sv(GLuint index, const GLshort* v) { MG_ATTRIB_NULL_GUARD(v) VertexAttrib2s(index, v[0], v[1]); }
|
||||
void VertexAttrib1sv(GLuint index, const GLshort* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttrib1s(index, v[0]);
|
||||
}
|
||||
void VertexAttrib2sv(GLuint index, const GLshort* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttrib2s(index, v[0], v[1]);
|
||||
}
|
||||
void VertexAttrib3sv(GLuint index, const GLshort* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttrib3s(index, v[0], v[1], v[2]);
|
||||
}
|
||||
@@ -890,8 +901,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
void VertexAttrib4Nusv(GLuint index, const GLushort* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v)
|
||||
VertexAttrib4f(index, NormalizeUnsignedShort(v[0]), NormalizeUnsignedShort(v[1]),
|
||||
NormalizeUnsignedShort(v[2]), NormalizeUnsignedShort(v[3]));
|
||||
VertexAttrib4f(index, NormalizeUnsignedShort(v[0]), NormalizeUnsignedShort(v[1]), NormalizeUnsignedShort(v[2]),
|
||||
NormalizeUnsignedShort(v[3]));
|
||||
}
|
||||
void VertexAttrib4Nuiv(GLuint index, const GLuint* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v)
|
||||
@@ -901,18 +912,36 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
// Family C -- pure integer forms. Signed -> VertexAttribI4i (sign-extend), unsigned ->
|
||||
// VertexAttribI4ui (zero-extend). w defaults to the integer 1 / 1u. Never touches the float view.
|
||||
void VertexAttribI1i(GLuint index, GLint x) { VertexAttribI4i(index, x, 0, 0, 1); }
|
||||
void VertexAttribI2i(GLuint index, GLint x, GLint y) { VertexAttribI4i(index, x, y, 0, 1); }
|
||||
void VertexAttribI3i(GLuint index, GLint x, GLint y, GLint z) { VertexAttribI4i(index, x, y, z, 1); }
|
||||
void VertexAttribI1ui(GLuint index, GLuint x) { VertexAttribI4ui(index, x, 0u, 0u, 1u); }
|
||||
void VertexAttribI2ui(GLuint index, GLuint x, GLuint y) { VertexAttribI4ui(index, x, y, 0u, 1u); }
|
||||
void VertexAttribI3ui(GLuint index, GLuint x, GLuint y, GLuint z) { VertexAttribI4ui(index, x, y, z, 1u); }
|
||||
void VertexAttribI1iv(GLuint index, const GLint* v) { MG_ATTRIB_NULL_GUARD(v) VertexAttribI1i(index, v[0]); }
|
||||
void VertexAttribI2iv(GLuint index, const GLint* v) { MG_ATTRIB_NULL_GUARD(v) VertexAttribI2i(index, v[0], v[1]); }
|
||||
void VertexAttribI1i(GLuint index, GLint x) {
|
||||
VertexAttribI4i(index, x, 0, 0, 1);
|
||||
}
|
||||
void VertexAttribI2i(GLuint index, GLint x, GLint y) {
|
||||
VertexAttribI4i(index, x, y, 0, 1);
|
||||
}
|
||||
void VertexAttribI3i(GLuint index, GLint x, GLint y, GLint z) {
|
||||
VertexAttribI4i(index, x, y, z, 1);
|
||||
}
|
||||
void VertexAttribI1ui(GLuint index, GLuint x) {
|
||||
VertexAttribI4ui(index, x, 0u, 0u, 1u);
|
||||
}
|
||||
void VertexAttribI2ui(GLuint index, GLuint x, GLuint y) {
|
||||
VertexAttribI4ui(index, x, y, 0u, 1u);
|
||||
}
|
||||
void VertexAttribI3ui(GLuint index, GLuint x, GLuint y, GLuint z) {
|
||||
VertexAttribI4ui(index, x, y, z, 1u);
|
||||
}
|
||||
void VertexAttribI1iv(GLuint index, const GLint* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttribI1i(index, v[0]);
|
||||
}
|
||||
void VertexAttribI2iv(GLuint index, const GLint* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttribI2i(index, v[0], v[1]);
|
||||
}
|
||||
void VertexAttribI3iv(GLuint index, const GLint* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttribI3i(index, v[0], v[1], v[2]);
|
||||
}
|
||||
void VertexAttribI1uiv(GLuint index, const GLuint* v) { MG_ATTRIB_NULL_GUARD(v) VertexAttribI1ui(index, v[0]); }
|
||||
void VertexAttribI1uiv(GLuint index, const GLuint* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttribI1ui(index, v[0]);
|
||||
}
|
||||
void VertexAttribI2uiv(GLuint index, const GLuint* v) {
|
||||
MG_ATTRIB_NULL_GUARD(v) VertexAttribI2ui(index, v[0], v[1]);
|
||||
}
|
||||
@@ -1155,9 +1184,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!VertexArrayImpl::ValidateVertexAttributeIndex(index)) return;
|
||||
if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"pname must be GL_VERTEX_ATTRIB_ARRAY_POINTER."));
|
||||
ErrorCode::InvalidEnum, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"pname must be GL_VERTEX_ATTRIB_ARRAY_POINTER."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1232,9 +1260,8 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
if (!vao || !param) return;
|
||||
if (pname != GL_ELEMENT_ARRAY_BUFFER_BINDING) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"pname must be GL_ELEMENT_ARRAY_BUFFER_BINDING."));
|
||||
ErrorCode::InvalidEnum, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"pname must be GL_ELEMENT_ARRAY_BUFFER_BINDING."));
|
||||
return;
|
||||
}
|
||||
const auto& indexBuffer = vao->GetIndexBufferBindingSlot().GetBoundObject();
|
||||
|
||||
@@ -235,17 +235,15 @@ namespace MobileGL::MG_Impl::GLImpl::VertexArrayImpl {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", fn,
|
||||
std::format("Invalid size {} for attribute {}. Must be 1-4.", size, index)));
|
||||
"MG_Impl/GLImpl", fn, std::format("Invalid size {} for attribute {}. Must be 1-4.", size, index)));
|
||||
return false;
|
||||
}
|
||||
// GL 4.6 core 10.3.2: the long form takes GL_DOUBLE and nothing else.
|
||||
if (type != GL_DOUBLE) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", fn,
|
||||
std::format("Type 0x{:X} is not GL_DOUBLE (attribute {}).", type, index)));
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", fn,
|
||||
std::format("Type 0x{:X} is not GL_DOUBLE (attribute {}).", type, index)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -64,8 +64,7 @@ MOBILEGL_GLX_API void** glXGetFBConfigs(Display* dpy, int screen, int* nelements
|
||||
return GLXImpl::GetFBConfigs(dpy, screen, nelements);
|
||||
}
|
||||
|
||||
MOBILEGL_GLX_API void** glXChooseFBConfig(Display* dpy, int screen, const int* attribList,
|
||||
int* nelements) {
|
||||
MOBILEGL_GLX_API void** glXChooseFBConfig(Display* dpy, int screen, const int* attribList, int* nelements) {
|
||||
GLXStreamLock streamLock;
|
||||
return GLXImpl::ChooseFBConfig(dpy, screen, attribList, nelements);
|
||||
}
|
||||
@@ -95,14 +94,13 @@ MOBILEGL_GLX_API void* glXCreateContext(Display* dpy, void* visualInfo, void* sh
|
||||
return GLXImpl::CreateContext(dpy, visualInfo, shareList, direct);
|
||||
}
|
||||
|
||||
MOBILEGL_GLX_API void* glXCreateNewContext(Display* dpy, void* config, int renderType,
|
||||
void* shareList, int direct) {
|
||||
MOBILEGL_GLX_API void* glXCreateNewContext(Display* dpy, void* config, int renderType, void* shareList, int direct) {
|
||||
GLXStreamLock streamLock;
|
||||
return GLXImpl::CreateNewContext(dpy, config, renderType, shareList, direct);
|
||||
}
|
||||
|
||||
MOBILEGL_GLX_API void* glXCreateContextAttribsARB(Display* dpy, void* config, void* shareContext,
|
||||
int direct, const int* attribList) {
|
||||
MOBILEGL_GLX_API void* glXCreateContextAttribsARB(Display* dpy, void* config, void* shareContext, int direct,
|
||||
const int* attribList) {
|
||||
GLXStreamLock streamLock;
|
||||
return GLXImpl::CreateContextAttribsARB(dpy, config, shareContext, direct, attribList);
|
||||
}
|
||||
@@ -117,8 +115,7 @@ MOBILEGL_GLX_API int glXMakeCurrent(Display* dpy, unsigned long drawable, void*
|
||||
return GLXImpl::MakeCurrent(dpy, drawable, context);
|
||||
}
|
||||
|
||||
MOBILEGL_GLX_API int glXMakeContextCurrent(Display* dpy, unsigned long draw, unsigned long read,
|
||||
void* context) {
|
||||
MOBILEGL_GLX_API int glXMakeContextCurrent(Display* dpy, unsigned long draw, unsigned long read, void* context) {
|
||||
GLXStreamLock streamLock;
|
||||
return GLXImpl::MakeContextCurrent(dpy, draw, read, context);
|
||||
}
|
||||
@@ -179,8 +176,7 @@ MOBILEGL_GLX_API int glXQueryContext(Display* dpy, void* context, int attribute,
|
||||
return GLXImpl::QueryContext(dpy, context, attribute, value);
|
||||
}
|
||||
|
||||
MOBILEGL_GLX_API void glXQueryDrawable(Display* dpy, unsigned long drawable, int attribute,
|
||||
unsigned int* value) {
|
||||
MOBILEGL_GLX_API void glXQueryDrawable(Display* dpy, unsigned long drawable, int attribute, unsigned int* value) {
|
||||
GLXStreamLock streamLock;
|
||||
GLXImpl::QueryDrawable(dpy, drawable, attribute, value);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,9 @@ namespace {
|
||||
const GLXApiExports* g_glxExports = nullptr;
|
||||
GLXVendorInfo* g_glxVendor = nullptr;
|
||||
|
||||
XBool VendorIsScreenSupported(Display*, int) { return 1; }
|
||||
XBool VendorIsScreenSupported(Display*, int) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// GLX names are the exported entry points (each holds the stream lock); GL names are the
|
||||
// implementation's, as eglGetProcAddress hands them out.
|
||||
|
||||
@@ -136,8 +136,8 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
int (*Sync)(Display*, int) = nullptr;
|
||||
|
||||
Bool Valid() const {
|
||||
return GetGeometry && GetVisualInfo && GetDefaultScreen && GetDefaultVisual &&
|
||||
VisualIDFromVisual && Free;
|
||||
return GetGeometry && GetVisualInfo && GetDefaultScreen && GetDefaultVisual && VisualIDFromVisual &&
|
||||
Free;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -151,16 +151,16 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
}
|
||||
}
|
||||
if (fns->Library) {
|
||||
fns->GetGeometry = reinterpret_cast<decltype(fns->GetGeometry)>(
|
||||
dlsym(fns->Library, "XGetGeometry"));
|
||||
fns->GetVisualInfo = reinterpret_cast<decltype(fns->GetVisualInfo)>(
|
||||
dlsym(fns->Library, "XGetVisualInfo"));
|
||||
fns->GetDefaultScreen = reinterpret_cast<decltype(fns->GetDefaultScreen)>(
|
||||
dlsym(fns->Library, "XDefaultScreen"));
|
||||
fns->GetDefaultVisual = reinterpret_cast<decltype(fns->GetDefaultVisual)>(
|
||||
dlsym(fns->Library, "XDefaultVisual"));
|
||||
fns->VisualIDFromVisual = reinterpret_cast<decltype(fns->VisualIDFromVisual)>(
|
||||
dlsym(fns->Library, "XVisualIDFromVisual"));
|
||||
fns->GetGeometry =
|
||||
reinterpret_cast<decltype(fns->GetGeometry)>(dlsym(fns->Library, "XGetGeometry"));
|
||||
fns->GetVisualInfo =
|
||||
reinterpret_cast<decltype(fns->GetVisualInfo)>(dlsym(fns->Library, "XGetVisualInfo"));
|
||||
fns->GetDefaultScreen =
|
||||
reinterpret_cast<decltype(fns->GetDefaultScreen)>(dlsym(fns->Library, "XDefaultScreen"));
|
||||
fns->GetDefaultVisual =
|
||||
reinterpret_cast<decltype(fns->GetDefaultVisual)>(dlsym(fns->Library, "XDefaultVisual"));
|
||||
fns->VisualIDFromVisual =
|
||||
reinterpret_cast<decltype(fns->VisualIDFromVisual)>(dlsym(fns->Library, "XVisualIDFromVisual"));
|
||||
fns->Free = reinterpret_cast<decltype(fns->Free)>(dlsym(fns->Library, "XFree"));
|
||||
fns->Sync = reinterpret_cast<decltype(fns->Sync)>(dlsym(fns->Library, "XSync"));
|
||||
}
|
||||
@@ -182,8 +182,8 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
Uint32 (*GenerateId)(void*) = nullptr;
|
||||
XcbVoidCookie (*CreateGC)(void*, Uint32, Uint32, Uint32, const void*) = nullptr;
|
||||
XcbVoidCookie (*FreeGC)(void*, Uint32) = nullptr;
|
||||
XcbVoidCookie (*PutImage)(void*, Uint8, Uint32, Uint32, Uint16, Uint16, Int16, Int16, Uint8, Uint8,
|
||||
Uint32, const Uint8*) = nullptr;
|
||||
XcbVoidCookie (*PutImage)(void*, Uint8, Uint32, Uint32, Uint16, Uint16, Int16, Int16, Uint8, Uint8, Uint32,
|
||||
const Uint8*) = nullptr;
|
||||
Uint32 (*MaximumRequestLength)(void*) = nullptr;
|
||||
int (*Flush)(void*) = nullptr;
|
||||
|
||||
@@ -415,9 +415,9 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
X11Present::CreateXcbConnection(connection, static_cast<Uint32>(drawable), caps);
|
||||
if (surface.PresentConnection) {
|
||||
surface.Images = MakeUnique<BackendImageSource>();
|
||||
surface.Chain = MakeUnique<X11Present::Chain>(
|
||||
*surface.PresentConnection, *surface.Images, surface.Depth, static_cast<Int32>(surface.Width),
|
||||
static_cast<Int32>(surface.Height), &SteadyNowMs);
|
||||
surface.Chain = MakeUnique<X11Present::Chain>(*surface.PresentConnection, *surface.Images,
|
||||
surface.Depth, static_cast<Int32>(surface.Width),
|
||||
static_cast<Int32>(surface.Height), &SteadyNowMs);
|
||||
} else {
|
||||
caps.Dri3Major = 0;
|
||||
surface.Path = X11Present::SelectPath(caps, surface.Depth, override);
|
||||
@@ -481,9 +481,11 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
const EGLint height = static_cast<EGLint>(surface.Height);
|
||||
const SizeT rowBytes = static_cast<SizeT>(width) * 4;
|
||||
if (surface.Shm) {
|
||||
const Bool put = surface.Shm->Put(
|
||||
static_cast<Uint32>(drawable), surface.Gc, surface.Depth, width, height,
|
||||
[&](Uint8* rows, SizeT stride) { EGLImpl::ReadBackFrameBGRA(width, height, surface.Scratch, rows, stride); });
|
||||
const Bool put =
|
||||
surface.Shm->Put(static_cast<Uint32>(drawable), surface.Gc, surface.Depth, width, height,
|
||||
[&](Uint8* rows, SizeT stride) {
|
||||
EGLImpl::ReadBackFrameBGRA(width, height, surface.Scratch, rows, stride);
|
||||
});
|
||||
if (put) return;
|
||||
MGLOG_I("glx: window 0x%lx: MIT-SHM put failed; PutImage from now on", drawable);
|
||||
surface.Shm.reset();
|
||||
@@ -523,8 +525,7 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
// owns size discovery and pushes changes through the internal resize hook
|
||||
// (same contract as the WGL and CGL layers). Polling XGetGeometry is a
|
||||
// server round trip, so throttle steady-state swaps.
|
||||
void SyncSurfaceSize(Display* dpy, GLXDrawableHandle drawable, DrawableSurface& surface,
|
||||
Bool force = false) {
|
||||
void SyncSurfaceSize(Display* dpy, GLXDrawableHandle drawable, DrawableSurface& surface, Bool force = false) {
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
if (!force && now - surface.LastSizePoll < std::chrono::milliseconds(250)) {
|
||||
return;
|
||||
@@ -539,8 +540,7 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
return;
|
||||
}
|
||||
// A remote X drawable is a pbuffer; resizing it gives it a new one at the new size.
|
||||
if (EGLImpl::ResizePlatformWindowSurface(surface.Display, surface.Surface,
|
||||
static_cast<EGLint>(width),
|
||||
if (EGLImpl::ResizePlatformWindowSurface(surface.Display, surface.Surface, static_cast<EGLint>(width),
|
||||
static_cast<EGLint>(height))) {
|
||||
surface.Width = width;
|
||||
surface.Height = height;
|
||||
@@ -549,8 +549,7 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
}
|
||||
}
|
||||
|
||||
DrawableSurface* EnsureDrawableSurface(Display* dpy, GLXDrawableHandle drawable,
|
||||
const ContextObject& context) {
|
||||
DrawableSurface* EnsureDrawableSurface(Display* dpy, GLXDrawableHandle drawable, const ContextObject& context) {
|
||||
auto& surfaces = DrawableSurfaces();
|
||||
auto it = surfaces.find(drawable);
|
||||
if (it != surfaces.end()) {
|
||||
@@ -567,21 +566,19 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
}
|
||||
|
||||
const EGLAttrib attribs[] = {
|
||||
EGL_WIDTH, static_cast<EGLAttrib>(width),
|
||||
EGL_HEIGHT, static_cast<EGLAttrib>(height),
|
||||
EGL_NONE,
|
||||
EGL_WIDTH, static_cast<EGLAttrib>(width), EGL_HEIGHT, static_cast<EGLAttrib>(height), EGL_NONE,
|
||||
};
|
||||
const Bool remotePbuffer = MG_Config::Transport == MG_Config::TransportMode::Spawn ||
|
||||
MG_Config::Transport == MG_Config::TransportMode::UnixSocket;
|
||||
const EGLint pbufferAttribs[] = {EGL_WIDTH, static_cast<EGLint>(width),
|
||||
EGL_HEIGHT, static_cast<EGLint>(height), EGL_NONE};
|
||||
const EGLint pbufferAttribs[] = {EGL_WIDTH, static_cast<EGLint>(width), EGL_HEIGHT,
|
||||
static_cast<EGLint>(height), EGL_NONE};
|
||||
EGLSurface surface = remotePbuffer
|
||||
? EGLImpl::CreatePbufferSurface(context.Display, context.Config, pbufferAttribs)
|
||||
: EGLImpl::CreatePlatformWindowSurface(
|
||||
context.Display, context.Config, reinterpret_cast<void*>(drawable), attribs);
|
||||
? EGLImpl::CreatePbufferSurface(context.Display, context.Config, pbufferAttribs)
|
||||
: EGLImpl::CreatePlatformWindowSurface(context.Display, context.Config,
|
||||
reinterpret_cast<void*>(drawable), attribs);
|
||||
if (surface == EGL_NO_SURFACE) {
|
||||
MGLOG_E_ONCE("glx: failed to create window surface for drawable 0x%lx (%ux%u)", drawable,
|
||||
width, height);
|
||||
MGLOG_E_ONCE("glx: failed to create window surface for drawable 0x%lx (%ux%u)", drawable, width,
|
||||
height);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -598,8 +595,7 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
return &inserted->second;
|
||||
}
|
||||
|
||||
GLXContextHandle CreateContextFromEGLAttribs(Display* dpy, const FBConfigInfo* fbconfig,
|
||||
GLXContextHandle share,
|
||||
GLXContextHandle CreateContextFromEGLAttribs(Display* dpy, const FBConfigInfo* fbconfig, GLXContextHandle share,
|
||||
const EGLint* contextAttribs) {
|
||||
const std::lock_guard<std::recursive_mutex> lock(RegistryMutex());
|
||||
EGLDisplay display = EnsureDisplay();
|
||||
@@ -619,20 +615,27 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
}
|
||||
|
||||
const EGLint configAttribs[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 24,
|
||||
EGL_STENCIL_SIZE, fbconfig->StencilBits,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_RED_SIZE,
|
||||
8,
|
||||
EGL_GREEN_SIZE,
|
||||
8,
|
||||
EGL_BLUE_SIZE,
|
||||
8,
|
||||
EGL_ALPHA_SIZE,
|
||||
8,
|
||||
EGL_DEPTH_SIZE,
|
||||
24,
|
||||
EGL_STENCIL_SIZE,
|
||||
fbconfig->StencilBits,
|
||||
EGL_SURFACE_TYPE,
|
||||
EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE,
|
||||
EGL_OPENGL_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
EGLConfig config = nullptr;
|
||||
EGLint configCount = 0;
|
||||
if (!EGLImpl::ChooseConfig(display, configAttribs, &config, 1, &configCount) ||
|
||||
configCount <= 0) {
|
||||
if (!EGLImpl::ChooseConfig(display, configAttribs, &config, 1, &configCount) || configCount <= 0) {
|
||||
MGLOG_E_ONCE("glx: eglChooseConfig failed");
|
||||
return nullptr;
|
||||
}
|
||||
@@ -651,8 +654,7 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
object.FBConfig = fbconfig;
|
||||
const auto handle = EncodeContext(NextContextHandle()++);
|
||||
Contexts()[handle] = object;
|
||||
MGLOG_I("glx: created context %p (EGL context %p, stencil %d)", handle, eglContext,
|
||||
fbconfig->StencilBits);
|
||||
MGLOG_I("glx: created context %p (EGL context %p, stencil %d)", handle, eglContext, fbconfig->StencilBits);
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -777,8 +779,8 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
tmpl.depth = 24;
|
||||
tmpl.c_class = kTrueColor;
|
||||
int count = 0;
|
||||
XVisualInfoCompat* info = x11.GetVisualInfo(
|
||||
dpy, kVisualScreenMask | kVisualDepthMask | kVisualClassMask, &tmpl, &count);
|
||||
XVisualInfoCompat* info =
|
||||
x11.GetVisualInfo(dpy, kVisualScreenMask | kVisualDepthMask | kVisualClassMask, &tmpl, &count);
|
||||
if (info && count < 1) {
|
||||
x11.Free(info);
|
||||
return nullptr;
|
||||
@@ -829,8 +831,7 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
}
|
||||
|
||||
GLXFBConfigHandle* GetFBConfigs(Display*, int, int* nelements) {
|
||||
auto** configs = static_cast<GLXFBConfigHandle*>(
|
||||
std::malloc(sizeof(GLXFBConfigHandle) * kFBConfigCount));
|
||||
auto** configs = static_cast<GLXFBConfigHandle*>(std::malloc(sizeof(GLXFBConfigHandle) * kFBConfigCount));
|
||||
if (!configs) {
|
||||
if (nelements) {
|
||||
*nelements = 0;
|
||||
@@ -938,8 +939,7 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
auto** configs =
|
||||
static_cast<GLXFBConfigHandle*>(std::malloc(sizeof(GLXFBConfigHandle) * count));
|
||||
auto** configs = static_cast<GLXFBConfigHandle*>(std::malloc(sizeof(GLXFBConfigHandle) * count));
|
||||
if (!configs) {
|
||||
if (nelements) {
|
||||
*nelements = 0;
|
||||
@@ -1048,32 +1048,38 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
// A legacy GLX context is a compatibility-profile context; MobileGL keys
|
||||
// its relaxed-semantics mode off the explicit compatibility bit.
|
||||
const EGLint attribs[] = {
|
||||
EGL_CONTEXT_MAJOR_VERSION, 3,
|
||||
EGL_CONTEXT_MINOR_VERSION, 3,
|
||||
EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT,
|
||||
EGL_CONTEXT_MAJOR_VERSION,
|
||||
3,
|
||||
EGL_CONTEXT_MINOR_VERSION,
|
||||
3,
|
||||
EGL_CONTEXT_OPENGL_PROFILE_MASK,
|
||||
EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
return CreateContextFromEGLAttribs(dpy, &kFBConfigs[0], share, attribs);
|
||||
}
|
||||
|
||||
GLXContextHandle CreateNewContext(Display* dpy, GLXFBConfigHandle config, int renderType,
|
||||
GLXContextHandle share, int) {
|
||||
GLXContextHandle CreateNewContext(Display* dpy, GLXFBConfigHandle config, int renderType, GLXContextHandle share,
|
||||
int) {
|
||||
EnsureInitialized();
|
||||
const auto* info = TryGetFBConfig(config);
|
||||
if (!info || renderType != GLX_RGBA_TYPE) {
|
||||
return nullptr;
|
||||
}
|
||||
const EGLint attribs[] = {
|
||||
EGL_CONTEXT_MAJOR_VERSION, 3,
|
||||
EGL_CONTEXT_MINOR_VERSION, 3,
|
||||
EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT,
|
||||
EGL_CONTEXT_MAJOR_VERSION,
|
||||
3,
|
||||
EGL_CONTEXT_MINOR_VERSION,
|
||||
3,
|
||||
EGL_CONTEXT_OPENGL_PROFILE_MASK,
|
||||
EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
return CreateContextFromEGLAttribs(dpy, info, share, attribs);
|
||||
}
|
||||
|
||||
GLXContextHandle CreateContextAttribsARB(Display* dpy, GLXFBConfigHandle config,
|
||||
GLXContextHandle share, int, const int* attribList) {
|
||||
GLXContextHandle CreateContextAttribsARB(Display* dpy, GLXFBConfigHandle config, GLXContextHandle share, int,
|
||||
const int* attribList) {
|
||||
EnsureInitialized();
|
||||
const auto* info = TryGetFBConfig(config);
|
||||
if (!info) {
|
||||
@@ -1105,21 +1111,22 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
// Accepted and ignored: MobileGL always validates.
|
||||
break;
|
||||
default:
|
||||
MGLOG_D("glXCreateContextAttribsARB: ignoring attrib 0x%04x = 0x%x", attrib,
|
||||
value);
|
||||
MGLOG_D("glXCreateContextAttribsARB: ignoring attrib 0x%04x = 0x%x", attrib, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (major < 1 || (profileMask & ~(GLX_CONTEXT_CORE_PROFILE_BIT_ARB |
|
||||
GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB))) {
|
||||
if (major < 1 ||
|
||||
(profileMask & ~(GLX_CONTEXT_CORE_PROFILE_BIT_ARB | GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vector<EGLint> attribs = {
|
||||
EGL_CONTEXT_MAJOR_VERSION, major,
|
||||
EGL_CONTEXT_MINOR_VERSION, minor,
|
||||
EGL_CONTEXT_MAJOR_VERSION,
|
||||
major,
|
||||
EGL_CONTEXT_MINOR_VERSION,
|
||||
minor,
|
||||
};
|
||||
const Bool wantsCompat = (profileMask & GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) != 0;
|
||||
if (major > 3 || (major == 3 && minor >= 2) || profileMask != 0) {
|
||||
@@ -1186,8 +1193,7 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!EGLImpl::MakeCurrent(object->Display, surface->Surface, surface->Surface,
|
||||
object->Context)) {
|
||||
if (!EGLImpl::MakeCurrent(object->Display, surface->Surface, surface->Surface, object->Context)) {
|
||||
MGLOG_E_ONCE("glx: eglMakeCurrent failed (drawable=0x%lx, ctx=%p)", drawable, context);
|
||||
return 0;
|
||||
}
|
||||
@@ -1195,13 +1201,11 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MakeContextCurrent(Display* dpy, GLXDrawableHandle draw, GLXDrawableHandle read,
|
||||
GLXContextHandle context) {
|
||||
int MakeContextCurrent(Display* dpy, GLXDrawableHandle draw, GLXDrawableHandle read, GLXContextHandle context) {
|
||||
if (context && draw != read) {
|
||||
// MobileGL's backends reject split draw/read surfaces; bind the draw
|
||||
// drawable for both, which is what every real caller here needs.
|
||||
MGLOG_W_ONCE("glx: glXMakeContextCurrent draw 0x%lx != read 0x%lx, using draw for both", draw,
|
||||
read);
|
||||
MGLOG_W_ONCE("glx: glXMakeContextCurrent draw 0x%lx != read 0x%lx, using draw for both", draw, read);
|
||||
}
|
||||
const int result = MakeCurrent(dpy, draw, context);
|
||||
if (result && context) {
|
||||
@@ -1228,15 +1232,14 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
// next throttled geometry poll.
|
||||
Int32 configuredWidth = 0;
|
||||
Int32 configuredHeight = 0;
|
||||
const Bool configured =
|
||||
it->second.Chain && it->second.Chain->TakeConfiguredSize(&configuredWidth, &configuredHeight) &&
|
||||
(static_cast<Uint32>(configuredWidth) != it->second.Width ||
|
||||
static_cast<Uint32>(configuredHeight) != it->second.Height);
|
||||
const Bool configured = it->second.Chain &&
|
||||
it->second.Chain->TakeConfiguredSize(&configuredWidth, &configuredHeight) &&
|
||||
(static_cast<Uint32>(configuredWidth) != it->second.Width ||
|
||||
static_cast<Uint32>(configuredHeight) != it->second.Height);
|
||||
SyncSurfaceSize(dpy, drawable, it->second, configured);
|
||||
}
|
||||
|
||||
GLXDrawableHandle CreateWindow(Display*, GLXFBConfigHandle config, GLXDrawableHandle window,
|
||||
const int*) {
|
||||
GLXDrawableHandle CreateWindow(Display*, GLXFBConfigHandle config, GLXDrawableHandle window, const int*) {
|
||||
EnsureInitialized();
|
||||
const auto* info = TryGetFBConfig(config);
|
||||
if (!info || window == 0) {
|
||||
|
||||
@@ -33,14 +33,13 @@ namespace MobileGL::MG_Impl::GLXImpl {
|
||||
int GetConfig(Display* dpy, void* visualInfo, int attribute, int* value);
|
||||
|
||||
GLXContextHandle CreateContext(Display* dpy, void* visualInfo, GLXContextHandle share, int direct);
|
||||
GLXContextHandle CreateNewContext(Display* dpy, GLXFBConfigHandle config, int renderType,
|
||||
GLXContextHandle share, int direct);
|
||||
GLXContextHandle CreateContextAttribsARB(Display* dpy, GLXFBConfigHandle config, GLXContextHandle share,
|
||||
int direct, const int* attribList);
|
||||
GLXContextHandle CreateNewContext(Display* dpy, GLXFBConfigHandle config, int renderType, GLXContextHandle share,
|
||||
int direct);
|
||||
GLXContextHandle CreateContextAttribsARB(Display* dpy, GLXFBConfigHandle config, GLXContextHandle share, int direct,
|
||||
const int* attribList);
|
||||
void DestroyContext(Display* dpy, GLXContextHandle context);
|
||||
int MakeCurrent(Display* dpy, GLXDrawableHandle drawable, GLXContextHandle context);
|
||||
int MakeContextCurrent(Display* dpy, GLXDrawableHandle draw, GLXDrawableHandle read,
|
||||
GLXContextHandle context);
|
||||
int MakeContextCurrent(Display* dpy, GLXDrawableHandle draw, GLXDrawableHandle read, GLXContextHandle context);
|
||||
void SwapBuffers(Display* dpy, GLXDrawableHandle drawable);
|
||||
|
||||
GLXDrawableHandle CreateWindow(Display* dpy, GLXFBConfigHandle config, GLXDrawableHandle window,
|
||||
|
||||
@@ -51,9 +51,9 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
Path SelectPath(const ConnectionCaps& caps, Uint32 depth, const char* overrideValue) {
|
||||
const Bool putImageOnly = overrideValue != nullptr && std::strcmp(overrideValue, "putimage") == 0;
|
||||
const Bool noDri3 = putImageOnly || (overrideValue != nullptr && (std::strcmp(overrideValue, "readback") == 0 ||
|
||||
std::strcmp(overrideValue, "shm") == 0));
|
||||
if (!noDri3 && caps.SharedImages && caps.LocalConnection && FourccForDepth(depth) != 0 &&
|
||||
caps.Dri3Major >= 1 && caps.PresentMajor >= 1) {
|
||||
std::strcmp(overrideValue, "shm") == 0));
|
||||
if (!noDri3 && caps.SharedImages && caps.LocalConnection && FourccForDepth(depth) != 0 && caps.Dri3Major >= 1 &&
|
||||
caps.PresentMajor >= 1) {
|
||||
return Path::Dri3Present;
|
||||
}
|
||||
// MIT-SHM 1.2 is the first with a client-made segment passed as a descriptor (no SysV
|
||||
@@ -71,7 +71,8 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
}
|
||||
|
||||
Chain::~Chain() {
|
||||
for (Buffer& buffer : m_buffers) Drop(buffer);
|
||||
for (Buffer& buffer : m_buffers)
|
||||
Drop(buffer);
|
||||
m_connection.Flush();
|
||||
}
|
||||
|
||||
@@ -83,13 +84,15 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
|
||||
SizeT Chain::AllocatedBuffers() const {
|
||||
SizeT count = 0;
|
||||
for (const Buffer& buffer : m_buffers) count += buffer.Pixmap != 0 ? 1 : 0;
|
||||
for (const Buffer& buffer : m_buffers)
|
||||
count += buffer.Pixmap != 0 ? 1 : 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
SizeT Chain::BusyBuffers() const {
|
||||
SizeT count = 0;
|
||||
for (const Buffer& buffer : m_buffers) count += buffer.Pixmap != 0 && buffer.Busy ? 1 : 0;
|
||||
for (const Buffer& buffer : m_buffers)
|
||||
count += buffer.Pixmap != 0 && buffer.Busy ? 1 : 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -112,7 +115,8 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
Break("the server allocated no shared image for the window");
|
||||
return false;
|
||||
}
|
||||
if (image.Fd < 0 || image.Width != static_cast<Uint32>(m_width) || image.Height != static_cast<Uint32>(m_height)) {
|
||||
if (image.Fd < 0 || image.Width != static_cast<Uint32>(m_width) ||
|
||||
image.Height != static_cast<Uint32>(m_height)) {
|
||||
CloseDescriptor(image.Fd);
|
||||
m_images.Release(image.Id);
|
||||
Break("a shared image came back without a descriptor or at another size");
|
||||
@@ -164,7 +168,8 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
|
||||
void Chain::DrainEvents() {
|
||||
Event event;
|
||||
while (m_connection.PollEvent(&event)) Handle(event);
|
||||
while (m_connection.PollEvent(&event))
|
||||
Handle(event);
|
||||
}
|
||||
|
||||
void Chain::WaitForPacing(Int swapInterval) {
|
||||
|
||||
@@ -49,11 +49,15 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
|
||||
// ---- which path a window's frames take -------------------------------------------------------
|
||||
|
||||
enum class Path { Dri3Present, ShmPutImage, PutImage };
|
||||
enum class Path {
|
||||
Dri3Present,
|
||||
ShmPutImage,
|
||||
PutImage
|
||||
};
|
||||
const char* PathName(Path path);
|
||||
|
||||
struct ConnectionCaps {
|
||||
Bool SharedImages = false; // the backend allocates shared images (a split client)
|
||||
Bool SharedImages = false; // the backend allocates shared images (a split client)
|
||||
Bool LocalConnection = false; // a unix socket: descriptors can be passed
|
||||
Uint32 Dri3Major = 0, Dri3Minor = 0;
|
||||
Uint32 PresentMajor = 0, PresentMinor = 0;
|
||||
@@ -94,7 +98,12 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
};
|
||||
|
||||
struct Event {
|
||||
enum class Kind { None, Idle, Complete, Configure };
|
||||
enum class Kind {
|
||||
None,
|
||||
Idle,
|
||||
Complete,
|
||||
Configure
|
||||
};
|
||||
Kind Type = Kind::None;
|
||||
Uint32 Serial = 0;
|
||||
Uint32 Pixmap = 0;
|
||||
|
||||
@@ -123,16 +123,14 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
void* xfixes = OpenLibrary("libxcb-xfixes.so.0");
|
||||
a->xfixesId =
|
||||
xfixes != nullptr ? static_cast<xcb_extension_t*>(dlsym(xfixes, "xcb_xfixes_id")) : nullptr;
|
||||
a->xfixes = a->xfixesId != nullptr && R(xfixes, xcb_xfixes_query_version) &
|
||||
R(xfixes, xcb_xfixes_query_version_reply) &
|
||||
R(xfixes, xcb_xfixes_create_region) &
|
||||
R(xfixes, xcb_xfixes_destroy_region);
|
||||
a->xfixes = a->xfixesId != nullptr &&
|
||||
R(xfixes, xcb_xfixes_query_version) & R(xfixes, xcb_xfixes_query_version_reply) &
|
||||
R(xfixes, xcb_xfixes_create_region) & R(xfixes, xcb_xfixes_destroy_region);
|
||||
void* shm = OpenLibrary("libxcb-shm.so.0");
|
||||
a->shmId = shm != nullptr ? static_cast<xcb_extension_t*>(dlsym(shm, "xcb_shm_id")) : nullptr;
|
||||
a->shm = a->shmId != nullptr && R(shm, xcb_shm_query_version) &
|
||||
R(shm, xcb_shm_query_version_reply) &
|
||||
R(shm, xcb_shm_attach_fd_checked) & R(shm, xcb_shm_detach) &
|
||||
R(shm, xcb_shm_put_image);
|
||||
a->shm = a->shmId != nullptr &&
|
||||
R(shm, xcb_shm_query_version) & R(shm, xcb_shm_query_version_reply) &
|
||||
R(shm, xcb_shm_attach_fd_checked) & R(shm, xcb_shm_detach) & R(shm, xcb_shm_put_image);
|
||||
}
|
||||
#undef R
|
||||
return a;
|
||||
@@ -140,7 +138,9 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
return *api;
|
||||
}
|
||||
|
||||
xcb_connection_t* Xcb(void* connection) { return static_cast<xcb_connection_t*>(connection); }
|
||||
xcb_connection_t* Xcb(void* connection) {
|
||||
return static_cast<xcb_connection_t*>(connection);
|
||||
}
|
||||
|
||||
Bool ExtensionPresent(xcb_connection_t* c, xcb_extension_t* id) {
|
||||
const XcbApi& api = Api();
|
||||
@@ -196,7 +196,8 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
}
|
||||
// XFixes demands its version be asked before any other request of it.
|
||||
if (api.xfixes && ExtensionPresent(c, api.xfixesId)) {
|
||||
if (auto* reply = api.xcb_xfixes_query_version_reply(c, api.xcb_xfixes_query_version(c, 5, 0), nullptr)) {
|
||||
if (auto* reply =
|
||||
api.xcb_xfixes_query_version_reply(c, api.xcb_xfixes_query_version(c, 5, 0), nullptr)) {
|
||||
result.XFixes = reply->major_version >= 2;
|
||||
std::free(reply);
|
||||
}
|
||||
@@ -295,8 +296,9 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
if (m_buffers12 && api.xcb_dri3_pixmap_from_buffers_checked != nullptr) {
|
||||
int32_t fds[1] = {fd};
|
||||
cookie = api.xcb_dri3_pixmap_from_buffers_checked(
|
||||
m_c, pixmap, m_window, 1, static_cast<uint16_t>(image.Width), static_cast<uint16_t>(image.Height),
|
||||
image.Stride, image.Offset, 0, 0, 0, 0, 0, 0, static_cast<uint8_t>(depth), 32, image.Modifier, fds);
|
||||
m_c, pixmap, m_window, 1, static_cast<uint16_t>(image.Width),
|
||||
static_cast<uint16_t>(image.Height), image.Stride, image.Offset, 0, 0, 0, 0, 0, 0,
|
||||
static_cast<uint8_t>(depth), 32, image.Modifier, fds);
|
||||
} else {
|
||||
if (image.Offset != 0 || image.Stride > 0xffffu) {
|
||||
::close(fd);
|
||||
@@ -308,8 +310,9 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
static_cast<uint8_t>(depth), 32, fd);
|
||||
}
|
||||
if (xcb_generic_error_t* error = api.xcb_request_check(m_c, cookie)) {
|
||||
MGLOG_I("glx: the X server refused a %ux%u shared image as a pixmap (X error %u, major %u minor %u)",
|
||||
image.Width, image.Height, error->error_code, error->major_code, error->minor_code);
|
||||
MGLOG_I(
|
||||
"glx: the X server refused a %ux%u shared image as a pixmap (X error %u, major %u minor %u)",
|
||||
image.Width, image.Height, error->error_code, error->major_code, error->minor_code);
|
||||
std::free(error);
|
||||
return 0;
|
||||
}
|
||||
@@ -339,9 +342,8 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
}
|
||||
// An earlier present whose answer never came is given up on, not left queued.
|
||||
if (m_hasPendingPresent) api.xcb_discard_reply(m_c, m_pendingPresent);
|
||||
const xcb_void_cookie_t cookie =
|
||||
api.xcb_present_pixmap_checked(m_c, m_window, pixmap, serial, 0, region, 0, 0, 0, 0, 0, options,
|
||||
targetMsc, 0, 0, 0, nullptr);
|
||||
const xcb_void_cookie_t cookie = api.xcb_present_pixmap_checked(
|
||||
m_c, m_window, pixmap, serial, 0, region, 0, 0, 0, 0, 0, options, targetMsc, 0, 0, 0, nullptr);
|
||||
m_pendingPresent = cookie.sequence;
|
||||
m_hasPendingPresent = true;
|
||||
if (region != 0) api.xcb_xfixes_destroy_region(m_c, region);
|
||||
@@ -412,7 +414,8 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
public:
|
||||
explicit XcbShmPresenter(xcb_connection_t* c) : m_c(c) {}
|
||||
~XcbShmPresenter() override {
|
||||
for (Segment& segment : m_segments) Release(segment);
|
||||
for (Segment& segment : m_segments)
|
||||
Release(segment);
|
||||
Api().xcb_flush(m_c);
|
||||
}
|
||||
|
||||
@@ -492,7 +495,9 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
};
|
||||
} // namespace
|
||||
|
||||
ConnectionCaps QueryConnectionCaps(void* xcbConnection) { return Query(xcbConnection).Caps; }
|
||||
ConnectionCaps QueryConnectionCaps(void* xcbConnection) {
|
||||
return Query(xcbConnection).Caps;
|
||||
}
|
||||
|
||||
UniquePtr<Connection> CreateXcbConnection(void* xcbConnection, Uint32 window, const ConnectionCaps& caps) {
|
||||
const XcbApi& api = Api();
|
||||
@@ -514,9 +519,15 @@ namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
#else // !MOBILEGL_GLX_XCB_PRESENT
|
||||
|
||||
namespace MobileGL::MG_Impl::GLXImpl::X11Present {
|
||||
ConnectionCaps QueryConnectionCaps(void*) { return {}; }
|
||||
UniquePtr<Connection> CreateXcbConnection(void*, Uint32, const ConnectionCaps&) { return nullptr; }
|
||||
UniquePtr<ShmPresenter> CreateShmPresenter(void*) { return nullptr; }
|
||||
ConnectionCaps QueryConnectionCaps(void*) {
|
||||
return {};
|
||||
}
|
||||
UniquePtr<Connection> CreateXcbConnection(void*, Uint32, const ConnectionCaps&) {
|
||||
return nullptr;
|
||||
}
|
||||
UniquePtr<ShmPresenter> CreateShmPresenter(void*) {
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace MobileGL::MG_Impl::GLXImpl::X11Present
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,12 +16,10 @@
|
||||
|
||||
extern "C" EGLDisplay eglGetPlatformDisplayEXT(EGLenum platform, void* native_display, const EGLint* attrib_list);
|
||||
extern "C" EGLImage eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer,
|
||||
const EGLint* attrib_list);
|
||||
const EGLint* attrib_list);
|
||||
extern "C" EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImage image);
|
||||
extern "C" EGLBoolean eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface draw, const EGLint* rects,
|
||||
EGLint n_rects);
|
||||
extern "C" EGLBoolean eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface draw, const EGLint* rects,
|
||||
EGLint n_rects);
|
||||
extern "C" EGLBoolean eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface draw, const EGLint* rects, EGLint n_rects);
|
||||
extern "C" EGLBoolean eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface draw, const EGLint* rects, EGLint n_rects);
|
||||
extern "C" EGLBoolean eglSetDamageRegionKHR(EGLDisplay dpy, EGLSurface surface, EGLint* rects, EGLint n_rects);
|
||||
extern "C" EGLBoolean eglQueryDmaBufFormatsEXT(EGLDisplay dpy, EGLint max_formats, EGLint* formats,
|
||||
EGLint* num_formats);
|
||||
|
||||
@@ -70,8 +70,9 @@ namespace MobileGL::MG_Impl::NSOpenGLImpl {
|
||||
}
|
||||
|
||||
id SendIdCGLPixelFormat(id receiver, const char* selector, CGLPixelFormatObj value) {
|
||||
return receiver ? ObjcMsgSend<id (*)(id, SEL, CGLPixelFormatObj)>()(receiver, sel_registerName(selector), value)
|
||||
: nil;
|
||||
return receiver
|
||||
? ObjcMsgSend<id (*)(id, SEL, CGLPixelFormatObj)>()(receiver, sel_registerName(selector), value)
|
||||
: nil;
|
||||
}
|
||||
|
||||
void SendVoidCGRect(id receiver, const char* selector, CGRect value) {
|
||||
@@ -306,9 +307,9 @@ namespace MobileGL::MG_Impl::NSOpenGLImpl {
|
||||
}
|
||||
SetAssoc(self, &kContextViewKey, view, kAssociationAssign);
|
||||
SetAssoc(self, &kContextLayerKey, layer, kAssociationRetain);
|
||||
const auto error = CGLImpl::AttachDrawable(context, view, layer,
|
||||
static_cast<GLint>(geometry.DrawableSize.width),
|
||||
static_cast<GLint>(geometry.DrawableSize.height));
|
||||
const auto error =
|
||||
CGLImpl::AttachDrawable(context, view, layer, static_cast<GLint>(geometry.DrawableSize.width),
|
||||
static_cast<GLint>(geometry.DrawableSize.height));
|
||||
if (error != kCGLNoError) {
|
||||
MGLOG_E_ONCE("NSOpenGLImpl: failed to attach drawable: %s", CGLImpl::ErrorString(error));
|
||||
}
|
||||
@@ -373,9 +374,9 @@ namespace MobileGL::MG_Impl::NSOpenGLImpl {
|
||||
}
|
||||
const auto geometry = GetDrawableGeometry(view);
|
||||
ConfigureMetalLayerForView(layer, view, geometry);
|
||||
const auto error = CGLImpl::AttachDrawable(context, view, layer,
|
||||
static_cast<GLint>(geometry.DrawableSize.width),
|
||||
static_cast<GLint>(geometry.DrawableSize.height));
|
||||
const auto error =
|
||||
CGLImpl::AttachDrawable(context, view, layer, static_cast<GLint>(geometry.DrawableSize.width),
|
||||
static_cast<GLint>(geometry.DrawableSize.height));
|
||||
if (error != kCGLNoError) {
|
||||
MGLOG_E_ONCE("NSOpenGLImpl: update failed to attach drawable: %s", CGLImpl::ErrorString(error));
|
||||
return;
|
||||
@@ -448,8 +449,8 @@ namespace MobileGL::MG_Impl::NSOpenGLImpl {
|
||||
return false;
|
||||
}
|
||||
|
||||
ReplaceInstanceMethod(pixelFormatClass, "initWithAttributes:",
|
||||
reinterpret_cast<IMP>(PixelFormatInitWithAttributes));
|
||||
ReplaceInstanceMethod(pixelFormatClass,
|
||||
"initWithAttributes:", reinterpret_cast<IMP>(PixelFormatInitWithAttributes));
|
||||
ReplaceInstanceMethod(pixelFormatClass, "initWithCGLPixelFormatObj:",
|
||||
reinterpret_cast<IMP>(PixelFormatInitWithCGLPixelFormatObj));
|
||||
ReplaceInstanceMethod(pixelFormatClass, "getValues:forAttribute:forVirtualScreen:",
|
||||
@@ -461,10 +462,10 @@ namespace MobileGL::MG_Impl::NSOpenGLImpl {
|
||||
ReplaceInstanceMethod(pixelFormatClass, "dealloc", reinterpret_cast<IMP>(PixelFormatDealloc),
|
||||
&g_pixelFormatDealloc);
|
||||
|
||||
ReplaceInstanceMethod(contextClass, "initWithFormat:shareContext:",
|
||||
reinterpret_cast<IMP>(ContextInitWithFormatShare));
|
||||
ReplaceInstanceMethod(contextClass, "initWithCGLContextObj:",
|
||||
reinterpret_cast<IMP>(ContextInitWithCGLContextObj));
|
||||
ReplaceInstanceMethod(contextClass,
|
||||
"initWithFormat:shareContext:", reinterpret_cast<IMP>(ContextInitWithFormatShare));
|
||||
ReplaceInstanceMethod(contextClass,
|
||||
"initWithCGLContextObj:", reinterpret_cast<IMP>(ContextInitWithCGLContextObj));
|
||||
ReplaceInstanceMethod(contextClass, "setView:", reinterpret_cast<IMP>(ContextSetView));
|
||||
ReplaceInstanceMethod(contextClass, "view", reinterpret_cast<IMP>(ContextView));
|
||||
ReplaceInstanceMethod(contextClass, "makeCurrentContext", reinterpret_cast<IMP>(ContextMakeCurrent));
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
|
||||
namespace MobileGL::MG_Impl::NSOpenGLImpl {
|
||||
void InstallHooks();
|
||||
}
|
||||
} // namespace MobileGL::MG_Impl::NSOpenGLImpl
|
||||
|
||||
@@ -65,9 +65,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// distinguished because the two roles resolve them from different places and a reader
|
||||
// that answered one for the other would size an upload off the wrong bytes.
|
||||
enum class MGPipeClientBufferKind : Uint8 {
|
||||
Element, // the bound GL_ELEMENT_ARRAY_BUFFER, for the index stream
|
||||
IndirectCommand,// the bound GL_DRAW_INDIRECT_BUFFER, for the command block
|
||||
IndirectCount, // the bound GL_PARAMETER_BUFFER, for an *IndirectCount form's count
|
||||
Element, // the bound GL_ELEMENT_ARRAY_BUFFER, for the index stream
|
||||
IndirectCommand, // the bound GL_DRAW_INDIRECT_BUFFER, for the command block
|
||||
IndirectCount, // the bound GL_PARAMETER_BUFFER, for an *IndirectCount form's count
|
||||
};
|
||||
|
||||
// Reads `size` bytes at `offset` of the named buffer on the CPU. False when the bytes do
|
||||
@@ -136,7 +136,8 @@ namespace MobileGL::MG_Pipe {
|
||||
if (!fetch.Range.Count || !fetch.Instances) continue;
|
||||
const Uint64 first = fetch.BaseInstance;
|
||||
const Uint64 last = first + (fetch.Instances - 1u) / divisor;
|
||||
for (Uint64 at = first; at <= last; ++at) out.push_back(at);
|
||||
for (Uint64 at = first; at <= last; ++at)
|
||||
out.push_back(at);
|
||||
}
|
||||
std::sort(out.begin(), out.end());
|
||||
out.erase(std::unique(out.begin(), out.end()), out.end());
|
||||
@@ -151,9 +152,8 @@ namespace MobileGL::MG_Pipe {
|
||||
Uint32 count = indirect.DrawCount;
|
||||
if (indirect.HasParameterBuffer) {
|
||||
Uint32 actual = 0;
|
||||
if (reader == nullptr ||
|
||||
!reader(user, MGPipeClientBufferKind::IndirectCount, indirect.ParameterOffset, sizeof(actual),
|
||||
&actual)) {
|
||||
if (reader == nullptr || !reader(user, MGPipeClientBufferKind::IndirectCount, indirect.ParameterOffset,
|
||||
sizeof(actual), &actual)) {
|
||||
return false;
|
||||
}
|
||||
count = std::min(count, actual);
|
||||
@@ -165,9 +165,8 @@ namespace MobileGL::MG_Pipe {
|
||||
const Uint64 displacement = static_cast<Uint64>(i) * stride;
|
||||
if (displacement > std::numeric_limits<Uint64>::max() - indirect.Offset) return false;
|
||||
Uint32 words[5]{};
|
||||
if (reader == nullptr ||
|
||||
!reader(user, MGPipeClientBufferKind::IndirectCommand, indirect.Offset + displacement,
|
||||
commandBytes, words)) {
|
||||
if (reader == nullptr || !reader(user, MGPipeClientBufferKind::IndirectCommand,
|
||||
indirect.Offset + displacement, commandBytes, words)) {
|
||||
return false;
|
||||
}
|
||||
Int32 bias = 0;
|
||||
@@ -199,8 +198,7 @@ namespace MobileGL::MG_Pipe {
|
||||
} else {
|
||||
indexBytes.resize(static_cast<SizeT>(size));
|
||||
if (reader == nullptr ||
|
||||
!reader(user, MGPipeClientBufferKind::Element, offset, indexBytes.size(),
|
||||
indexBytes.data())) {
|
||||
!reader(user, MGPipeClientBufferKind::Element, offset, indexBytes.size(), indexBytes.data())) {
|
||||
return false;
|
||||
}
|
||||
data = indexBytes.data();
|
||||
|
||||
@@ -64,8 +64,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// one death helper and in its fixed order. That is the pipeline-cache release path; the
|
||||
// composite's own destructor is the other one and the second of the two is the proven
|
||||
// no-op.
|
||||
MGPipeHandle Observe(Uint64 contextId, const ProgramPipelineObject& pipeline,
|
||||
const ProgramObject& composite, MGPipeHandle handle) {
|
||||
MGPipeHandle Observe(Uint64 contextId, const ProgramPipelineObject& pipeline, const ProgramObject& composite,
|
||||
MGPipeHandle handle) {
|
||||
const DrawProgramSignature signature = pipeline.ComputeDrawProgramSignature();
|
||||
const Uint pipelineName = pipeline.GetExternalIndex();
|
||||
Entry* entry = Find(contextId, pipelineName);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace MobileGL::MG_Pipe {
|
||||
class MGPipeCsoCache {
|
||||
public:
|
||||
struct Counters {
|
||||
Uint64 Mints = 0; // create_render_state emissions
|
||||
Uint64 Mints = 0; // create_render_state emissions
|
||||
// bind_render_state emissions, mint or reuse. Counted in Acquire because Acquire
|
||||
// has exactly ONE caller (PipeFill.cpp's EmitRenderState) and that caller binds
|
||||
// immediately after every call - so "acquisitions" and "binds" are the same
|
||||
@@ -42,9 +42,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// remembering to tick it. mints/binds is the cache's hit rate and it is the
|
||||
// number the CSO content-addressing negative control moves.
|
||||
Uint64 Binds = 0;
|
||||
Uint64 Hits = 0; // a probe that found a live entry and passed the memcmp
|
||||
Uint64 Hits = 0; // a probe that found a live entry and passed the memcmp
|
||||
Uint64 Collisions = 0; // a hash hit the memcmp REJECTED - the reason it exists
|
||||
Uint64 Evictions = 0; // LRU evictions, each one a delete_render_state
|
||||
Uint64 Evictions = 0; // LRU evictions, each one a delete_render_state
|
||||
};
|
||||
|
||||
// The handle for `params`' pipeline subset. Mints and emits create_render_state on a
|
||||
@@ -55,11 +55,10 @@ namespace MobileGL::MG_Pipe {
|
||||
MGPipeGatherPipelineBytes(params, bytes.data());
|
||||
++m_counters.Binds;
|
||||
|
||||
const Bool contentAddressed =
|
||||
(MG_Config::Features.PipePush & kMGPipeBehaviourNoCsoContentAddressing) == 0;
|
||||
const Bool contentAddressed = (MG_Config::Features.PipePush & kMGPipeBehaviourNoCsoContentAddressing) == 0;
|
||||
if (contentAddressed) {
|
||||
const Uint64 hash = s_hashForTest != nullptr ? s_hashForTest(bytes.data())
|
||||
: MGPipeHashPipelineBytes(bytes.data());
|
||||
const Uint64 hash =
|
||||
s_hashForTest != nullptr ? s_hashForTest(bytes.data()) : MGPipeHashPipelineBytes(bytes.data());
|
||||
for (SizeT i = 0; i < m_entries.size(); ++i) {
|
||||
if (m_entries[i].Hash != hash) continue;
|
||||
if (std::memcmp(m_entries[i].Bytes.data(), bytes.data(), bytes.size()) != 0) {
|
||||
@@ -87,7 +86,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// is reset alongside, and a delete for a record that is about to be dropped anyway
|
||||
// would be a wire message with no reader.
|
||||
void Reset() {
|
||||
for (auto& entry : m_entries) MGPipeSlots().Free(MGPipeKind::RenderStateCso, entry.Cso);
|
||||
for (auto& entry : m_entries)
|
||||
MGPipeSlots().Free(MGPipeKind::RenderStateCso, entry.Cso);
|
||||
m_entries.clear();
|
||||
m_clock = 0;
|
||||
}
|
||||
@@ -114,8 +114,7 @@ namespace MobileGL::MG_Pipe {
|
||||
Array<Uint8, kMGPipePipelineChunkBytes> Bytes{};
|
||||
};
|
||||
|
||||
MGPipeHandle Mint(Uint64 hash, const Array<Uint8, kMGPipePipelineChunkBytes>& bytes,
|
||||
Uint64& payloadBytes) {
|
||||
MGPipeHandle Mint(Uint64 hash, const Array<Uint8, kMGPipePipelineChunkBytes>& bytes, Uint64& payloadBytes) {
|
||||
if (m_entries.size() >= kMGPipeCsoCacheCapacity) {
|
||||
SizeT victim = 0;
|
||||
for (SizeT i = 1; i < m_entries.size(); ++i) {
|
||||
@@ -161,8 +160,7 @@ namespace MobileGL::MG_Pipe {
|
||||
++m_counters.Evictions;
|
||||
}
|
||||
|
||||
static constexpr Uint32 kAllPipelineChunks =
|
||||
static_cast<Uint32>((Uint64{1} << kMGPipePipelineChunkCount) - 1);
|
||||
static constexpr Uint32 kAllPipelineChunks = static_cast<Uint32>((Uint64{1} << kMGPipePipelineChunkCount) - 1);
|
||||
|
||||
Vector<Entry> m_entries;
|
||||
Uint64 m_clock = 0;
|
||||
|
||||
@@ -268,10 +268,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// that "nothing moved" costs one compare rather than two.
|
||||
const Uint64 drawHash = drawOk ? drawState.ContentHash : 0;
|
||||
const Uint64 readHash = readOk ? readState.ContentHash : 0;
|
||||
const Uint64 combined =
|
||||
MGPipeMixShutter(MGPipeMixShutter(drawHash, readHash), shared ? 1u : 0u);
|
||||
if (!MGPipeSetHashSuppressorInstance().ShouldEmit(MGPipeSuppressorSlot::SetFramebufferState,
|
||||
combined)) {
|
||||
const Uint64 combined = MGPipeMixShutter(MGPipeMixShutter(drawHash, readHash), shared ? 1u : 0u);
|
||||
if (!MGPipeSetHashSuppressorInstance().ShouldEmit(MGPipeSuppressorSlot::SetFramebufferState, combined)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -405,7 +403,8 @@ namespace MobileGL::MG_Pipe {
|
||||
void ResetForTest() {
|
||||
Reset();
|
||||
ResetCounters();
|
||||
for (auto& memo : m_buildMemo) memo.Valid = false;
|
||||
for (auto& memo : m_buildMemo)
|
||||
memo.Valid = false;
|
||||
m_lastDraw = MGPFramebufferState{};
|
||||
m_lastRead = MGPFramebufferState{};
|
||||
m_lastNamed = MGPFramebufferState{};
|
||||
@@ -453,15 +452,14 @@ namespace MobileGL::MG_Pipe {
|
||||
// truncating it silently is exactly the bug class this phase is closing. The
|
||||
// backend half of the same refusal (bit 9 declined at its first lookup, with one
|
||||
// ERROR naming the cap) rides ResolveFramebufferSubsystemArm.
|
||||
for (Int point = static_cast<Int>(FramebufferAttachmentType::Color0) +
|
||||
static_cast<Int>(kMGPipeMaxColorAttachments);
|
||||
for (Int point =
|
||||
static_cast<Int>(FramebufferAttachmentType::Color0) + static_cast<Int>(kMGPipeMaxColorAttachments);
|
||||
point <= static_cast<Int>(FramebufferAttachmentType::ColorMax); ++point) {
|
||||
if (fbo.GetAttachment(static_cast<FramebufferAttachmentType>(point)).IsEmpty()) continue;
|
||||
MGLOG_E_ONCE("MGPipe: framebuffer %u has an attachment at colour point %d, which is at or "
|
||||
"above the wire width of %u - set_framebuffer_state is refused rather than "
|
||||
"truncated and the legacy arm runs",
|
||||
fbo.GetExternalIndex(),
|
||||
point - static_cast<Int>(FramebufferAttachmentType::Color0),
|
||||
fbo.GetExternalIndex(), point - static_cast<Int>(FramebufferAttachmentType::Color0),
|
||||
static_cast<Uint>(kMGPipeMaxColorAttachments));
|
||||
++m_refusals;
|
||||
return false;
|
||||
@@ -478,8 +476,7 @@ namespace MobileGL::MG_Pipe {
|
||||
"at or above the wire width of %u - set_framebuffer_state is refused "
|
||||
"rather than truncated and the legacy arm runs",
|
||||
fbo.GetExternalIndex(),
|
||||
static_cast<Int>(tokens[i]) -
|
||||
static_cast<Int>(FramebufferAttachmentType::Color0),
|
||||
static_cast<Int>(tokens[i]) - static_cast<Int>(FramebufferAttachmentType::Color0),
|
||||
static_cast<Uint>(i), static_cast<Uint>(kMGPipeMaxColorAttachments));
|
||||
++m_refusals;
|
||||
return false;
|
||||
@@ -505,9 +502,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// the draw-buffer indices below still map BackLeft to slot 0.
|
||||
if (out.IsDefault == 0) {
|
||||
for (SizeT i = 0; i < kMGPipeMaxColorAttachments; ++i) {
|
||||
out.Color[i] = SurfaceOf(fbo, static_cast<FramebufferAttachmentType>(
|
||||
static_cast<Int>(FramebufferAttachmentType::Color0) +
|
||||
static_cast<Int>(i)));
|
||||
out.Color[i] =
|
||||
SurfaceOf(fbo, static_cast<FramebufferAttachmentType>(
|
||||
static_cast<Int>(FramebufferAttachmentType::Color0) + static_cast<Int>(i)));
|
||||
}
|
||||
out.Depth = SurfaceOf(fbo, FramebufferAttachmentType::Depth);
|
||||
out.Stencil = SurfaceOf(fbo, FramebufferAttachmentType::Stencil);
|
||||
@@ -594,8 +591,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// DEPTH_STENCIL, the two sticky bind bits nothing set before P4a. Sticky and ORed,
|
||||
// so a texture that was ever a colour attachment keeps saying so, and the mask is
|
||||
// republished on the resource's next respecify.
|
||||
const Uint16 bit = (type == FramebufferAttachmentType::Depth ||
|
||||
type == FramebufferAttachmentType::Stencil)
|
||||
const Uint16 bit = (type == FramebufferAttachmentType::Depth || type == FramebufferAttachmentType::Stencil)
|
||||
? static_cast<Uint16>(kMGPipeBindDepthStencil)
|
||||
: static_cast<Uint16>(kMGPipeBindRenderTarget);
|
||||
MGPipeHandle res = kMGPipeNullHandle;
|
||||
@@ -622,15 +618,13 @@ namespace MobileGL::MG_Pipe {
|
||||
if (!found) {
|
||||
out.Width = static_cast<Uint16>(std::clamp<Int>(size.x(), 0, 0xFFFF));
|
||||
out.Height = static_cast<Uint16>(std::clamp<Int>(size.y(), 0, 0xFFFF));
|
||||
out.Layers = static_cast<Uint16>(
|
||||
attachment.IsLayered() ? std::clamp<Int>(size.z(), 1, 0xFFFF) : 1);
|
||||
out.Layers = static_cast<Uint16>(attachment.IsLayered() ? std::clamp<Int>(size.z(), 1, 0xFFFF) : 1);
|
||||
if (attachment.IsTexture()) {
|
||||
const auto& texture = attachment.GetTexture();
|
||||
out.Samples = static_cast<Uint16>(std::max<Int>(texture->GetSamples(), 0));
|
||||
out.FixedSampleLocations = texture->HasFixedSampleLocations() ? 1 : 0;
|
||||
} else {
|
||||
out.Samples = static_cast<Uint16>(
|
||||
std::max<Int>(attachment.GetRenderbuffer()->GetSamples(), 0));
|
||||
out.Samples = static_cast<Uint16>(std::max<Int>(attachment.GetRenderbuffer()->GetSamples(), 0));
|
||||
out.FixedSampleLocations = 1;
|
||||
}
|
||||
found = true;
|
||||
@@ -672,8 +666,7 @@ namespace MobileGL::MG_Pipe {
|
||||
if (entry.IsTexture) {
|
||||
const auto& texture = attachment.GetTexture();
|
||||
return texture->GetLifetimeId() == entry.LifetimeId &&
|
||||
texture->GetShapeVersion() == entry.ShapeVersion &&
|
||||
texture->GetSamples() == entry.Samples &&
|
||||
texture->GetShapeVersion() == entry.ShapeVersion && texture->GetSamples() == entry.Samples &&
|
||||
texture->HasFixedSampleLocations() == entry.FixedSampleLocations;
|
||||
}
|
||||
const auto& renderbuffer = attachment.GetRenderbuffer();
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace MobileGL::MG_Pipe {
|
||||
entry.InternalFormat = static_cast<Uint32>(binding.Format);
|
||||
entry.Layer = static_cast<Uint32>(binding.Layer);
|
||||
entry.Level = MGPipeImageBindingIsAccessible(binding) ? static_cast<Uint16>(binding.Level)
|
||||
: kMGPipeImageLevelNone;
|
||||
: kMGPipeImageLevelNone;
|
||||
entry.Layered = binding.Layered != GL_FALSE ? 1 : 0;
|
||||
entry.Access = static_cast<Uint8>(MGPipeEncodeImageAccess(binding.Access));
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ namespace MobileGL::MG_Pipe {
|
||||
~MGPipeOwnedDrawInputs() {
|
||||
if (m_vertexBindingsChanged)
|
||||
MGPipeVertexInputEmitterInstance().EmitVertexBuffers(m_context, m_baseInstance);
|
||||
if (m_indexBindingChanged)
|
||||
MGPipeVertexInputEmitterInstance().EmitIndexBuffer(m_context);
|
||||
if (m_indexBindingChanged) MGPipeVertexInputEmitterInstance().EmitIndexBuffer(m_context);
|
||||
// The bindings no longer name them: the buffers go back to the share group for the
|
||||
// next client-array draw. Their next respecify orphans the store this draw reads.
|
||||
auto& group = *m_context.GetShareGroup();
|
||||
@@ -41,8 +40,8 @@ namespace MobileGL::MG_Pipe {
|
||||
if (m_indexBuffer) group.ReturnClientArrayBuffer(std::move(m_indexBuffer));
|
||||
}
|
||||
|
||||
Bool Prepare(MGPDrawInfo& info, const MGPDrawRange* ranges, Uint32 rangeCount,
|
||||
const void* clientIndices, Uint64 clientIndexBytes, const MGPDrawIndirect* indirect) {
|
||||
Bool Prepare(MGPDrawInfo& info, const MGPDrawRange* ranges, Uint32 rangeCount, const void* clientIndices,
|
||||
Uint64 clientIndexBytes, const MGPDrawIndirect* indirect) {
|
||||
m_baseInstance = info.StartInstance;
|
||||
const auto& vao = m_context.GetBoundVertexArray();
|
||||
if (!vao) return (info.Flags & kDrawClientArrays) == 0 && clientIndexBytes == 0;
|
||||
@@ -87,9 +86,10 @@ namespace MobileGL::MG_Pipe {
|
||||
inputs.BaseInstance = info.StartInstance;
|
||||
inputs.PrimitiveRestart = (info.Flags & kDrawPrimitiveRestart) != 0;
|
||||
const Bool fixedRestart = m_context.IsCapabilityEnabled(CapabilityInput::PrimitiveRestartFixedIndex);
|
||||
inputs.RestartIndex = fixedRestart
|
||||
? (info.IndexSize == 1 ? 0xffu : info.IndexSize == 2 ? 0xffffu : 0xffffffffu)
|
||||
: info.RestartIndex;
|
||||
inputs.RestartIndex = fixedRestart ? (info.IndexSize == 1 ? 0xffu
|
||||
: info.IndexSize == 2 ? 0xffffu
|
||||
: 0xffffffffu)
|
||||
: info.RestartIndex;
|
||||
inputs.ClientIndices = clientIndices;
|
||||
inputs.ClientIndexBytes = clientIndexBytes;
|
||||
inputs.WantVertices = needsVertexIndices;
|
||||
@@ -114,8 +114,7 @@ namespace MobileGL::MG_Pipe {
|
||||
if (!m_plan.Elements(static_cast<Uint32>(attribute.Divisor), referenced)) return false;
|
||||
const Uint64 stride = static_cast<Uint32>(attribute.Stride);
|
||||
const Uint64 last = referenced.empty() ? 0 : referenced.back();
|
||||
if (stride != 0 && last > (std::numeric_limits<Uint32>::max() - elementBytes) / stride)
|
||||
return false;
|
||||
if (stride != 0 && last > (std::numeric_limits<Uint32>::max() - elementBytes) / stride) return false;
|
||||
const SizeT byteCount = static_cast<SizeT>(last * stride + elementBytes);
|
||||
Vector<Uint8> bytes(byteCount, 0);
|
||||
if (!referenced.empty()) {
|
||||
@@ -139,7 +138,8 @@ namespace MobileGL::MG_Pipe {
|
||||
}
|
||||
}
|
||||
}
|
||||
m_vertexBuffers[location] = MakeOwnedBuffer(m_context, bytes.data(), bytes.size(), BufferTarget::Vertex);
|
||||
m_vertexBuffers[location] =
|
||||
MakeOwnedBuffer(m_context, bytes.data(), bytes.size(), BufferTarget::Vertex);
|
||||
handles[location] = MGPipeResourceTrackerInstance().Find(*m_vertexBuffers[location]);
|
||||
}
|
||||
MGPipeVertexInputEmitterInstance().EmitVertexBuffers(m_context, info.StartInstance, &handles);
|
||||
@@ -173,15 +173,30 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
static SizeT AttributeBytes(const MG_State::GLState::VertexAttribute& attribute) {
|
||||
if (attribute.IsBgra || attribute.Type == DataType::Int2101010Rev ||
|
||||
attribute.Type == DataType::Uint2101010Rev) return 4;
|
||||
attribute.Type == DataType::Uint2101010Rev)
|
||||
return 4;
|
||||
SizeT component = 0;
|
||||
switch (attribute.Type) {
|
||||
case DataType::Int8: case DataType::Uint8: component = 1; break;
|
||||
case DataType::Int16: case DataType::Uint16: case DataType::Float16: component = 2; break;
|
||||
case DataType::Int32: case DataType::Uint32: case DataType::Float32: case DataType::Fixed32:
|
||||
component = 4; break;
|
||||
case DataType::Float64: component = 8; break;
|
||||
default: return 0;
|
||||
case DataType::Int8:
|
||||
case DataType::Uint8:
|
||||
component = 1;
|
||||
break;
|
||||
case DataType::Int16:
|
||||
case DataType::Uint16:
|
||||
case DataType::Float16:
|
||||
component = 2;
|
||||
break;
|
||||
case DataType::Int32:
|
||||
case DataType::Uint32:
|
||||
case DataType::Float32:
|
||||
case DataType::Fixed32:
|
||||
component = 4;
|
||||
break;
|
||||
case DataType::Float64:
|
||||
component = 8;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return attribute.Size > 0 && attribute.Size <= 4 ? component * attribute.Size : 0;
|
||||
}
|
||||
|
||||
+186
-210
@@ -76,7 +76,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// list of friend functions so the header names exactly one friend.
|
||||
struct MGPipeFillAccess {
|
||||
static void CopyServerPackReference(PipeInputs& dst, const PipeInputs& actual,
|
||||
const PixelStoreParameters& pack) {
|
||||
const PixelStoreParameters& pack) {
|
||||
dst.m_pixelStore[0] = pack;
|
||||
dst.m_pixelStore[1] = actual.m_pixelStore[1];
|
||||
}
|
||||
@@ -139,7 +139,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// every draw does not pay a reference-count increment and decrement for a pointer it
|
||||
// already holds (P14: one of these moves per Minecraft draw, the other three rarely).
|
||||
case F::GetBoundVertexArray:
|
||||
if (dst.m_boundVertexArray != ctx.GetBoundVertexArray()) dst.m_boundVertexArray = ctx.GetBoundVertexArray();
|
||||
if (dst.m_boundVertexArray != ctx.GetBoundVertexArray())
|
||||
dst.m_boundVertexArray = ctx.GetBoundVertexArray();
|
||||
break;
|
||||
case F::GetBufferBindingSlot:
|
||||
// Every global target has a slot; Index stays null - GLContext resolves it
|
||||
@@ -358,11 +359,15 @@ namespace MobileGL::MG_Pipe {
|
||||
};
|
||||
|
||||
namespace {
|
||||
GLContext* LiveContext() { return MG_State::pGLContext.get(); }
|
||||
GLContext* LiveContext() {
|
||||
return MG_State::pGLContext.get();
|
||||
}
|
||||
|
||||
#if !MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P13 W5: no transport, no run-ahead client.
|
||||
Bool ClientRunsAhead() { return false; }
|
||||
Bool ClientRunsAhead() {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// ---- P5e (ra): the fill decision (CONTRACT-P5E §3.1) -----------------------------
|
||||
@@ -408,12 +413,12 @@ namespace MobileGL::MG_Pipe {
|
||||
if (g_forceBarrieredFill) return true;
|
||||
MGPWireOp op = MGPipeRecordOpForVerb(verb);
|
||||
if (op == MGPWireOp::ReadPixels && PackReadbackGoesToBuffer(ctx)) op = MGPWireOp::ReadPixelsToBuffer;
|
||||
if (op == MGPWireOp::GetTextureImage && PackReadbackGoesToBuffer(ctx)) op = MGPWireOp::GetTextureImageToBuffer;
|
||||
if (op == MGPWireOp::GetTextureImage && PackReadbackGoesToBuffer(ctx))
|
||||
op = MGPWireOp::GetTextureImageToBuffer;
|
||||
// No record (answered from the caps mirror): no apply can read a fill for it.
|
||||
if (op == kMGPipeNoRecord) return false;
|
||||
if (MGPipeWaitClassFor(op) != kWaitNone) return true;
|
||||
if (MGPipeCallClassFor(op) == kCtxVerb && ctx != nullptr &&
|
||||
ctx->IsTransformFeedbackActive()) {
|
||||
if (MGPipeCallClassFor(op) == kCtxVerb && ctx != nullptr && ctx->IsTransformFeedbackActive()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -529,7 +534,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// precedes MGP_INPUT_VERIFY_READ in every accessor and a stamp of 0 is never fresh,
|
||||
// so such a read is Fatal{UnmigratedPipeInput, "<Field>@<none>"} before the hook
|
||||
// could matter - which holds only while a verify build always carries the poison.
|
||||
static_assert(MOBILEGL_PIPE_POISON, "the compare-at-read hook relies on the poison for reads before the first fill");
|
||||
static_assert(MOBILEGL_PIPE_POISON,
|
||||
"the compare-at-read hook relies on the poison for reads before the first fill");
|
||||
|
||||
struct VerifyState {
|
||||
Bool Parsed = false;
|
||||
@@ -569,8 +575,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// filled). Cost: two Bool compares and one String compare per fill, verify builds only.
|
||||
void ArmVerify() {
|
||||
const auto& features = MG_Config::Features;
|
||||
if (g_verify.Parsed && g_verify.Enabled == features.PipeVerify && g_verify.Fatal == features.PipeVerifyFatal &&
|
||||
g_verify.CorruptKnob == features.PipeVerifyCorrupt) {
|
||||
if (g_verify.Parsed && g_verify.Enabled == features.PipeVerify &&
|
||||
g_verify.Fatal == features.PipeVerifyFatal && g_verify.CorruptKnob == features.PipeVerifyCorrupt) {
|
||||
return;
|
||||
}
|
||||
g_verify.Parsed = true;
|
||||
@@ -588,18 +594,20 @@ namespace MobileGL::MG_Pipe {
|
||||
g_verify.Corrupt = field;
|
||||
}
|
||||
// The lanes grep for this line: a verify run whose log lacks it never armed.
|
||||
MGLOG_I("MGPipe: verify armed - %u fields, %u verbs, fatal=%d", static_cast<unsigned>(kMGPipeInputFieldCount),
|
||||
static_cast<unsigned>(kMGPipeVerbCount), g_verify.Fatal ? 1 : 0);
|
||||
MGLOG_I("MGPipe: verify armed - %u fields, %u verbs, fatal=%d",
|
||||
static_cast<unsigned>(kMGPipeInputFieldCount), static_cast<unsigned>(kMGPipeVerbCount),
|
||||
g_verify.Fatal ? 1 : 0);
|
||||
if (g_verify.Corrupt) {
|
||||
MGLOG_I("MGPipe: verify corruption armed - %s", kMGPipeInputFieldNames[static_cast<SizeT>(*g_verify.Corrupt)]);
|
||||
MGLOG_I("MGPipe: verify corruption armed - %s",
|
||||
kMGPipeInputFieldNames[static_cast<SizeT>(*g_verify.Corrupt)]);
|
||||
}
|
||||
}
|
||||
|
||||
void ReportDivergence(MGPipeInputField field, const char* where) {
|
||||
const Uint64 serial = MGPipeFillAccess::Filled(MGPipeClientInputs()).CurrentVerbSerial;
|
||||
MGLOG_F("MGPipe: Fatal{PipeVerifyDiffer, \"%s@%s\", verb=%llu, where=%s}",
|
||||
kMGPipeInputFieldNames[static_cast<SizeT>(field)], MGPipeVerbName(MGPipeClientInputs().CurrentVerb()),
|
||||
static_cast<unsigned long long>(serial), where);
|
||||
kMGPipeInputFieldNames[static_cast<SizeT>(field)],
|
||||
MGPipeVerbName(MGPipeClientInputs().CurrentVerb()), static_cast<unsigned long long>(serial), where);
|
||||
if (g_verify.Fatal) std::abort();
|
||||
g_verify.Divergences.fetch_add(1, std::memory_order_relaxed);
|
||||
}
|
||||
@@ -685,7 +693,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// PipeInputs.h. The FATAL=0 summary, written while the role's log is still open:
|
||||
// MobileGL::Destroy calls this right before MG_Util::Debug::Close() - see VerifyState for why
|
||||
// the static destructor cannot be the writer.
|
||||
void MGPipeVerifyFlushSummary() { g_verify.FlushSummary(); }
|
||||
void MGPipeVerifyFlushSummary() {
|
||||
g_verify.FlushSummary();
|
||||
}
|
||||
#endif // MOBILEGL_PIPE_VERIFY
|
||||
|
||||
// ---- push on mutation (P1 lane finding F2) ----
|
||||
@@ -722,8 +732,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// barriered verb the applier is usually already caught up, so this is a watermark test
|
||||
// rather than a park in the common case.
|
||||
QuiesceApplierBeforeFill("MGPipeNoteFrontendMutation");
|
||||
MG_Remote::Client::ClientSession::RefusePipeInputsTouchWhileApplierOwnsIt(
|
||||
"MGPipeNoteFrontendMutation", /*isBarrieredFill=*/true);
|
||||
MG_Remote::Client::ClientSession::RefusePipeInputsTouchWhileApplierOwnsIt("MGPipeNoteFrontendMutation",
|
||||
/*isBarrieredFill=*/true);
|
||||
#endif
|
||||
auto* ctx = LiveContext();
|
||||
if (ctx == nullptr) return;
|
||||
@@ -931,8 +941,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// place. Monolith keeps initialBytes on the record; its applier reads them directly. The
|
||||
// apply thread (RunsAsTheServerRole()) also takes the plain route: it emits no client wire
|
||||
// records, so the follow-up's self-check would abort the server.
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith &&
|
||||
!MG_Remote::Client::RunsAsTheServerRole() && initialBytes != nullptr) {
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith && !MG_Remote::Client::RunsAsTheServerRole() &&
|
||||
initialBytes != nullptr) {
|
||||
MGPipeRouteResourceRespecify(desc, nullptr);
|
||||
// COUNTED, NOT ASSUMED, and this is the only thing that can gate the follow-up at
|
||||
// all. Dropping the walk below leaves a respecify that went out with nullptr and
|
||||
@@ -989,15 +999,18 @@ namespace MobileGL::MG_Pipe {
|
||||
return stageChunk == 0 ? kMGPipeSubDataMaxRecordSize : static_cast<Uint64>(stageChunk);
|
||||
}
|
||||
#else
|
||||
constexpr Uint64 MGPipeContentChunkCap() { return kMGPipeSubDataMaxRecordSize; }
|
||||
constexpr Uint64 MGPipeContentChunkCap() {
|
||||
return kMGPipeSubDataMaxRecordSize;
|
||||
}
|
||||
#endif
|
||||
|
||||
void MGPipeEmitResourceSubData(BufferObject& buffer, SizeT offset, SizeT size) {
|
||||
const MGPipeHandle handle = ContentHandleFor(buffer, "resource_subdata");
|
||||
if (MGPipeHandleIsNull(handle)) return;
|
||||
const Uint8* base = buffer.MappedData();
|
||||
const Bool encodable =
|
||||
MGPipeForEachSubDataRecordRange(offset, size, [&](Uint64 at, Uint64 length) {
|
||||
const Bool encodable = MGPipeForEachSubDataRecordRange(
|
||||
offset, size,
|
||||
[&](Uint64 at, Uint64 length) {
|
||||
MGPSubData record{};
|
||||
// The pre-pass inside the walk proved every piece encodable before the first
|
||||
// one was emitted, so this cannot be false - but a zeroed record (null
|
||||
@@ -1015,7 +1028,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// rather than re-read so the staged run and the record's own claim come from
|
||||
// one number.
|
||||
MGPipeRouteResourceSubData(record, base + at, length);
|
||||
}, MGPipeContentChunkCap());
|
||||
},
|
||||
MGPipeContentChunkCap());
|
||||
if (!encodable) {
|
||||
MGLOG_E_ONCE("MGPipe: resource_subdata range [%llu, +%llu) on buffer %u cannot be encoded - "
|
||||
"one record's destination box caps the offset at 2^31-1",
|
||||
@@ -1028,8 +1042,9 @@ namespace MobileGL::MG_Pipe {
|
||||
const MGPipeHandle handle = ContentHandleFor(buffer, "buffer_subdata_resident");
|
||||
if (MGPipeHandleIsNull(handle)) return;
|
||||
const auto* base = static_cast<const Uint8*>(bytes);
|
||||
const Bool encodable =
|
||||
MGPipeForEachSubDataRecordRange(offset, size, [&](Uint64 at, Uint64 length) {
|
||||
const Bool encodable = MGPipeForEachSubDataRecordRange(
|
||||
offset, size,
|
||||
[&](Uint64 at, Uint64 length) {
|
||||
MGPSubData record{};
|
||||
// NOT a verbatim level shadow: these bytes are the application's staging
|
||||
// store, or the pattern FillSubData expanded locally, and neither is this
|
||||
@@ -1049,10 +1064,10 @@ namespace MobileGL::MG_Pipe {
|
||||
// PipeStats.h's CallClass::ResidentSubDataEmissions for why the count is the
|
||||
// only thing that can tell this arm from the in-place memcpy beside it.
|
||||
if (MG_Util::PipeStats::Enabled()) {
|
||||
MG_Util::PipeStats::AddCalls(
|
||||
MG_Util::PipeStats::CallClass::ResidentSubDataEmissions, 1);
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::ResidentSubDataEmissions, 1);
|
||||
}
|
||||
}, MGPipeContentChunkCap());
|
||||
},
|
||||
MGPipeContentChunkCap());
|
||||
if (!encodable) {
|
||||
MGLOG_E_ONCE("MGPipe: buffer_subdata_resident range [%llu, +%llu) on buffer %u cannot be encoded",
|
||||
static_cast<unsigned long long>(offset), static_cast<unsigned long long>(size),
|
||||
@@ -1078,8 +1093,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// Only that range: staging bytes outside it would write stale shadow bytes over server
|
||||
// data the flush does not cover, such as GPU writes. The apply thread takes the plain
|
||||
// route, as in MGPipeEmitResourceRespecify.
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith &&
|
||||
!MG_Remote::Client::RunsAsTheServerRole() && size != 0) {
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith && !MG_Remote::Client::RunsAsTheServerRole() &&
|
||||
size != 0) {
|
||||
MGPipeEmitResourceSubData(buffer, offset, size);
|
||||
}
|
||||
#endif
|
||||
@@ -1217,7 +1232,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// fill only for UNBARRIERED records); an unbarriered apply may not read it at all, and
|
||||
// §3.3's detector is what says so by name. Clearing the stamps as well would trade that
|
||||
// named abort for the poison Fatal, which names the field but not the rule it broke.
|
||||
void MGPipeReleaseResidualFillPins() { MGPipeFillAccess::ReleaseObjectPins(MGPipeClientInputs()); }
|
||||
void MGPipeReleaseResidualFillPins() {
|
||||
MGPipeFillAccess::ReleaseObjectPins(MGPipeClientInputs());
|
||||
}
|
||||
|
||||
// P5e (ra), CONTRACT-P5E §2.5. Declared in PipeMutation.h; see there for why it is not a
|
||||
// ClientSession call at the GL entry point.
|
||||
@@ -1279,8 +1296,7 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
Bool MGPipeEmitVertexElementsDestroyAndFree(Uint64 lifetimeId) {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
if (MGPipeDeferDestroyAndFreeIfOnApplyThread(MGPipeKind::VertexElementsCso,
|
||||
lifetimeId)) {
|
||||
if (MGPipeDeferDestroyAndFreeIfOnApplyThread(MGPipeKind::VertexElementsCso, lifetimeId)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -1296,8 +1312,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// May be the null handle: no slot is minted for a VAO that no draw ever validated with
|
||||
// and no backend twin table ever looked up. That case still raises the notice below -
|
||||
// see there.
|
||||
const MGPipeHandle handle =
|
||||
MGPipeSlots().FindByLifetimeId(MGPipeKind::VertexElementsCso, lifetimeId);
|
||||
const MGPipeHandle handle = MGPipeSlots().FindByLifetimeId(MGPipeKind::VertexElementsCso, lifetimeId);
|
||||
|
||||
// ASKED, NOT ASSUMED. A slot is not evidence of a record: DirectGLES mints one from
|
||||
// BackendSlotTable::GetOrCreate at every VAO sync, whether or not bit 8 asked this
|
||||
@@ -1355,9 +1370,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// once instead of four times. It is deliberately NOT kMGPipeSubsystemsMigratedAtP4a
|
||||
// (which is 0x1fff, every bit through P4a): the rule belongs to the families this
|
||||
// phase adds and to no earlier one.
|
||||
inline constexpr Uint64 kMGPipeP4aFamilySubsystems =
|
||||
kMGPipeSubsystemFramebuffer | kMGPipeSubsystemTextureResources |
|
||||
kMGPipeSubsystemSamplers | kMGPipeSubsystemPrograms;
|
||||
inline constexpr Uint64 kMGPipeP4aFamilySubsystems = kMGPipeSubsystemFramebuffer |
|
||||
kMGPipeSubsystemTextureResources |
|
||||
kMGPipeSubsystemSamplers | kMGPipeSubsystemPrograms;
|
||||
|
||||
// A handle family (framebuffer, texture resources, samplers, programs) emits only when
|
||||
// something consumes its records; otherwise it emits nothing and the legacy path runs. An
|
||||
@@ -1380,8 +1395,7 @@ namespace MobileGL::MG_Pipe {
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
// P5f fm: texture/framebuffer records have their own server consumers;
|
||||
// Magma consumes them without claiming the still-unmigrated buffer family.
|
||||
return MG_Remote::Client::CapsMirrorInstance().ServerConsumes(
|
||||
subsystem & kMGPipeP4aFamilySubsystems);
|
||||
return MG_Remote::Client::CapsMirrorInstance().ServerConsumes(subsystem & kMGPipeP4aFamilySubsystems);
|
||||
}
|
||||
#endif
|
||||
return MGPipeGetResourceOps() != nullptr;
|
||||
@@ -1401,36 +1415,31 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
constexpr Uint64 P4aFamilyDependencyTableCoverage() {
|
||||
Uint64 covered = 0;
|
||||
for (const MGPipeSubsystemDependencyRow& row : kMGPipeSubsystemDependencies) covered |= row.Family;
|
||||
for (const MGPipeSubsystemDependencyRow& row : kMGPipeSubsystemDependencies)
|
||||
covered |= row.Family;
|
||||
return covered;
|
||||
}
|
||||
static_assert((P4aFamilyDependencyTableCoverage() & kMGPipeP4aFamilySubsystems) ==
|
||||
kMGPipeP4aFamilySubsystems,
|
||||
static_assert((P4aFamilyDependencyTableCoverage() & kMGPipeP4aFamilySubsystems) == kMGPipeP4aFamilySubsystems,
|
||||
"every P4a family needs a D-K2 dependency row in MG_Pipe/SubsystemDeps.def, "
|
||||
"even an empty one");
|
||||
static_assert(P4aFamilyDependencyBits(kMGPipeSubsystemFramebuffer) ==
|
||||
kMGPipeSubsystemTextureResources,
|
||||
static_assert(P4aFamilyDependencyBits(kMGPipeSubsystemFramebuffer) == kMGPipeSubsystemTextureResources,
|
||||
"bit 9 requires bit 10");
|
||||
static_assert(P4aFamilyDependencyBits(kMGPipeSubsystemTextureResources) ==
|
||||
(kMGPipeSubsystemResources | kMGPipeSubsystemSamplers),
|
||||
"bit 10 requires bit 7 and bit 11");
|
||||
static_assert(P4aFamilyDependencyBits(kMGPipeSubsystemSamplers) ==
|
||||
kMGPipeSubsystemTextureResources,
|
||||
static_assert(P4aFamilyDependencyBits(kMGPipeSubsystemSamplers) == kMGPipeSubsystemTextureResources,
|
||||
"bit 11 requires bit 10");
|
||||
static_assert(P4aFamilyDependencyBits(kMGPipeSubsystemPrograms) == 0, "bit 12 depends on nothing");
|
||||
// No family may depend on itself: a row that did would be unfalsifiable (its own bit is
|
||||
// set by the time the conjunct is evaluated) and would read as a dependency nobody has.
|
||||
static_assert((P4aFamilyDependencyBits(kMGPipeSubsystemFramebuffer) &
|
||||
kMGPipeSubsystemFramebuffer) == 0 &&
|
||||
static_assert((P4aFamilyDependencyBits(kMGPipeSubsystemFramebuffer) & kMGPipeSubsystemFramebuffer) == 0 &&
|
||||
(P4aFamilyDependencyBits(kMGPipeSubsystemTextureResources) &
|
||||
kMGPipeSubsystemTextureResources) == 0 &&
|
||||
(P4aFamilyDependencyBits(kMGPipeSubsystemSamplers) &
|
||||
kMGPipeSubsystemSamplers) == 0,
|
||||
(P4aFamilyDependencyBits(kMGPipeSubsystemSamplers) & kMGPipeSubsystemSamplers) == 0,
|
||||
"a D-K2 row must not name its own family");
|
||||
// The default mask carries every dependency, so the shipped arm is unchanged by all of
|
||||
// this - the table only ever narrows a HAND-PICKED A/B mask.
|
||||
static_assert((kMGPipeSubsystemsMigratedAtP4a &
|
||||
P4aFamilyDependencyBits(kMGPipeP4aFamilySubsystems)) ==
|
||||
static_assert((kMGPipeSubsystemsMigratedAtP4a & P4aFamilyDependencyBits(kMGPipeP4aFamilySubsystems)) ==
|
||||
P4aFamilyDependencyBits(kMGPipeP4aFamilySubsystems),
|
||||
"the P4a phase mask must satisfy every dependency it declares");
|
||||
|
||||
@@ -1457,8 +1466,7 @@ namespace MobileGL::MG_Pipe {
|
||||
if (!MGPipeSubsystemDependenciesAreSet(kMGPipeSubsystemBufferBindings, pushMask)) return false;
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
return MG_Remote::Client::CapsMirrorInstance().ServerConsumes(
|
||||
kMGPipeSubsystemBufferBindings);
|
||||
return MG_Remote::Client::CapsMirrorInstance().ServerConsumes(kMGPipeSubsystemBufferBindings);
|
||||
}
|
||||
#endif
|
||||
// Under monolith the "consumer" is the backend that registered the resource op
|
||||
@@ -1469,10 +1477,8 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
Bool FamilyIsLive(Uint64 subsystem, Uint64 wired) {
|
||||
const Uint64 pushMask = MG_Config::Features.PipePush;
|
||||
return (pushMask & subsystem) != 0 && (wired & subsystem) != 0 &&
|
||||
P4aFamilyHasItsConsumer(subsystem) &&
|
||||
P4aFamilyDependenciesAreSet(subsystem, pushMask) &&
|
||||
P5eFamilyIsLive(subsystem, pushMask);
|
||||
return (pushMask & subsystem) != 0 && (wired & subsystem) != 0 && P4aFamilyHasItsConsumer(subsystem) &&
|
||||
P4aFamilyDependenciesAreSet(subsystem, pushMask) && P5eFamilyIsLive(subsystem, pushMask);
|
||||
}
|
||||
|
||||
// ---- The family seam: a birth hook forwards to its family's emitter ----
|
||||
@@ -1543,7 +1549,8 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
// A fresh server holds no record at all (MGPipeForgetEndedSession).
|
||||
void ForgetAll() {
|
||||
for (Vector<Entry>& table : m_kinds) table.clear();
|
||||
for (Vector<Entry>& table : m_kinds)
|
||||
table.clear();
|
||||
m_band.clear();
|
||||
}
|
||||
|
||||
@@ -1641,22 +1648,22 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
void MGPipeEmitTextureResourceCreate(ITextureObject& texture) {
|
||||
if (!FamilyIsLive(kMGPipeSubsystemTextureResources, kMGPipeWiredTextureSubsystem)) return;
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(
|
||||
MGPipeTextureEmitterInstance(), [&](auto& emitter) { emitter.EmitResourceCreate(texture); });
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(MGPipeTextureEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.EmitResourceCreate(texture); });
|
||||
}
|
||||
|
||||
void MGPipeEmitTextureResourceRespecify(ITextureObject& texture, MGPipeTextureRespecifyScope scope,
|
||||
Uint32 uploadTarget, Uint32 level) {
|
||||
if (!FamilyIsLive(kMGPipeSubsystemTextureResources, kMGPipeWiredTextureSubsystem)) return;
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(
|
||||
MGPipeTextureEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.EmitResourceRespecify(texture, scope, uploadTarget, level); });
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(MGPipeTextureEmitterInstance(), [&](auto& emitter) {
|
||||
emitter.EmitResourceRespecify(texture, scope, uploadTarget, level);
|
||||
});
|
||||
}
|
||||
|
||||
void MGPipeEmitTextureParams(ITextureObject& texture) {
|
||||
if (!FamilyIsLive(kMGPipeSubsystemTextureResources, kMGPipeWiredTextureSubsystem)) return;
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(
|
||||
MGPipeTextureEmitterInstance(), [&](auto& emitter) { emitter.EmitTextureParams(texture); });
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(MGPipeTextureEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.EmitTextureParams(texture); });
|
||||
}
|
||||
|
||||
void MGPipeNoteTextureLevelDirty(ITextureObject& storageOwner, Uint32 uploadTarget, Uint32 level) {
|
||||
@@ -1668,31 +1675,29 @@ namespace MobileGL::MG_Pipe {
|
||||
// the texture. The level stays dirty on the object, which no live context can reach.
|
||||
if (MG_Remote::Client::ClientSession::DeviceLost()) return;
|
||||
#endif
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(
|
||||
MGPipeTextureEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.NoteLevelDirty(storageOwner, uploadTarget, level); });
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(MGPipeTextureEmitterInstance(), [&](auto& emitter) {
|
||||
emitter.NoteLevelDirty(storageOwner, uploadTarget, level);
|
||||
});
|
||||
}
|
||||
|
||||
void MGPipeEmitRenderbufferResourceCreate(RenderbufferObject& renderbuffer) {
|
||||
if (!FamilyIsLive(kMGPipeSubsystemTextureResources, kMGPipeWiredTextureSubsystem)) return;
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(
|
||||
MGPipeTextureEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.EmitRenderbufferCreate(renderbuffer); });
|
||||
MGPipeTextureEmitterInstance(), [&](auto& emitter) { emitter.EmitRenderbufferCreate(renderbuffer); });
|
||||
}
|
||||
|
||||
void MGPipeEmitRenderbufferResourceRespecify(RenderbufferObject& renderbuffer) {
|
||||
if (!FamilyIsLive(kMGPipeSubsystemTextureResources, kMGPipeWiredTextureSubsystem)) return;
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(
|
||||
MGPipeTextureEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.EmitRenderbufferRespecify(renderbuffer); });
|
||||
MGPipeTextureEmitterInstance(), [&](auto& emitter) { emitter.EmitRenderbufferRespecify(renderbuffer); });
|
||||
}
|
||||
|
||||
void MGPipeNoteTextureBoundAs(MGPipeHandle texture, Uint32 bindBit) {
|
||||
// Not gated on FamilyIsLive: the mask is client state (see the declaration), and the
|
||||
// emitter gates the emission it causes.
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(
|
||||
MGPipeTextureEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.NoteTextureBoundAs(texture, static_cast<Uint16>(bindBit)); });
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(MGPipeTextureEmitterInstance(), [&](auto& emitter) {
|
||||
emitter.NoteTextureBoundAs(texture, static_cast<Uint16>(bindBit));
|
||||
});
|
||||
}
|
||||
|
||||
void MGPipeNoteTextureImageBound(ITextureObject& texture) {
|
||||
@@ -1704,20 +1709,20 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
void MGPipeEmitSamplerCsoCreate(SamplerObject& sampler) {
|
||||
if (!FamilyIsLive(kMGPipeSubsystemSamplers, kMGPipeWiredSamplerSubsystem)) return;
|
||||
ForwardWhenWired<kMGPipeWiredSamplerSubsystem>(
|
||||
MGPipeSamplerEmitterInstance(), [&](auto& emitter) { emitter.EmitSamplerCso(sampler); });
|
||||
ForwardWhenWired<kMGPipeWiredSamplerSubsystem>(MGPipeSamplerEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.EmitSamplerCso(sampler); });
|
||||
}
|
||||
|
||||
void MGPipeEmitSamplerViewCreate(ITextureObject& texture) {
|
||||
if (!FamilyIsLive(kMGPipeSubsystemSamplers, kMGPipeWiredSamplerSubsystem)) return;
|
||||
ForwardWhenWired<kMGPipeWiredSamplerSubsystem>(
|
||||
MGPipeSamplerEmitterInstance(), [&](auto& emitter) { emitter.EmitSamplerView(texture); });
|
||||
ForwardWhenWired<kMGPipeWiredSamplerSubsystem>(MGPipeSamplerEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.EmitSamplerView(texture); });
|
||||
}
|
||||
|
||||
void MGPipeEmitShaderCsoCreate(ProgramObject& program) {
|
||||
if (!FamilyIsLive(kMGPipeSubsystemPrograms, kMGPipeWiredProgramSubsystem)) return;
|
||||
ForwardWhenWired<kMGPipeWiredProgramSubsystem>(
|
||||
MGPipeProgramEmitterInstance(), [&](auto& emitter) { emitter.EmitShaderCso(program); });
|
||||
ForwardWhenWired<kMGPipeWiredProgramSubsystem>(MGPipeProgramEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.EmitShaderCso(program); });
|
||||
}
|
||||
|
||||
// ---- Client-side death helpers, one per handle kind minted above ----
|
||||
@@ -1759,8 +1764,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// The parameter type is the route's, which is byte-identical to the applier's
|
||||
// (const MGPHandleOnly&, void return), so the fix is `&MGPipeRoute<Name>` at the five call
|
||||
// sites; PipeCatalogue.FrontendNeverTakesAnApplierAddress checks MG_Impl in every unit lane.
|
||||
Bool EmitDeleteIfPublished(MGPipeKind kind, MGPipeHandle handle,
|
||||
void (*route)(const MGPHandleOnly&)) {
|
||||
Bool EmitDeleteIfPublished(MGPipeKind kind, MGPipeHandle handle, void (*route)(const MGPHandleOnly&)) {
|
||||
if (!MGPipeHandleIsPublished(kind, handle)) return false;
|
||||
route(HandleOnly(kind, handle));
|
||||
MGPipeNoteHandleUnpublished(kind, handle);
|
||||
@@ -1785,12 +1789,10 @@ namespace MobileGL::MG_Pipe {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
const MGPipeHandle handle =
|
||||
MGPipeSlots().FindByLifetimeId(MGPipeKind::SamplerViewCso, lifetimeId);
|
||||
const Bool published =
|
||||
EmitDeleteIfPublished(MGPipeKind::SamplerViewCso, handle, &MGPipeRouteDeleteSamplerView);
|
||||
ForwardWhenWired<kMGPipeWiredSamplerSubsystem>(
|
||||
MGPipeSamplerEmitterInstance(), [&](auto& emitter) { emitter.NoteRecordDestroyed(handle); });
|
||||
const MGPipeHandle handle = MGPipeSlots().FindByLifetimeId(MGPipeKind::SamplerViewCso, lifetimeId);
|
||||
const Bool published = EmitDeleteIfPublished(MGPipeKind::SamplerViewCso, handle, &MGPipeRouteDeleteSamplerView);
|
||||
ForwardWhenWired<kMGPipeWiredSamplerSubsystem>(MGPipeSamplerEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.NoteRecordDestroyed(handle); });
|
||||
// THE NOTICE IS RAISED FOR THIS KIND TOO, and the reason it once was not is wrong:
|
||||
// NotifyStateObjectDestroyed takes a KIND and a lifetime id, not an object
|
||||
// (StateObjectDeathNotice.h - one entry point for every kind rather than one ops table
|
||||
@@ -1813,13 +1815,12 @@ namespace MobileGL::MG_Pipe {
|
||||
}
|
||||
#endif
|
||||
const MGPipeHandle handle = MGPipeSlots().FindByLifetimeId(MGPipeKind::Texture, lifetimeId);
|
||||
const Bool published =
|
||||
EmitDeleteIfPublished(MGPipeKind::Texture, handle, &MGPipeRouteResourceDestroy);
|
||||
const Bool published = EmitDeleteIfPublished(MGPipeKind::Texture, handle, &MGPipeRouteResourceDestroy);
|
||||
// The emitter retires its entry while the handle still resolves (C-2): the drain list
|
||||
// drops the dead texture's levels, the raw pointer goes, the built-in sampler's cache
|
||||
// reference is given back, the latches and the sticky mask are cleared.
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(
|
||||
MGPipeTextureEmitterInstance(), [&](auto& emitter) { emitter.NoteTextureDied(handle); });
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(MGPipeTextureEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.NoteTextureDied(handle); });
|
||||
NotifyAndFree(MGPipeKind::Texture, lifetimeId, handle);
|
||||
// The texture's SamplerViewCso shares its lifetime id and is released here, after the
|
||||
// texture's own record, so a server reading the view while the texture is dropped still
|
||||
@@ -1838,12 +1839,10 @@ namespace MobileGL::MG_Pipe {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
const MGPipeHandle handle =
|
||||
MGPipeSlots().FindByLifetimeId(MGPipeKind::Renderbuffer, lifetimeId);
|
||||
const Bool published =
|
||||
EmitDeleteIfPublished(MGPipeKind::Renderbuffer, handle, &MGPipeRouteResourceDestroy);
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(
|
||||
MGPipeTextureEmitterInstance(), [&](auto& emitter) { emitter.NoteRenderbufferDied(handle); });
|
||||
const MGPipeHandle handle = MGPipeSlots().FindByLifetimeId(MGPipeKind::Renderbuffer, lifetimeId);
|
||||
const Bool published = EmitDeleteIfPublished(MGPipeKind::Renderbuffer, handle, &MGPipeRouteResourceDestroy);
|
||||
ForwardWhenWired<kMGPipeWiredTextureSubsystem>(MGPipeTextureEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.NoteRenderbufferDied(handle); });
|
||||
NotifyAndFree(MGPipeKind::Renderbuffer, lifetimeId, handle);
|
||||
return published;
|
||||
}
|
||||
@@ -1861,10 +1860,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// MarkFramebufferObjectForDeletion rebinds slots holding it to framebuffer 0, and a
|
||||
// recycled handle cannot match its predecessor's record because Gen is in its ContentHash.
|
||||
// Nothing latches a framebuffer publication, so the answer is always false.
|
||||
const MGPipeHandle handle =
|
||||
MGPipeSlots().FindByLifetimeId(MGPipeKind::Framebuffer, lifetimeId);
|
||||
ForwardWhenWired<kMGPipeWiredFramebufferSubsystem>(
|
||||
MGPipeFramebufferEmitterInstance(), [&](auto& emitter) { emitter.NoteFramebufferDied(handle); });
|
||||
const MGPipeHandle handle = MGPipeSlots().FindByLifetimeId(MGPipeKind::Framebuffer, lifetimeId);
|
||||
ForwardWhenWired<kMGPipeWiredFramebufferSubsystem>(MGPipeFramebufferEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.NoteFramebufferDied(handle); });
|
||||
NotifyAndFree(MGPipeKind::Framebuffer, lifetimeId, handle);
|
||||
return false;
|
||||
}
|
||||
@@ -1875,10 +1873,8 @@ namespace MobileGL::MG_Pipe {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
const MGPipeHandle handle =
|
||||
MGPipeSlots().FindByLifetimeId(MGPipeKind::SamplerCso, lifetimeId);
|
||||
const Bool published =
|
||||
EmitDeleteIfPublished(MGPipeKind::SamplerCso, handle, &MGPipeRouteDeleteSamplerState);
|
||||
const MGPipeHandle handle = MGPipeSlots().FindByLifetimeId(MGPipeKind::SamplerCso, lifetimeId);
|
||||
const Bool published = EmitDeleteIfPublished(MGPipeKind::SamplerCso, handle, &MGPipeRouteDeleteSamplerState);
|
||||
// NOTHING TO RETIRE IN AN EMITTER FOR THIS KIND, stated rather than implied: a sampler
|
||||
// CSO is content-addressed and belongs to a value, so no emitter keeps an entry under
|
||||
// a SamplerObject's handle - the cache's entries are keyed by value and reference
|
||||
@@ -1901,12 +1897,10 @@ namespace MobileGL::MG_Pipe {
|
||||
// destructor - and the second is a proven no-op, because MGPipeSlotAllocator::Free
|
||||
// refuses a slot that is not live at that generation and bumps no generation of its
|
||||
// own (the bump rides the next handout).
|
||||
const MGPipeHandle handle =
|
||||
MGPipeSlots().FindByLifetimeId(MGPipeKind::ShaderCso, lifetimeId);
|
||||
const Bool published =
|
||||
EmitDeleteIfPublished(MGPipeKind::ShaderCso, handle, &MGPipeRouteDeleteShaderState);
|
||||
ForwardWhenWired<kMGPipeWiredProgramSubsystem>(
|
||||
MGPipeProgramEmitterInstance(), [&](auto& emitter) { emitter.NoteRecordDestroyed(handle); });
|
||||
const MGPipeHandle handle = MGPipeSlots().FindByLifetimeId(MGPipeKind::ShaderCso, lifetimeId);
|
||||
const Bool published = EmitDeleteIfPublished(MGPipeKind::ShaderCso, handle, &MGPipeRouteDeleteShaderState);
|
||||
ForwardWhenWired<kMGPipeWiredProgramSubsystem>(MGPipeProgramEmitterInstance(),
|
||||
[&](auto& emitter) { emitter.NoteRecordDestroyed(handle); });
|
||||
NotifyAndFree(MGPipeKind::ShaderCso, lifetimeId, handle);
|
||||
return published;
|
||||
}
|
||||
@@ -1934,8 +1928,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// ---- liveness ----
|
||||
Bool PipeInputs::IsLive() const {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith)
|
||||
return MGPipeServerContextIsLive();
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) return MGPipeServerContextIsLive();
|
||||
#endif
|
||||
return LiveContext() != nullptr;
|
||||
}
|
||||
@@ -1966,7 +1959,8 @@ namespace MobileGL::MG_Pipe {
|
||||
case BufferTarget::AtomicCounter:
|
||||
case BufferTarget::TransformFeedback:
|
||||
return kMGPipeMaxBufferBindingPoints;
|
||||
default: return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2000,7 +1994,7 @@ namespace MobileGL::MG_Pipe {
|
||||
});
|
||||
return true;
|
||||
}();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void PipeInputs::InvalidateCompileEnv() {
|
||||
MGP_STICKY_FORWARD_PULL(InvalidateCompileEnv);
|
||||
@@ -2065,7 +2059,9 @@ namespace MobileGL::MG_Pipe {
|
||||
MGPipeTrackerInstance().SetPendingBaseInstance(baseInstance);
|
||||
}
|
||||
|
||||
Uint32 MGPipePendingBaseInstance() { return MGPipeTrackerInstance().PendingBaseInstance(); }
|
||||
Uint32 MGPipePendingBaseInstance() {
|
||||
return MGPipeTrackerInstance().PendingBaseInstance();
|
||||
}
|
||||
|
||||
void MGPipeLeaveVerb() {
|
||||
PipeInputs& inputs = MGPipeClientInputs();
|
||||
@@ -2077,8 +2073,8 @@ namespace MobileGL::MG_Pipe {
|
||||
if (g_lastFillWasBarriered) {
|
||||
// Same layer-2 gate as the fill: the serial bump and the verb reset below are
|
||||
// writes into gPipeInputs (gt).
|
||||
MG_Remote::Client::ClientSession::RefusePipeInputsTouchWhileApplierOwnsIt(
|
||||
"MGPipeLeaveVerb", /*isBarrieredFill=*/true);
|
||||
MG_Remote::Client::ClientSession::RefusePipeInputsTouchWhileApplierOwnsIt("MGPipeLeaveVerb",
|
||||
/*isBarrieredFill=*/true);
|
||||
}
|
||||
if (!g_lastFillWasBarriered) {
|
||||
MGPipeTrackerInstance().ClearPendingBaseInstance();
|
||||
@@ -2105,7 +2101,6 @@ namespace MobileGL::MG_Pipe {
|
||||
MGPipeTrackerInstance().ClearPendingBaseInstance();
|
||||
}
|
||||
|
||||
|
||||
// ================================================================================
|
||||
// The emission step (P2 brief D1 step 3, D5, D6, D7)
|
||||
// ================================================================================
|
||||
@@ -2192,8 +2187,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// rather than kMGPipeSubsystemVertexInput to pin the two maps to each other: an emitter
|
||||
// row moved to another subsystem must fail too. bind_vertex_elements is the family's only
|
||||
// Coverage.def emitter row, so it is the emitter side of all three.
|
||||
static_assert(SubsystemForEmitter(MGPipeFieldEmitter::BindVertexElements) ==
|
||||
kMGPipeSubsystemVertexInput,
|
||||
static_assert(SubsystemForEmitter(MGPipeFieldEmitter::BindVertexElements) == kMGPipeSubsystemVertexInput,
|
||||
"bind_vertex_elements must name the vertex-input subsystem");
|
||||
static_assert(MGPipeSubsystemForDirty(MGPipeDirty::NewVertexElements) ==
|
||||
SubsystemForEmitter(MGPipeFieldEmitter::BindVertexElements),
|
||||
@@ -2207,8 +2201,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// The two vertex views' capacity is one number on both sides of the boundary. This is
|
||||
// the one translation unit that sees the frontend constant and the MG_Pipe one, so it
|
||||
// is where they are pinned together; MGPipeTypes.h says so in place.
|
||||
static_assert(kMGPipeMaxVertexAttribs ==
|
||||
MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS,
|
||||
static_assert(kMGPipeMaxVertexAttribs == MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS,
|
||||
"the MGPipe vertex-attribute capacity and the frontend's have drifted");
|
||||
|
||||
// P5e (docs/archive/contracts/CONTRACT-P5E.md §1, ruling 10), pinned here for the same reason and in
|
||||
@@ -2216,8 +2209,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// and nothing else does. 84 is what the emitter may describe and what the wire carries;
|
||||
// the BACKEND clamps to the device's real GL_MAX_UNIFORM_BUFFER_BINDINGS, as it does
|
||||
// today, because a client-side clamp would read a device capability from the wrong side.
|
||||
static_assert(kMGPipeMaxBufferBindingPoints ==
|
||||
MG_State::GLState::BufferBindingPointCount,
|
||||
static_assert(kMGPipeMaxBufferBindingPoints == MG_State::GLState::BufferBindingPointCount,
|
||||
"the MGPipe buffer-binding-point capacity and the frontend's have drifted");
|
||||
|
||||
// ---- P4a's SEVEN pairings, and EVERY ONE OF THEM COMPARES AGAINST
|
||||
@@ -2281,8 +2273,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// one of them was edited. Exactly the shape NoDirtyBitOwnsTheResidualSubsystem uses.
|
||||
constexpr Bool NoDirtyBitOwnsTheTextureResourceSubsystem() {
|
||||
for (SizeT i = 0; i < kMGPipeDirtyCount; ++i) {
|
||||
if (MGPipeSubsystemForDirty(static_cast<MGPipeDirty>(i)) ==
|
||||
kMGPipeSubsystemTextureResources) {
|
||||
if (MGPipeSubsystemForDirty(static_cast<MGPipeDirty>(i)) == kMGPipeSubsystemTextureResources) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2311,24 +2302,18 @@ namespace MobileGL::MG_Pipe {
|
||||
// own emit header; the sampler one covers SamplerEmit.h and ImageEmit.h. The residual
|
||||
// subsystem is here for set_context_values, which has no dirty bit, so the residual-fill
|
||||
// skip reads this mask for its eight fields.
|
||||
constexpr Uint64 kMGPipeWiredSubsystems = kMGPipeSubsystemRenderState |
|
||||
kMGPipeSubsystemPixelPack |
|
||||
kMGPipeSubsystemPatchState |
|
||||
kMGPipeSubsystemVertexAttribDefaults |
|
||||
kMGPipeSubsystemResidualValues |
|
||||
kMGPipeSubsystemResources |
|
||||
kMGPipeSubsystemVertexInput |
|
||||
kMGPipeWiredFramebufferSubsystem |
|
||||
kMGPipeWiredTextureSubsystem |
|
||||
kMGPipeWiredSamplerSubsystem |
|
||||
kMGPipeWiredProgramSubsystem |
|
||||
// P5e (sb): the indexed buffer binding
|
||||
// points, by the same rule and from the same
|
||||
// kind of header. ID-106 pins the other half
|
||||
// of the switch: MG_Backend/Init.cpp's
|
||||
// consumer mask gains bit 13 in the same
|
||||
// commit, or R-8 withholds the whole family.
|
||||
kMGPipeWiredBufferBindingSubsystem;
|
||||
constexpr Uint64 kMGPipeWiredSubsystems =
|
||||
kMGPipeSubsystemRenderState | kMGPipeSubsystemPixelPack | kMGPipeSubsystemPatchState |
|
||||
kMGPipeSubsystemVertexAttribDefaults | kMGPipeSubsystemResidualValues | kMGPipeSubsystemResources |
|
||||
kMGPipeSubsystemVertexInput | kMGPipeWiredFramebufferSubsystem | kMGPipeWiredTextureSubsystem |
|
||||
kMGPipeWiredSamplerSubsystem | kMGPipeWiredProgramSubsystem |
|
||||
// P5e (sb): the indexed buffer binding
|
||||
// points, by the same rule and from the same
|
||||
// kind of header. ID-106 pins the other half
|
||||
// of the switch: MG_Backend/Init.cpp's
|
||||
// consumer mask gains bit 13 in the same
|
||||
// commit, or R-8 withholds the whole family.
|
||||
kMGPipeWiredBufferBindingSubsystem;
|
||||
|
||||
// P15: the dirty bits whose family this build, push mask and consumer emit - every
|
||||
// condition of the per-bit gate in MGPipeValidateForVerb except the dirty bit itself.
|
||||
@@ -2376,11 +2361,9 @@ namespace MobileGL::MG_Pipe {
|
||||
static_assert(kMGPipeWiredTextureSubsystem == 0 ||
|
||||
kMGPipeWiredTextureSubsystem == kMGPipeSubsystemTextureResources,
|
||||
"TextureEmit.h's wired constant must be 0 or the texture-resource bit");
|
||||
static_assert(kMGPipeWiredSamplerSubsystem == 0 ||
|
||||
kMGPipeWiredSamplerSubsystem == kMGPipeSubsystemSamplers,
|
||||
static_assert(kMGPipeWiredSamplerSubsystem == 0 || kMGPipeWiredSamplerSubsystem == kMGPipeSubsystemSamplers,
|
||||
"SamplerEmit.h's wired constant must be 0 or the sampler bit");
|
||||
static_assert(kMGPipeWiredProgramSubsystem == 0 ||
|
||||
kMGPipeWiredProgramSubsystem == kMGPipeSubsystemPrograms,
|
||||
static_assert(kMGPipeWiredProgramSubsystem == 0 || kMGPipeWiredProgramSubsystem == kMGPipeSubsystemPrograms,
|
||||
"ProgramEmit.h's wired constant must be 0 or the program bit");
|
||||
static_assert(kMGPipeWiredBufferBindingSubsystem == 0 ||
|
||||
kMGPipeWiredBufferBindingSubsystem == kMGPipeSubsystemBufferBindings,
|
||||
@@ -2487,8 +2470,7 @@ namespace MobileGL::MG_Pipe {
|
||||
for (SizeT i = 0; i < kMGPipeInputFieldCount; ++i) {
|
||||
const auto field = static_cast<MGPipeInputField>(i);
|
||||
const Uint64 subsystem = SubsystemForEmitter(kMGPipeFieldEmittedBy[i]);
|
||||
if ((subsystem & kMGPipeP4aFamilySubsystems) != 0 &&
|
||||
EmittedCallSuppliesTheWholeField(field)) {
|
||||
if ((subsystem & kMGPipeP4aFamilySubsystems) != 0 && EmittedCallSuppliesTheWholeField(field)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2557,8 +2539,7 @@ namespace MobileGL::MG_Pipe {
|
||||
};
|
||||
ResidualFillPlan g_fillPlan;
|
||||
|
||||
MGPipeFieldMask SuppliedFieldMask(Uint64 pushMask, Bool applierDerives,
|
||||
Bool contextValuesWireLive) {
|
||||
MGPipeFieldMask SuppliedFieldMask(Uint64 pushMask, Bool applierDerives, Bool contextValuesWireLive) {
|
||||
// THE CONSUMER SIGNAL IS READ ONLY WHERE THE WALK BELOW COULD REACH IT, and that
|
||||
// guard is not a micro-optimisation - it is what keeps R-8's DIAGNOSTIC COUNTERS
|
||||
// where they were (P5d r3 package C review, minor 2). In the conjunction below
|
||||
@@ -2570,17 +2551,16 @@ namespace MobileGL::MG_Pipe {
|
||||
// where the baseline never touched the mirror, which is the opposite direction from
|
||||
// the one this change is supposed to move them in. The key stays COMPLETE because
|
||||
// pushMask is itself in the key: a mask that gains a P4a bit re-keys on the mask.
|
||||
const Bool p4aConsumer = (pushMask & kMGPipeP4aFamilySubsystems) != 0 &&
|
||||
P4aFamilyHasItsConsumer(kMGPipeP4aFamilySubsystems);
|
||||
if (g_fillPlan.Valid && g_fillPlan.PushMask == pushMask &&
|
||||
g_fillPlan.ApplierDerives == applierDerives &&
|
||||
g_fillPlan.ContextValuesWireLive == contextValuesWireLive &&
|
||||
g_fillPlan.P4aConsumer == p4aConsumer
|
||||
const Bool p4aConsumer =
|
||||
(pushMask & kMGPipeP4aFamilySubsystems) != 0 && P4aFamilyHasItsConsumer(kMGPipeP4aFamilySubsystems);
|
||||
if (g_fillPlan.Valid && g_fillPlan.PushMask == pushMask && g_fillPlan.ApplierDerives == applierDerives &&
|
||||
g_fillPlan.ContextValuesWireLive == contextValuesWireLive && g_fillPlan.P4aConsumer == p4aConsumer
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
&& g_fillPlan.CapsGeneration == (MG_Config::Transport != MG_Config::TransportMode::Monolith ?
|
||||
MG_Remote::Client::CapsMirrorInstance().Generation() : 0)
|
||||
&& g_fillPlan.CapsGeneration == (MG_Config::Transport != MG_Config::TransportMode::Monolith
|
||||
? MG_Remote::Client::CapsMirrorInstance().Generation()
|
||||
: 0)
|
||||
#endif
|
||||
) {
|
||||
) {
|
||||
return g_fillPlan.Supplied;
|
||||
}
|
||||
MGPipeFieldMask built{};
|
||||
@@ -2605,14 +2585,11 @@ namespace MobileGL::MG_Pipe {
|
||||
// NO PRODUCER without a live wire (its emission is transport-gated at the validate
|
||||
// point), so its eight fields keep being pulled under monolith - G1's byte-for-byte
|
||||
// rule - and are skipped only when the record really crosses.
|
||||
const Bool supplied = subsystem != 0 && (subsystem & kMGPipeWiredSubsystems) != 0 &&
|
||||
(pushMask & subsystem) != 0 &&
|
||||
P4aFamilyHasItsConsumer(subsystem) &&
|
||||
P4aFamilyDependenciesAreSet(subsystem, pushMask) &&
|
||||
EmittedCallSuppliesTheWholeField(field) &&
|
||||
(applierDerives || AppliedWithoutDerivation(field)) &&
|
||||
(emitter != MGPipeFieldEmitter::SetContextValues ||
|
||||
contextValuesWireLive);
|
||||
const Bool supplied =
|
||||
subsystem != 0 && (subsystem & kMGPipeWiredSubsystems) != 0 && (pushMask & subsystem) != 0 &&
|
||||
P4aFamilyHasItsConsumer(subsystem) && P4aFamilyDependenciesAreSet(subsystem, pushMask) &&
|
||||
EmittedCallSuppliesTheWholeField(field) && (applierDerives || AppliedWithoutDerivation(field)) &&
|
||||
(emitter != MGPipeFieldEmitter::SetContextValues || contextValuesWireLive);
|
||||
if (supplied) built.Words[i / 64] |= (Uint64{1} << (i % 64));
|
||||
}
|
||||
// PUBLISHED IN ONE ASSIGNMENT, after the walk - see the paragraph above the struct.
|
||||
@@ -2622,8 +2599,9 @@ namespace MobileGL::MG_Pipe {
|
||||
g_fillPlan.ContextValuesWireLive = contextValuesWireLive;
|
||||
g_fillPlan.P4aConsumer = p4aConsumer;
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
g_fillPlan.CapsGeneration = MG_Config::Transport != MG_Config::TransportMode::Monolith ?
|
||||
MG_Remote::Client::CapsMirrorInstance().Generation() : 0;
|
||||
g_fillPlan.CapsGeneration = MG_Config::Transport != MG_Config::TransportMode::Monolith
|
||||
? MG_Remote::Client::CapsMirrorInstance().Generation()
|
||||
: 0;
|
||||
#endif
|
||||
g_fillPlan.Supplied = built;
|
||||
for (SizeT c = 0; c < ResidualFillPlan::kClasses; ++c) {
|
||||
@@ -2666,8 +2644,10 @@ namespace MobileGL::MG_Pipe {
|
||||
const RenderStateParameters& live = ctx.GetRenderStateParameters();
|
||||
MGPPatchState patch{};
|
||||
patch.Vertices = live.PatchVertices;
|
||||
for (SizeT i = 0; i < 4; ++i) patch.Outer[i] = live.PatchDefaultOuterLevel[i];
|
||||
for (SizeT i = 0; i < 2; ++i) patch.Inner[i] = live.PatchDefaultInnerLevel[i];
|
||||
for (SizeT i = 0; i < 4; ++i)
|
||||
patch.Outer[i] = live.PatchDefaultOuterLevel[i];
|
||||
for (SizeT i = 0; i < 2; ++i)
|
||||
patch.Inner[i] = live.PatchDefaultInnerLevel[i];
|
||||
MGPipeRouteSetPatchState(patch);
|
||||
return sizeof(MGPPatchState);
|
||||
}
|
||||
@@ -2696,11 +2676,12 @@ namespace MobileGL::MG_Pipe {
|
||||
static_assert(kAttribs <= 32, "MGPVertexAttribDefaults::Mask is a Uint32");
|
||||
|
||||
Array<MG_State::GLState::CurrentVertexAttributeValue, kAttribs> resolved;
|
||||
for (SizeT i = 0; i < kAttribs; ++i) resolved[i] = ctx.GetCurrentVertexAttribute(static_cast<Uint>(i));
|
||||
for (SizeT i = 0; i < kAttribs; ++i)
|
||||
resolved[i] = ctx.GetCurrentVertexAttribute(static_cast<Uint>(i));
|
||||
|
||||
const Uint64 contentHash = XXH64(resolved.data(), sizeof(resolved), 0);
|
||||
if (!MGPipeSetHashSuppressorInstance().ShouldEmit(MGPipeSuppressorSlot::SetVertexAttribDefaults,
|
||||
contentHash)) {
|
||||
contentHash)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2729,8 +2710,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// it says nothing about which view holds the value the other two were
|
||||
// converted from.
|
||||
MGPipeFillAttribValue(static_cast<Uint32>(i), resolved[i],
|
||||
ctx.GetCurrentVertexAttributeClass(static_cast<Uint>(i)),
|
||||
tail[header.Count]);
|
||||
ctx.GetCurrentVertexAttributeClass(static_cast<Uint>(i)), tail[header.Count]);
|
||||
header.Mask |= Uint32{1} << static_cast<Uint32>(i);
|
||||
++header.Count;
|
||||
staged[i] = resolved[i];
|
||||
@@ -2799,10 +2779,9 @@ namespace MobileGL::MG_Pipe {
|
||||
values.MaxTouchedTextureUnit = static_cast<Uint32>(ctx.GetMaxTouchedTextureUnit());
|
||||
// The array is indexed by BufferTarget value, all 15 of them (MGPipeTypes.h);
|
||||
// targets with no binding points answer 0 (BufferState::GetTouchedBindPointCount).
|
||||
static_assert(
|
||||
std::extent_v<decltype(MGPContextValues::TouchedBufferBindingPointCount)> ==
|
||||
static_cast<SizeT>(BufferTarget::BufferTargetCount),
|
||||
"MGPContextValues' per-target array and BufferTargetCount have drifted");
|
||||
static_assert(std::extent_v<decltype(MGPContextValues::TouchedBufferBindingPointCount)> ==
|
||||
static_cast<SizeT>(BufferTarget::BufferTargetCount),
|
||||
"MGPContextValues' per-target array and BufferTargetCount have drifted");
|
||||
for (Uint32 t = 0; t < static_cast<Uint32>(BufferTarget::BufferTargetCount); ++t) {
|
||||
values.TouchedBufferBindingPointCount[t] =
|
||||
static_cast<Uint32>(ctx.GetTouchedBufferBindingPointCount(static_cast<BufferTarget>(t)));
|
||||
@@ -2847,8 +2826,6 @@ namespace MobileGL::MG_Pipe {
|
||||
MGPipeFieldMaskHas(mask, MGPipeInputField::GetTransformFeedbackCapturedVertices);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// The residual block is the ONE emission whose gate names a subsystem constant
|
||||
// directly instead of going through MGPipeSubsystemForDirty, and the reason is that
|
||||
// it has no dirty bit: it carries what has no shutter of its own, which is what makes
|
||||
@@ -2858,8 +2835,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// assumed, the same discipline SubsystemForEmitter's five static_asserts use.
|
||||
constexpr Bool NoDirtyBitOwnsTheResidualSubsystem() {
|
||||
for (SizeT i = 0; i < kMGPipeDirtyCount; ++i) {
|
||||
if (MGPipeSubsystemForDirty(static_cast<MGPipeDirty>(i)) ==
|
||||
kMGPipeSubsystemResidualValues) {
|
||||
if (MGPipeSubsystemForDirty(static_cast<MGPipeDirty>(i)) == kMGPipeSubsystemResidualValues) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2870,8 +2846,7 @@ namespace MobileGL::MG_Pipe {
|
||||
"residual block's gate through MGPipeSubsystemForDirty like every other "
|
||||
"emission, or the two gates will disagree");
|
||||
|
||||
constexpr Uint32 kAllDynamicChunks =
|
||||
static_cast<Uint32>((Uint64{1} << kMGPipeDynamicChunkCount) - 1);
|
||||
constexpr Uint32 kAllDynamicChunks = static_cast<Uint32>((Uint64{1} << kMGPipeDynamicChunkCount) - 1);
|
||||
|
||||
// create/bind_render_state and set_dynamic_state. Returns the bytes that went on the
|
||||
// wire, for the payload histogram.
|
||||
@@ -2901,8 +2876,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// glClearColor sends D2. An EMPTY mask still sends the 32-byte header,
|
||||
// because the VERSION is what Magma's dynamic tail gates on and it moved.
|
||||
const Uint32 chunkMask =
|
||||
freshlyPrimed ? kAllDynamicChunks
|
||||
: MGPipeDynamicChunksThatMoved(live, tracker.Staged());
|
||||
freshlyPrimed ? kAllDynamicChunks : MGPipeDynamicChunksThatMoved(live, tracker.Staged());
|
||||
Array<Uint8, kMGPipeDynamicChunkBytes> blob;
|
||||
const SizeT blobBytes = MGPipeDynamicChunkBlobBytes(chunkMask);
|
||||
MGPipeGatherDynamicChunks(live, chunkMask, blob.data());
|
||||
@@ -3017,8 +2991,12 @@ namespace MobileGL::MG_Pipe {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Uint64 MGPipeVertexAttribDefaultRepairCount() { return g_attribDefaultRepairs; }
|
||||
MGPVertexAttribDefaults MGPipeVertexAttribDefaultsLastHeader() { return g_attribDefaultLastHeader; }
|
||||
Uint64 MGPipeVertexAttribDefaultRepairCount() {
|
||||
return g_attribDefaultRepairs;
|
||||
}
|
||||
MGPVertexAttribDefaults MGPipeVertexAttribDefaultsLastHeader() {
|
||||
return g_attribDefaultLastHeader;
|
||||
}
|
||||
|
||||
// The unit gate's door onto step 4's predicate (PipeFill.h says why it needs one). It
|
||||
// returns the memo's answer rather than a second copy of the expression, so a case that
|
||||
@@ -3026,8 +3004,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// re-implementation of it.
|
||||
Bool MGPipeResidualFillSuppliesField(MGPipeInputField field, Uint64 pushMask, Bool applierDerives,
|
||||
Bool contextValuesWireLive) {
|
||||
return MGPipeFieldMaskHas(SuppliedFieldMask(pushMask, applierDerives, contextValuesWireLive),
|
||||
field);
|
||||
return MGPipeFieldMaskHas(SuppliedFieldMask(pushMask, applierDerives, contextValuesWireLive), field);
|
||||
}
|
||||
|
||||
void MGPipeValidateForVerbBarriered(MGPipeVerb verb) {
|
||||
@@ -3097,10 +3074,11 @@ namespace MobileGL::MG_Pipe {
|
||||
// change scalars the apply thread reads inside the record it is applying. The guard
|
||||
// then checks the fact and aborts with Fatal{RoleViolation, "gPipeInputs"} if the wait
|
||||
// is missing. See ARCHITECTURE.md §9.2.2.
|
||||
if (runAhead) MG_Remote::Client::ClientSession::NoteBarrieredVerbForStats(kMGPipeVerbNames[static_cast<SizeT>(verb)]);
|
||||
if (runAhead)
|
||||
MG_Remote::Client::ClientSession::NoteBarrieredVerbForStats(kMGPipeVerbNames[static_cast<SizeT>(verb)]);
|
||||
QuiesceApplierBeforeFill("MGPipeValidateForVerb");
|
||||
MG_Remote::Client::ClientSession::RefusePipeInputsTouchWhileApplierOwnsIt(
|
||||
"MGPipeValidateForVerb", /*isBarrieredFill=*/barriered);
|
||||
MG_Remote::Client::ClientSession::RefusePipeInputsTouchWhileApplierOwnsIt("MGPipeValidateForVerb",
|
||||
/*isBarrieredFill=*/barriered);
|
||||
}
|
||||
#else
|
||||
constexpr Bool fillOwed = true;
|
||||
@@ -3164,10 +3142,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// P13 W4d: AND ON MONOLITH'S RECORD ARM, where the route is the in-process applier
|
||||
// (Mono_SetContextValues) and the backend reads what the record put in gPipeInputs - the
|
||||
// same supplier as a wire, one call away.
|
||||
const Bool contextValuesWireLive =
|
||||
MG_Config::Transport != MG_Config::TransportMode::Monolith
|
||||
? MG_Remote::Client::ContextValuesWireLive()
|
||||
: MG_Config::RecordArmAliasesFrontend();
|
||||
const Bool contextValuesWireLive = MG_Config::Transport != MG_Config::TransportMode::Monolith
|
||||
? MG_Remote::Client::ContextValuesWireLive()
|
||||
: MG_Config::RecordArmAliasesFrontend();
|
||||
#else
|
||||
// P13 W8: a library without a transport is ALWAYS monolith's record arm, so it takes the
|
||||
// eight fields from the record exactly as the split build's monolith does. This branch
|
||||
@@ -3203,8 +3180,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// would wait on itself) and a transport with no live session (EmitApplierResetRecord
|
||||
// returns false) make the direct call instead.
|
||||
const Bool transportActive =
|
||||
MG_Config::Transport != MG_Config::TransportMode::Monolith &&
|
||||
!MG_Remote::Client::RunsAsTheServerRole();
|
||||
MG_Config::Transport != MG_Config::TransportMode::Monolith && !MG_Remote::Client::RunsAsTheServerRole();
|
||||
Bool resetCrossed = false;
|
||||
if (transportActive) {
|
||||
resetCrossed = MG_Remote::Client::EmitApplierResetRecord();
|
||||
@@ -3383,8 +3359,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// into a named abort rather than a torn read.
|
||||
if (fillOwed) {
|
||||
QuiesceApplierBeforeFill("MGPipeValidateForVerb/residual");
|
||||
MG_Remote::Client::ClientSession::RefusePipeInputsTouchWhileApplierOwnsIt(
|
||||
"MGPipeValidateForVerb/residual", /*isBarrieredFill=*/true);
|
||||
MG_Remote::Client::ClientSession::RefusePipeInputsTouchWhileApplierOwnsIt("MGPipeValidateForVerb/residual",
|
||||
/*isBarrieredFill=*/true);
|
||||
}
|
||||
#endif
|
||||
const Bool applierDerives = ApplierDerivesRenderStateFields();
|
||||
|
||||
@@ -126,5 +126,5 @@ namespace MobileGL::MG_Pipe {
|
||||
// baseinstance, carrying the argument RAW. It has to be a macro for MGP_FILL's reason: the
|
||||
// three call sites are compiled in the pull build too, where MGPipeSetPendingBaseInstance is
|
||||
// neither declared nor defined.
|
||||
#define MGP_SET_BASE_INSTANCE(BaseInstance) \
|
||||
#define MGP_SET_BASE_INSTANCE(BaseInstance) \
|
||||
::MobileGL::MG_Pipe::MGPipeSetPendingBaseInstance(static_cast<::MobileGL::Uint32>(BaseInstance))
|
||||
|
||||
@@ -64,8 +64,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// compile take effect only at the next link, and the same stages index GetGeneratedSpirv().
|
||||
inline Uint64 MGPipeStorageOverrideSignatureEntry(const String& blockName, Int binding) {
|
||||
Uint64 entry = std::hash<String>{}(blockName);
|
||||
entry ^= (static_cast<Uint64>(static_cast<Uint32>(binding)) + 0x9e3779b97f4a7c15ull +
|
||||
(entry << 6) + (entry >> 2));
|
||||
entry ^=
|
||||
(static_cast<Uint64>(static_cast<Uint32>(binding)) + 0x9e3779b97f4a7c15ull + (entry << 6) + (entry >> 2));
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -97,8 +97,7 @@ namespace MobileGL::MG_Pipe {
|
||||
const auto& drawProgram = ctx.GetProgramForDraw();
|
||||
const auto& dispatchProgram = ctx.GetProgramForDispatch();
|
||||
|
||||
const MGPipeHandle drawCso =
|
||||
drawProgram ? AcquireShaderCso(*drawProgram, bytes) : kMGPipeNullHandle;
|
||||
const MGPipeHandle drawCso = drawProgram ? AcquireShaderCso(*drawProgram, bytes) : kMGPipeNullHandle;
|
||||
// P5e (pg): AFTER the create and never before it. The draft note on
|
||||
// MGPProgramBindings said "emitted BEFORE create_shader_state at the same validate
|
||||
// point", and that ordering is wrong against the applier the same contract
|
||||
@@ -123,13 +122,12 @@ namespace MobileGL::MG_Pipe {
|
||||
// one pipeline name released the other context's LIVE composite.
|
||||
// GetTextureContextId() is the tree's never-reused per-context id, the same
|
||||
// one PipeInputs carries and the backends' per-context memos key on.
|
||||
MGPipeCompositeResolverInstance().Observe(ctx.GetTextureContextId(), *pipeline,
|
||||
*drawProgram, drawCso);
|
||||
MGPipeCompositeResolverInstance().Observe(ctx.GetTextureContextId(), *pipeline, *drawProgram,
|
||||
drawCso);
|
||||
}
|
||||
}
|
||||
const MGPipeHandle dispatchCso =
|
||||
dispatchProgram ? (dispatchProgram == drawProgram ? drawCso
|
||||
: AcquireShaderCso(*dispatchProgram, bytes))
|
||||
dispatchProgram ? (dispatchProgram == drawProgram ? drawCso : AcquireShaderCso(*dispatchProgram, bytes))
|
||||
: kMGPipeNullHandle;
|
||||
if (dispatchProgram && dispatchProgram != drawProgram) {
|
||||
bytes += EmitProgramBindings(*dispatchProgram, dispatchCso);
|
||||
@@ -353,13 +351,14 @@ namespace MobileGL::MG_Pipe {
|
||||
// every c_str() taken before that would dangle.
|
||||
m_storageOverrideNamePtrs.clear();
|
||||
m_storageOverrideNamePtrs.reserve(m_storageOverrideNames.size());
|
||||
for (const String& name : m_storageOverrideNames) m_storageOverrideNamePtrs.push_back(name.c_str());
|
||||
for (const String& name : m_storageOverrideNames)
|
||||
m_storageOverrideNamePtrs.push_back(name.c_str());
|
||||
|
||||
MGPipeRouteSetProgramBindings(
|
||||
m_lastBindings, m_blockBindings.empty() ? nullptr : m_blockBindings.data(),
|
||||
m_samplerUnits.empty() ? nullptr : m_samplerUnits.data(),
|
||||
m_storageOverrides.empty() ? nullptr : m_storageOverrides.data(),
|
||||
m_storageOverrideNamePtrs.empty() ? nullptr : m_storageOverrideNamePtrs.data());
|
||||
MGPipeRouteSetProgramBindings(m_lastBindings, m_blockBindings.empty() ? nullptr : m_blockBindings.data(),
|
||||
m_samplerUnits.empty() ? nullptr : m_samplerUnits.data(),
|
||||
m_storageOverrides.empty() ? nullptr : m_storageOverrides.data(),
|
||||
m_storageOverrideNamePtrs.empty() ? nullptr
|
||||
: m_storageOverrideNamePtrs.data());
|
||||
++m_bindingSets;
|
||||
|
||||
latch.BindingsLive = true;
|
||||
|
||||
@@ -128,8 +128,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// explicitly, and it may not reach into MG_Impl to do so. The second discriminator is the
|
||||
// frontend enum, named rather than open-coded, and stays here because only this file
|
||||
// produces it.
|
||||
inline constexpr Uint8 kMGPipeResourceStorageKindBuffer =
|
||||
static_cast<Uint8>(MobileGL::TextureStorageType::Buffer);
|
||||
inline constexpr Uint8 kMGPipeResourceStorageKindBuffer = static_cast<Uint8>(MobileGL::TextureStorageType::Buffer);
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// D-A2: the payload builders. Pure, so a unit case can assert field by field.
|
||||
@@ -138,9 +137,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// The descriptor for `buffer`. `storageDefined` is false for the create that the
|
||||
// constructor emits - storage is defined lazily by the first respecify and a backend
|
||||
// tolerates a resource that has none - and true for every respecify.
|
||||
inline MGPResourceDesc MGPipeBuildResourceDesc(const MG_State::GLState::BufferObject& buffer,
|
||||
MGPipeHandle handle, Uint16 bindMask,
|
||||
Bool storageDefined) {
|
||||
inline MGPResourceDesc MGPipeBuildResourceDesc(const MG_State::GLState::BufferObject& buffer, MGPipeHandle handle,
|
||||
Uint16 bindMask, Bool storageDefined) {
|
||||
MGPResourceDesc desc{};
|
||||
desc.Resource = handle;
|
||||
desc.Target = static_cast<Uint8>(kMGPipeResourceTargetBuffer);
|
||||
@@ -158,8 +156,7 @@ namespace MobileGL::MG_Pipe {
|
||||
MGLOG_E_ONCE("MGPipe: buffer %u declares a store of %llu bytes, which does not fit "
|
||||
"MGPResourceDesc::Width - the descriptor's extent is narrowed and every "
|
||||
"write past 4 GiB will be refused by the applier's range gate",
|
||||
buffer.GetExternalIndex(),
|
||||
static_cast<unsigned long long>(buffer.GetSize()));
|
||||
buffer.GetExternalIndex(), static_cast<unsigned long long>(buffer.GetSize()));
|
||||
MOBILEGL_ASSERT(false, "MGPResourceDesc::Width cannot carry this buffer's size");
|
||||
}
|
||||
desc.Width = static_cast<Uint32>(buffer.GetSize());
|
||||
@@ -313,7 +310,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// told about: a live buffer of the ended session's contexts dies with no destroy on the
|
||||
// new wire, and the inverse entries stay so the handles still resolve locally.
|
||||
void ForgetPublication() {
|
||||
for (Entry& entry : m_bySlot) entry.Published = false;
|
||||
for (Entry& entry : m_bySlot)
|
||||
entry.Published = false;
|
||||
}
|
||||
|
||||
// The sticky everBoundAs mask. Sticky exactly as MGPResourceDesc::ImageBindableHint's
|
||||
@@ -504,8 +502,8 @@ namespace MobileGL::MG_Pipe {
|
||||
Uint64 producedAtSeq) {
|
||||
auto* buffer = MGPipeResourceTrackerInstance().Resolve(res);
|
||||
if (buffer == nullptr) {
|
||||
MGLOG_E_ONCE("MGPipe: OnBufferWriteback for a handle {%u,%u} that resolves to no buffer",
|
||||
res.Slot, res.Gen);
|
||||
MGLOG_E_ONCE("MGPipe: OnBufferWriteback for a handle {%u,%u} that resolves to no buffer", res.Slot,
|
||||
res.Gen);
|
||||
return;
|
||||
}
|
||||
void* bytePtr = nullptr;
|
||||
@@ -532,14 +530,13 @@ namespace MobileGL::MG_Pipe {
|
||||
const void* resolved = nullptr;
|
||||
if (session && session->DataLink()) {
|
||||
session->DataLink()->ResolveSpan(MG_Remote::Transport::LinkSegment::Event,
|
||||
{bytes.Offset, bytes.Size}, &resolved);
|
||||
{bytes.Offset, bytes.Size}, &resolved);
|
||||
}
|
||||
if (resolved == nullptr) {
|
||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"OnBufferWriteback.Offset\"} - "
|
||||
"the writeback blobref's {%llu + %llu} does not resolve inside the "
|
||||
"session's SEG_EVENT segment",
|
||||
static_cast<unsigned long long>(bytes.Offset),
|
||||
static_cast<unsigned long long>(bytes.Size));
|
||||
static_cast<unsigned long long>(bytes.Offset), static_cast<unsigned long long>(bytes.Size));
|
||||
std::abort();
|
||||
}
|
||||
bytePtr = const_cast<void*>(resolved);
|
||||
@@ -562,8 +559,8 @@ namespace MobileGL::MG_Pipe {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
buffer->WritebackFromBackend(DataPtr{bytePtr, static_cast<SizeT>(bytes.Size)},
|
||||
static_cast<SizeT>(offset), producedAtSeq);
|
||||
buffer->WritebackFromBackend(DataPtr{bytePtr, static_cast<SizeT>(bytes.Size)}, static_cast<SizeT>(offset),
|
||||
producedAtSeq);
|
||||
}
|
||||
|
||||
// The monolith callback's shape (MGPipeCallbacks::OnBufferWriteback).
|
||||
@@ -593,8 +590,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// Loud, like its sibling above: a backend announcing a write against a handle
|
||||
// this client cannot resolve is a dropped MarkGpuWritten, and a dropped
|
||||
// MarkGpuWritten is a stale shadow read back as if it were current.
|
||||
MGLOG_E_ONCE("MGPipe: OnGpuWritten for a handle {%u,%u} that resolves to no buffer", res.Slot,
|
||||
res.Gen);
|
||||
MGLOG_E_ONCE("MGPipe: OnGpuWritten for a handle {%u,%u} that resolves to no buffer", res.Slot, res.Gen);
|
||||
return;
|
||||
}
|
||||
buffer->MarkGpuWrittenInChannelOrder();
|
||||
@@ -622,8 +618,7 @@ namespace MobileGL::MG_Pipe {
|
||||
}
|
||||
entry = fn;
|
||||
};
|
||||
install(gMGPipeCallbacks.OnBufferWriteback, &MGPipeClientOnBufferWriteback,
|
||||
"OnBufferWriteback");
|
||||
install(gMGPipeCallbacks.OnBufferWriteback, &MGPipeClientOnBufferWriteback, "OnBufferWriteback");
|
||||
install(gMGPipeCallbacks.OnGpuWritten, &MGPipeClientOnGpuWritten, "OnGpuWritten");
|
||||
}
|
||||
|
||||
@@ -631,8 +626,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// and call OnGpuWritten directly; P5f fm rejects Magma's P7 buffer consumers before
|
||||
// reaching here. Keep a named guard at this boundary so a future caller cannot turn
|
||||
// a missing callback/handle into a write through a client object.
|
||||
inline void MGPipeAnnounceBufferGpuWritten(
|
||||
const SharedPtr<MG_State::GLState::BufferObject>& bufferObject) {
|
||||
inline void MGPipeAnnounceBufferGpuWritten(const SharedPtr<MG_State::GLState::BufferObject>& bufferObject) {
|
||||
if (bufferObject == nullptr) return;
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
@@ -645,8 +639,7 @@ namespace MobileGL::MG_Pipe {
|
||||
bufferObject->MarkGpuWritten();
|
||||
return;
|
||||
}
|
||||
const MGPipeHandle res =
|
||||
MGPipeSlots().FindByLifetimeId(MGPipeKind::Buffer, bufferObject->GetLifetimeId());
|
||||
const MGPipeHandle res = MGPipeSlots().FindByLifetimeId(MGPipeKind::Buffer, bufferObject->GetLifetimeId());
|
||||
if (MGPipeHandleIsNull(res)) {
|
||||
MGLOG_E_ONCE("MGPipe: no handle for the GPU-write announcement of buffer %u - the "
|
||||
"reverse channel is installed but the mint is missing, so the mark "
|
||||
|
||||
@@ -132,12 +132,12 @@ namespace MobileGL::MG_Pipe {
|
||||
class MGPipeSamplerCsoCache {
|
||||
public:
|
||||
struct Counters {
|
||||
Uint64 Mints = 0; // create_sampler_state emissions
|
||||
Uint64 Mints = 0; // create_sampler_state emissions
|
||||
Uint64 Acquisitions = 0;
|
||||
Uint64 Hits = 0; // a probe that found a live entry and passed the memcmp
|
||||
Uint64 Collisions = 0; // a hash hit the memcmp REJECTED - the reason it exists
|
||||
Uint64 Evictions = 0; // LRU evictions, each one a delete_sampler_state
|
||||
Uint64 Releases = 0; // reference drops
|
||||
Uint64 Hits = 0; // a probe that found a live entry and passed the memcmp
|
||||
Uint64 Collisions = 0; // a hash hit the memcmp REJECTED - the reason it exists
|
||||
Uint64 Evictions = 0; // LRU evictions, each one a delete_sampler_state
|
||||
Uint64 Releases = 0; // reference drops
|
||||
// Mints made with the cache already full and EVERY entry referenced. A recorded
|
||||
// number and not a gate (ID-17): growing past 256 is the safe direction, and this
|
||||
// is what makes it visible instead of silent.
|
||||
@@ -327,8 +327,7 @@ namespace MobileGL::MG_Pipe {
|
||||
NotePublishedIn(entry, MGPipeCurrentShareGroupToken());
|
||||
payloadBytes += sizeof(MGPSamplerDesc) + sizeof(SamplerParameters);
|
||||
if (MG_Util::PipeStats::Enabled()) {
|
||||
MG_Util::PipeStats::AddBytes(MG_Util::PipeStats::ByteClass::CsoBlobBytes,
|
||||
sizeof(SamplerParameters));
|
||||
MG_Util::PipeStats::AddBytes(MG_Util::PipeStats::ByteClass::CsoBlobBytes, sizeof(SamplerParameters));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,8 +430,7 @@ namespace MobileGL::MG_Pipe {
|
||||
++m_counters.Mints;
|
||||
payloadBytes += sizeof(MGPSamplerDesc) + sizeof(SamplerParameters);
|
||||
if (MG_Util::PipeStats::Enabled()) {
|
||||
MG_Util::PipeStats::AddBytes(MG_Util::PipeStats::ByteClass::CsoBlobBytes,
|
||||
sizeof(SamplerParameters));
|
||||
MG_Util::PipeStats::AddBytes(MG_Util::PipeStats::ByteClass::CsoBlobBytes, sizeof(SamplerParameters));
|
||||
}
|
||||
return cso;
|
||||
}
|
||||
@@ -619,8 +617,7 @@ namespace MobileGL::MG_Pipe {
|
||||
if (unit > m_resolution.MaxImageUnit) m_resolution.MaxImageUnit = unit;
|
||||
continue;
|
||||
}
|
||||
const TextureTarget target =
|
||||
MGPipeSamplerUniformTextureTarget(program->GetUniformType(location));
|
||||
const TextureTarget target = MGPipeSamplerUniformTextureTarget(program->GetUniformType(location));
|
||||
if (target == TextureTarget::Unknown) continue;
|
||||
// FIRST WRITER WINS, which is DirectGLES' arbitration read forwards: when
|
||||
// two sampler uniforms of different types share a unit the binding placed
|
||||
@@ -700,8 +697,7 @@ namespace MobileGL::MG_Pipe {
|
||||
Uint64 EmitSamplerViews(GLContext& ctx) {
|
||||
const Int maxTouched = ctx.GetMaxTouchedTextureUnit();
|
||||
const Uint32 count =
|
||||
maxTouched < 0 ? 0u
|
||||
: Min(static_cast<Uint32>(maxTouched) + 1u, kMGPipeMaxTextureUnits);
|
||||
maxTouched < 0 ? 0u : Min(static_cast<Uint32>(maxTouched) + 1u, kMGPipeMaxTextureUnits);
|
||||
|
||||
// The join is the EMITTER's, deliberately, and it is the same GetProgramForDraw()
|
||||
// the verb is about to make anyway: the tracker's own shutters read
|
||||
@@ -731,13 +727,12 @@ namespace MobileGL::MG_Pipe {
|
||||
// the completeness answer depends on which one applies - a mipmap mode of None
|
||||
// makes a single-level texture complete that would otherwise sample black.
|
||||
const auto& unitSampler = textureUnit.GetSamplerObject();
|
||||
const SamplerObject* effective =
|
||||
unitSampler ? unitSampler.get() : texture->GetSamplerObject().get();
|
||||
const SamplerObject* effective = unitSampler ? unitSampler.get() : texture->GetSamplerObject().get();
|
||||
if (MG_State::GLState::SamplesAsIncompleteTexture(texture.get(), effective)) continue;
|
||||
|
||||
entry.Texture = MGPipeSlots().AcquireHinted(
|
||||
MGPipeKind::Texture, texture->GetLifetimeId(),
|
||||
texture->PipeHandleHint(ITextureObject::PipeHintKind::Texture));
|
||||
entry.Texture =
|
||||
MGPipeSlots().AcquireHinted(MGPipeKind::Texture, texture->GetLifetimeId(),
|
||||
texture->PipeHandleHint(ITextureObject::PipeHintKind::Texture));
|
||||
// D-A4: a texture the sampler-view resolution names in an emitted MGPBoundView
|
||||
// is SAMPLER-bound from then on (sticky; the texture emitter's contract door,
|
||||
// since this header is included BY TextureEmit.h). One early-out per unit per
|
||||
@@ -773,15 +768,13 @@ namespace MobileGL::MG_Pipe {
|
||||
Uint64 EmitSamplerStates(GLContext& ctx) {
|
||||
const Int maxTouched = ctx.GetMaxTouchedTextureUnit();
|
||||
const Uint32 count =
|
||||
maxTouched < 0 ? 0u
|
||||
: Min(static_cast<Uint32>(maxTouched) + 1u, kMGPipeMaxTextureUnits);
|
||||
maxTouched < 0 ? 0u : Min(static_cast<Uint32>(maxTouched) + 1u, kMGPipeMaxTextureUnits);
|
||||
|
||||
Uint64 bytes = 0;
|
||||
MGPipeSamplerCsoCache& cache = MGPipeSamplerCsoCacheInstance();
|
||||
for (Uint32 unit = 0; unit < count; ++unit) {
|
||||
const auto& sampler = ctx.GetTextureUnitObject(static_cast<Int>(unit)).GetSamplerObject();
|
||||
m_states[unit] =
|
||||
sampler ? cache.Acquire(sampler->GetAllSamplerParameters(), bytes) : kMGPipeNullHandle;
|
||||
m_states[unit] = sampler ? cache.Acquire(sampler->GetAllSamplerParameters(), bytes) : kMGPipeNullHandle;
|
||||
}
|
||||
for (Uint32 unit = 0; unit < kMGPipeMaxTextureUnits; ++unit) {
|
||||
const MGPipeHandle held = m_stateRefs[unit];
|
||||
@@ -900,8 +893,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// because a birth is not a validate-point emission and has no payload budget to report.
|
||||
void EmitSamplerView(ITextureObject& texture) {
|
||||
Uint64 bytes = 0;
|
||||
const MGPipeHandle textureHandle =
|
||||
MGPipeSlots().Acquire(MGPipeKind::Texture, texture.GetLifetimeId());
|
||||
const MGPipeHandle textureHandle = MGPipeSlots().Acquire(MGPipeKind::Texture, texture.GetLifetimeId());
|
||||
AcquireSamplerView(texture, textureHandle, bytes);
|
||||
}
|
||||
|
||||
@@ -966,9 +958,7 @@ namespace MobileGL::MG_Pipe {
|
||||
const MGPSamplerViews& LastSamplerViews() const { return m_lastViews; }
|
||||
const Array<MGPBoundView, kMGPipeMaxTextureUnits>& LastBoundViews() const { return m_views; }
|
||||
const MGPSamplerStates& LastSamplerStates() const { return m_lastStates; }
|
||||
const Array<MGPipeHandle, kMGPipeMaxTextureUnits>& LastSamplerStateHandles() const {
|
||||
return m_states;
|
||||
}
|
||||
const Array<MGPipeHandle, kMGPipeMaxTextureUnits>& LastSamplerStateHandles() const { return m_states; }
|
||||
const MGPSamplerView& LastCreatedView() const { return m_lastView; }
|
||||
Uint64 ViewSetCount() const { return m_viewSets; }
|
||||
Uint64 StateSetCount() const { return m_stateSets; }
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// hash is the "did any covered value move" answer. The enum is
|
||||
// CLIENT-ONLY and is not a wire opcode, so appending before Count is safe.
|
||||
enum class MGPipeSuppressorSlot : Uint32 {
|
||||
SetVertexBuffers = 0, // P3a - wired, and its hash includes BaseInstance
|
||||
SetVertexBuffers = 0, // P3a - wired, and its hash includes BaseInstance
|
||||
// P4a - WIRED. The three unit sets' suppressors are not optional and were never a
|
||||
// later phase's: MGPipeTypes.h makes the pattern mandatory for every kVarTail set_*,
|
||||
// because GetTextureBindGeneration() bumps on a REDUNDANT rebind - MC 26.2 rebinds the
|
||||
@@ -37,9 +37,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// the design names. What P3b/P4b owns is the ~175-line BACKEND debounce these replace
|
||||
// (UnitBindingsSnapshot / CaptureUnitBindings / UnitBindingsUnchanged and the two
|
||||
// g_*SyncList tables); P4a wires the carrier, P3b/P4b deletes the backend copy.
|
||||
SetSamplerViews, // P4a - wired (backend debounce deletion: P3b/P4b)
|
||||
BindSamplerStates, // P4a - wired (backend debounce deletion: P3b/P4b)
|
||||
SetShaderImages, // P4a - wired (backend debounce deletion: P3b/P4b)
|
||||
SetSamplerViews, // P4a - wired (backend debounce deletion: P3b/P4b)
|
||||
BindSamplerStates, // P4a - wired (backend debounce deletion: P3b/P4b)
|
||||
SetShaderImages, // P4a - wired (backend debounce deletion: P3b/P4b)
|
||||
// P5e (docs/archive/contracts/CONTRACT-P5E.md §1, ruling 11): THREE SLOTS, ONE PER CLASS, not one
|
||||
// for the call. set_shader_buffers is emitted per Class (Uniform / ShaderStorage /
|
||||
// AtomicCounter) because the record's own Class field says which binding-point array
|
||||
@@ -51,20 +51,20 @@ namespace MobileGL::MG_Pipe {
|
||||
SetShaderBuffersUniform, // P5e (sb)
|
||||
SetShaderBuffersShaderStorage, // P5e (sb)
|
||||
SetShaderBuffersAtomicCounter, // P5e (sb)
|
||||
SetStreamOutputTargets, // P4b
|
||||
SetStreamOutputTargets, // P4b
|
||||
// P5e (CONTRACT-P5E.md §1): set_program_bindings, the post-link binding record. Not
|
||||
// kVarTail-only - it has three tails - but the same rule applies: the emitter latches
|
||||
// on (Cso, backendStateVersion, blockBindingVersion) and the whole-record hash is what
|
||||
// says "nothing moved".
|
||||
SetProgramBindings, // P5e (pg)
|
||||
SetVertexAttribDefaults, // P2 - the one consumer that is wired
|
||||
SetFramebufferState, // P4a - wired
|
||||
SetProgramBindings, // P5e (pg)
|
||||
SetVertexAttribDefaults, // P2 - the one consumer that is wired
|
||||
SetFramebufferState, // P4a - wired
|
||||
// P5c rv (CONTRACT-P5C.md §5.3). NOT kVarTail either - the same shape as
|
||||
// SetFramebufferState's note: MGPContextValues is one fixed-width POD, and the
|
||||
// whole-record hash IS its "did any covered value move" answer (there is deliberately
|
||||
// no dirty mask in the payload - a suppressed record means "nothing moved", never
|
||||
// "field invalid").
|
||||
SetContextValues, // P5c rv - wired, split+transport only (PipeFill.cpp gates)
|
||||
SetContextValues, // P5c rv - wired, split+transport only (PipeFill.cpp gates)
|
||||
Count,
|
||||
};
|
||||
|
||||
@@ -94,14 +94,13 @@ namespace MobileGL::MG_Pipe {
|
||||
void Invalidate(MGPipeSuppressorSlot slot) { m_lastEmitted[static_cast<SizeT>(slot)] = 0; }
|
||||
|
||||
void InvalidateAll() {
|
||||
for (SizeT i = 0; i < kMGPipeSuppressorSlotCount; ++i) m_lastEmitted[i] = 0;
|
||||
for (SizeT i = 0; i < kMGPipeSuppressorSlotCount; ++i)
|
||||
m_lastEmitted[i] = 0;
|
||||
}
|
||||
|
||||
// 0 == "never emitted". Exposed for the unit test, which is what pins that the
|
||||
// reserved value really is reserved.
|
||||
Uint64 LastEmitted(MGPipeSuppressorSlot slot) const {
|
||||
return m_lastEmitted[static_cast<SizeT>(slot)];
|
||||
}
|
||||
Uint64 LastEmitted(MGPipeSuppressorSlot slot) const { return m_lastEmitted[static_cast<SizeT>(slot)]; }
|
||||
|
||||
private:
|
||||
Array<Uint64, kMGPipeSuppressorSlotCount> m_lastEmitted{};
|
||||
|
||||
@@ -45,9 +45,12 @@ namespace MobileGL::MG_Pipe {
|
||||
// chances to pair Uniform with ShaderStorage.
|
||||
inline constexpr BufferTarget MGPipeBufferTargetForShaderBufferClass(Uint32 cls) {
|
||||
switch (cls) {
|
||||
case kMGPipeShaderBufferClassShaderStorage: return BufferTarget::ShaderStorage;
|
||||
case kMGPipeShaderBufferClassAtomicCounter: return BufferTarget::AtomicCounter;
|
||||
default: return BufferTarget::Uniform;
|
||||
case kMGPipeShaderBufferClassShaderStorage:
|
||||
return BufferTarget::ShaderStorage;
|
||||
case kMGPipeShaderBufferClassAtomicCounter:
|
||||
return BufferTarget::AtomicCounter;
|
||||
default:
|
||||
return BufferTarget::Uniform;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +61,8 @@ namespace MobileGL::MG_Pipe {
|
||||
return MGPipeSuppressorSlot::SetShaderBuffersShaderStorage;
|
||||
case kMGPipeShaderBufferClassAtomicCounter:
|
||||
return MGPipeSuppressorSlot::SetShaderBuffersAtomicCounter;
|
||||
default: return MGPipeSuppressorSlot::SetShaderBuffersUniform;
|
||||
default:
|
||||
return MGPipeSuppressorSlot::SetShaderBuffersUniform;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,9 +72,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// same, or the per-class A/B tallies would be reading each other's traffic - and the mask
|
||||
// words are mixed because they are a FIELD of the record that the entries alone do not
|
||||
// determine (a uniform range and a storage range with the same handle differ only there).
|
||||
inline Uint64 MGPipeShaderBufferSetContentHash(const MGPBufferRange* entries, Uint32 cls,
|
||||
Uint32 start, Uint32 count,
|
||||
const Uint32* writableMask) {
|
||||
inline Uint64 MGPipeShaderBufferSetContentHash(const MGPBufferRange* entries, Uint32 cls, Uint32 start,
|
||||
Uint32 count, const Uint32* writableMask) {
|
||||
Uint64 hash = XXH64(entries, static_cast<SizeT>(count) * sizeof(MGPBufferRange), 0);
|
||||
hash = MGPipeMixShutter(hash, cls);
|
||||
hash = MGPipeMixShutter(hash, start);
|
||||
@@ -86,9 +89,7 @@ namespace MobileGL::MG_Pipe {
|
||||
using GLContext = MG_State::GLState::GLContext;
|
||||
|
||||
// Dirty bit 15 (NEW_CONST_BUFFERS) -> the uniform binding points.
|
||||
Uint64 EmitConstBuffers(GLContext& ctx) {
|
||||
return EmitClass(ctx, kMGPipeShaderBufferClassUniform);
|
||||
}
|
||||
Uint64 EmitConstBuffers(GLContext& ctx) { return EmitClass(ctx, kMGPipeShaderBufferClassUniform); }
|
||||
|
||||
// Dirty bit 16 (NEW_SHADER_BUFFERS) -> the two WRITABLE classes, which share a bit
|
||||
// because they share a shutter: a storage bind and a counter bind are both "the
|
||||
@@ -111,7 +112,8 @@ namespace MobileGL::MG_Pipe {
|
||||
}
|
||||
|
||||
void ResetCounters() {
|
||||
for (Uint32 cls = 0; cls < kMGPipeShaderBufferClassCount; ++cls) m_emissions[cls] = 0;
|
||||
for (Uint32 cls = 0; cls < kMGPipeShaderBufferClassCount; ++cls)
|
||||
m_emissions[cls] = 0;
|
||||
}
|
||||
|
||||
// What a unit case reads. The emitter hands m_entries straight to the route, so "what
|
||||
@@ -119,12 +121,8 @@ namespace MobileGL::MG_Pipe {
|
||||
const MGPShaderBuffers& LastHeader(Uint32 cls) const {
|
||||
return m_last[cls < kMGPipeShaderBufferClassCount ? cls : 0];
|
||||
}
|
||||
const Array<MGPBufferRange, kMGPipeMaxBufferBindingPoints>& LastRanges() const {
|
||||
return m_entries;
|
||||
}
|
||||
Uint64 EmissionCount(Uint32 cls) const {
|
||||
return m_emissions[cls < kMGPipeShaderBufferClassCount ? cls : 0];
|
||||
}
|
||||
const Array<MGPBufferRange, kMGPipeMaxBufferBindingPoints>& LastRanges() const { return m_entries; }
|
||||
Uint64 EmissionCount(Uint32 cls) const { return m_emissions[cls < kMGPipeShaderBufferClassCount ? cls : 0]; }
|
||||
|
||||
private:
|
||||
Uint64 EmitClass(GLContext& ctx, Uint32 cls) {
|
||||
@@ -133,9 +131,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// never binds an indexed buffer of this class.
|
||||
const SizeT touched = ctx.GetTouchedBufferBindingPointCount(target);
|
||||
if (touched == 0) return 0;
|
||||
const Uint32 count = touched < kMGPipeMaxBufferBindingPoints
|
||||
? static_cast<Uint32>(touched)
|
||||
: kMGPipeMaxBufferBindingPoints;
|
||||
const Uint32 count =
|
||||
touched < kMGPipeMaxBufferBindingPoints ? static_cast<Uint32>(touched) : kMGPipeMaxBufferBindingPoints;
|
||||
// NO CLIENT-SIDE CLAMP TO THE DEVICE's LIMIT (ruling 10). MobileGL advertises the
|
||||
// GL 4.5 minimum of 84 uniform binding points while ES 3.2's is 72, and which of
|
||||
// them the driver can actually hold is a SERVER question: the backend clamps to
|
||||
@@ -191,10 +188,8 @@ namespace MobileGL::MG_Pipe {
|
||||
if (classIsWritable) MGPipeShaderBufferMaskSet(writableMask, i);
|
||||
}
|
||||
|
||||
const Uint64 hash =
|
||||
MGPipeShaderBufferSetContentHash(m_entries.data(), cls, 0, count, writableMask);
|
||||
if (!MGPipeSetHashSuppressorInstance().ShouldEmit(
|
||||
MGPipeSuppressorSlotForShaderBufferClass(cls), hash)) {
|
||||
const Uint64 hash = MGPipeShaderBufferSetContentHash(m_entries.data(), cls, 0, count, writableMask);
|
||||
if (!MGPipeSetHashSuppressorInstance().ShouldEmit(MGPipeSuppressorSlotForShaderBufferClass(cls), hash)) {
|
||||
return 0;
|
||||
}
|
||||
MGPShaderBuffers& header = m_last[cls];
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
#include <Config.h>
|
||||
#include <MG_Backend/MGPipe/PipeInputs.h> // D1c: MGPipeServerArm()
|
||||
#include <MG_Backend/MGPipe/PipeInputs.h> // D1c: MGPipeServerArm()
|
||||
#include <MG_Pipe/PipeApply.h>
|
||||
#include <MG_Remote/Server/ServerLoop.h>
|
||||
#include <MG_Util/Debug/Log.h>
|
||||
@@ -70,8 +70,7 @@ namespace MobileGL::MG_Pipe {
|
||||
return m_kinds[index < kKindCount ? index : 0];
|
||||
}
|
||||
|
||||
MGPipeSlotAllocator::SlotState* MGPipeSlotAllocator::EntryOf(KindState& state, MGPipeKind kind,
|
||||
Uint32 slot) {
|
||||
MGPipeSlotAllocator::SlotState* MGPipeSlotAllocator::EntryOf(KindState& state, MGPipeKind kind, Uint32 slot) {
|
||||
if (kind == MGPipeKind::ShaderCso && MGPipeIsCompositeShaderSlot(slot)) {
|
||||
const SizeT index = slot - kMGPipeShaderCsoCompositeSlotBase;
|
||||
if (index >= state.BandSlots.size()) return nullptr;
|
||||
@@ -81,8 +80,8 @@ namespace MobileGL::MG_Pipe {
|
||||
return &state.Slots[slot];
|
||||
}
|
||||
|
||||
const MGPipeSlotAllocator::SlotState*
|
||||
MGPipeSlotAllocator::EntryOf(const KindState& state, MGPipeKind kind, Uint32 slot) {
|
||||
const MGPipeSlotAllocator::SlotState* MGPipeSlotAllocator::EntryOf(const KindState& state, MGPipeKind kind,
|
||||
Uint32 slot) {
|
||||
return EntryOf(const_cast<KindState&>(state), kind, slot);
|
||||
}
|
||||
|
||||
@@ -106,8 +105,7 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
if (!reused) {
|
||||
slot = static_cast<Uint32>(state.Slots.size());
|
||||
MOBILEGL_ASSERT(SlotIsAllocatable(kind, slot),
|
||||
"MGPipe slot space of kind %u is exhausted at slot %u",
|
||||
MOBILEGL_ASSERT(SlotIsAllocatable(kind, slot), "MGPipe slot space of kind %u is exhausted at slot %u",
|
||||
static_cast<Uint32>(kind), slot);
|
||||
if (!SlotIsAllocatable(kind, slot)) return kMGPipeNullHandle;
|
||||
state.Slots.emplace_back();
|
||||
@@ -223,8 +221,7 @@ namespace MobileGL::MG_Pipe {
|
||||
return MGPipeHandle{it->second, entry->Gen};
|
||||
}
|
||||
|
||||
MGPipeHandle MGPipeSlotAllocator::FindByLifetimeIdHinted(MGPipeKind kind, Uint64 lifetimeId,
|
||||
Uint64& hint) const {
|
||||
MGPipeHandle MGPipeSlotAllocator::FindByLifetimeIdHinted(MGPipeKind kind, Uint64 lifetimeId, Uint64& hint) const {
|
||||
if (hint != 0 && lifetimeId != 0) {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
MGPipeRefuseAllocatorFromApplyThread("FindByLifetimeIdHinted");
|
||||
@@ -317,7 +314,9 @@ namespace MobileGL::MG_Pipe {
|
||||
return static_cast<Uint32>(kMGPipeShaderCsoCompositeSlotBase + state.BandSlots.size());
|
||||
}
|
||||
|
||||
Uint32 MGPipeSlotAllocator::LiveCount(MGPipeKind kind) const { return StateOf(kind).LiveCount; }
|
||||
Uint32 MGPipeSlotAllocator::LiveCount(MGPipeKind kind) const {
|
||||
return StateOf(kind).LiveCount;
|
||||
}
|
||||
|
||||
Uint32 MGPipeSlotAllocator::CompositeLiveCount() const {
|
||||
return StateOf(MGPipeKind::ShaderCso).BandLiveCount;
|
||||
|
||||
@@ -52,8 +52,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// MOBILEGL_PIPE_PUSH, not the wired constants, so this constant and the sampler one are set
|
||||
// together, and the framebuffer constant is never set without this one.
|
||||
inline constexpr Uint64 kMGPipeWiredTextureSubsystem = kMGPipeSubsystemTextureResources;
|
||||
static_assert(kMGPipeWiredTextureSubsystem == 0 ||
|
||||
kMGPipeWiredTextureSubsystem == kMGPipeSubsystemTextureResources,
|
||||
static_assert(kMGPipeWiredTextureSubsystem == 0 || kMGPipeWiredTextureSubsystem == kMGPipeSubsystemTextureResources,
|
||||
"a family's wired constant is 0 or its own bit and nothing else");
|
||||
|
||||
// BOTH HALVES MATTER, exactly as MGPipeResourceSubsystemEnabled()'s two do, and they are
|
||||
@@ -170,10 +169,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// `viewOf`, `bufferForTexBuffer` and the buffer window are handed in rather than resolved
|
||||
// here, because resolving them needs the slot allocator and this function must stay pure.
|
||||
inline MGPResourceDesc MGPipeBuildTextureResourceDesc(const MG_State::GLState::ITextureObject& texture,
|
||||
MGPipeHandle handle, Uint16 bindMask,
|
||||
Bool storageDefined, MGPipeHandle viewOf,
|
||||
MGPipeHandle bufferForTexBuffer, Uint64 bufOffset,
|
||||
Uint64 bufSize) {
|
||||
MGPipeHandle handle, Uint16 bindMask, Bool storageDefined,
|
||||
MGPipeHandle viewOf, MGPipeHandle bufferForTexBuffer,
|
||||
Uint64 bufOffset, Uint64 bufSize) {
|
||||
MGPResourceDesc desc{};
|
||||
desc.Resource = handle;
|
||||
desc.Target = static_cast<Uint8>(MGPipeResourceTargetForTextureTarget(texture.GetTarget()));
|
||||
@@ -204,9 +202,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// count, a buffer texture with whether a buffer is attached; both are what the
|
||||
// backend's ensure path already tests before it uploads anything.
|
||||
desc.HasDefinedContent =
|
||||
(mipmap != nullptr ? mipmap->GetMipmapLevelCount() > 0 : !MGPipeHandleIsNull(bufferForTexBuffer))
|
||||
? 1
|
||||
: 0;
|
||||
(mipmap != nullptr ? mipmap->GetMipmapLevelCount() > 0 : !MGPipeHandleIsNull(bufferForTexBuffer)) ? 1
|
||||
: 0;
|
||||
}
|
||||
desc.ViewOf = viewOf;
|
||||
desc.BufferForTexBuffer = bufferForTexBuffer;
|
||||
@@ -375,8 +372,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// texel), and NOTHING has been handed out when it returns false, so the caller keeps the
|
||||
// whole-level record it would have emitted anyway.
|
||||
template <class Fn>
|
||||
inline Bool MGPipeForEachTextureSlab(const IntVec3& levelSize, const MGPipeLevelPitch& pitch,
|
||||
Uint64 levelBytes, SizeT chunkBytes, Fn&& body) {
|
||||
inline Bool MGPipeForEachTextureSlab(const IntVec3& levelSize, const MGPipeLevelPitch& pitch, Uint64 levelBytes,
|
||||
SizeT chunkBytes, Fn&& body) {
|
||||
const Uint64 cap = static_cast<Uint64>(chunkBytes);
|
||||
const Uint64 width = static_cast<Uint64>(std::max<Int>(levelSize.x(), 0));
|
||||
const Uint64 height = static_cast<Uint64>(std::max<Int>(levelSize.y(), 0));
|
||||
@@ -390,12 +387,11 @@ namespace MobileGL::MG_Pipe {
|
||||
// tail no box describes, and it stays on the whole-level record.
|
||||
if (sliceStride * depth != levelBytes) return false;
|
||||
|
||||
const auto emit = [&](Uint64 x0, Uint64 y0, Uint64 z0, Uint64 w, Uint64 h, Uint64 d,
|
||||
Uint64 runOffset, Uint64 runBytes) {
|
||||
const auto emit = [&](Uint64 x0, Uint64 y0, Uint64 z0, Uint64 w, Uint64 h, Uint64 d, Uint64 runOffset,
|
||||
Uint64 runBytes) {
|
||||
MGPipeTextureSlab slab{};
|
||||
slab.Box = MGPBox{static_cast<Int32>(x0), static_cast<Int32>(y0), static_cast<Int32>(z0),
|
||||
static_cast<Uint32>(w), static_cast<Uint32>(h),
|
||||
static_cast<Uint32>(d)};
|
||||
static_cast<Uint32>(w), static_cast<Uint32>(h), static_cast<Uint32>(d)};
|
||||
slab.RunOffset = runOffset;
|
||||
slab.RunBytes = runBytes;
|
||||
body(slab);
|
||||
@@ -427,8 +423,7 @@ namespace MobileGL::MG_Pipe {
|
||||
for (Uint64 y = 0; y < height; ++y) {
|
||||
for (Uint64 x = 0; x < width; x += slabTexels) {
|
||||
const Uint64 w = std::min(slabTexels, width - x);
|
||||
emit(x, y, z, w, 1, 1, (z * height + y) * rowStride + x * texelBytes,
|
||||
w * texelBytes);
|
||||
emit(x, y, z, w, 1, 1, (z * height + y) * rowStride + x * texelBytes, w * texelBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -442,8 +437,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// MGPipeBuildSubRegion computes it. THE STRIDES STAY THE LEVEL'S: a clipped rect's rows are no
|
||||
// more contiguous inside the piece than inside the level, and a 0 would be read as "tightly
|
||||
// packed" - the whole-level spelling - which would repack the wrong bytes.
|
||||
inline MGPSubRegion MGPipeBuildPieceRegion(const MGPBox& box, const MGPBox& piece,
|
||||
const MGPipeLevelPitch& pitch) {
|
||||
inline MGPSubRegion MGPipeBuildPieceRegion(const MGPBox& box, const MGPBox& piece, const MGPipeLevelPitch& pitch) {
|
||||
MGPSubRegion region{};
|
||||
region.X = box.X;
|
||||
region.Y = box.Y;
|
||||
@@ -467,9 +461,8 @@ namespace MobileGL::MG_Pipe {
|
||||
const Int64 y1 = std::min<Int64>(static_cast<Int64>(a.Y) + a.H, static_cast<Int64>(b.Y) + b.H);
|
||||
const Int64 z1 = std::min<Int64>(static_cast<Int64>(a.Z) + a.D, static_cast<Int64>(b.Z) + b.D);
|
||||
if (x1 <= x0 || y1 <= y0 || z1 <= z0) return MGPBox{};
|
||||
return MGPBox{static_cast<Int32>(x0), static_cast<Int32>(y0), static_cast<Int32>(z0),
|
||||
static_cast<Uint32>(x1 - x0), static_cast<Uint32>(y1 - y0),
|
||||
static_cast<Uint32>(z1 - z0)};
|
||||
return MGPBox{static_cast<Int32>(x0), static_cast<Int32>(y0), static_cast<Int32>(z0),
|
||||
static_cast<Uint32>(x1 - x0), static_cast<Uint32>(y1 - y0), static_cast<Uint32>(z1 - z0)};
|
||||
}
|
||||
|
||||
// THE REGIONS ONE PIECE CARRIES: every dirty rect clipped to the piece's box, each with its
|
||||
@@ -478,9 +471,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// the far side reads as tightly packed), and the piece's bytes have to cross whether or not
|
||||
// any of them changed, because the server's level image is assembled from these runs and a
|
||||
// hole in it is a texel read nothing on that side can answer.
|
||||
inline SizeT MGPipeBuildSlabRegions(const MGPBox* rects, SizeT rectCount,
|
||||
const MGPipeTextureSlab& slab, const MGPipeLevelPitch& pitch,
|
||||
MGPSubRegion* out, SizeT maxOut) {
|
||||
inline SizeT MGPipeBuildSlabRegions(const MGPBox* rects, SizeT rectCount, const MGPipeTextureSlab& slab,
|
||||
const MGPipeLevelPitch& pitch, MGPSubRegion* out, SizeT maxOut) {
|
||||
if (out == nullptr || maxOut == 0) return 0;
|
||||
SizeT count = 0;
|
||||
for (SizeT i = 0; i < rectCount && count < maxOut; ++i) {
|
||||
@@ -697,8 +689,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// entry points (glTexParameter BASE_LEVEL) move no descriptor field; a OneLevel call
|
||||
// never is: a non-base level's extent moves no descriptor field, and a pending box kept
|
||||
// across a shrink would upload past the end of the new level.
|
||||
void EmitResourceRespecify(ITextureObject& texture, MGPipeTextureRespecifyScope scope,
|
||||
Uint32 uploadTarget, Uint32 level) {
|
||||
void EmitResourceRespecify(ITextureObject& texture, MGPipeTextureRespecifyScope scope, Uint32 uploadTarget,
|
||||
Uint32 level) {
|
||||
const MGPipeHandle handle = AcquireTexture(texture.GetLifetimeId(), &texture);
|
||||
// THE VIEW'S OWNER IS ACQUIRED FIRST, and no Entry& is held across it (m3): the
|
||||
// owner's slot can be higher than this table's size, so AcquireTexture would
|
||||
@@ -734,8 +726,7 @@ namespace MobileGL::MG_Pipe {
|
||||
}
|
||||
Entry& entry = EntryFor(m_textures, handle);
|
||||
const MGPResourceDesc desc = MGPipeBuildTextureResourceDesc(
|
||||
texture, handle, entry.BindMask, /*storageDefined=*/true, viewOf, bufferHandle, bufOffset,
|
||||
bufSize);
|
||||
texture, handle, entry.BindMask, /*storageDefined=*/true, viewOf, bufferHandle, bufOffset, bufSize);
|
||||
const Bool unchanged = entry.HasLastDesc && std::memcmp(&entry.LastDesc, &desc, sizeof(desc)) == 0;
|
||||
|
||||
// THE KEYS THIS CALL DROPS. `keyCount == 0` is the whole resource (a null level
|
||||
@@ -772,9 +763,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// REFUSED. A create rather than a respecify, because that is what the record's
|
||||
// absence means and because the applier starts a record over on a create.
|
||||
if (!MGPipeHandleIsPublished(MGPipeKind::Texture, handle)) {
|
||||
const MGPResourceDesc createDesc = MGPipeBuildTextureResourceDesc(
|
||||
texture, handle, entry.BindMask, /*storageDefined=*/false, viewOf, bufferHandle,
|
||||
bufOffset, bufSize);
|
||||
const MGPResourceDesc createDesc =
|
||||
MGPipeBuildTextureResourceDesc(texture, handle, entry.BindMask, /*storageDefined=*/false, viewOf,
|
||||
bufferHandle, bufOffset, bufSize);
|
||||
NoteDesc(createDesc, /*isCreate=*/true);
|
||||
PublishCreate(MGPipeKind::Texture, handle, entry, createDesc);
|
||||
}
|
||||
@@ -795,8 +786,8 @@ namespace MobileGL::MG_Pipe {
|
||||
static_cast<Uint32>(MGPipeResourceTargetForTextureTarget(texture.GetTarget())), uploadTarget);
|
||||
Bool accepted = false;
|
||||
if (keyCount == 0) {
|
||||
accepted = RespecifyOnce(texture, handle, entry, desc, nullptr, viewOf, bufferHandle, bufOffset,
|
||||
bufSize);
|
||||
accepted =
|
||||
RespecifyOnce(texture, handle, entry, desc, nullptr, viewOf, bufferHandle, bufOffset, bufSize);
|
||||
} else {
|
||||
for (Uint32 i = 0; i < keyCount; ++i) {
|
||||
MGPRespecifiedLevel key{};
|
||||
@@ -807,13 +798,13 @@ namespace MobileGL::MG_Pipe {
|
||||
MGLOG_E_ONCE("MGPipe: a per-level texture respecify had no mipmap storage; it was not emitted");
|
||||
return;
|
||||
}
|
||||
const IntVec3 exactLevelExtent = mipmap->GetMipmapTexelSize(
|
||||
static_cast<TextureUploadTarget>(uploadTarget), key.Level);
|
||||
const IntVec3 exactLevelExtent =
|
||||
mipmap->GetMipmapTexelSize(static_cast<TextureUploadTarget>(uploadTarget), key.Level);
|
||||
key.Width = static_cast<Uint32>(exactLevelExtent.x());
|
||||
key.Height = static_cast<Uint32>(exactLevelExtent.y());
|
||||
key.Depth = static_cast<Uint32>(exactLevelExtent.z());
|
||||
accepted = RespecifyOnce(texture, handle, entry, desc, &key, viewOf, bufferHandle, bufOffset,
|
||||
bufSize);
|
||||
accepted =
|
||||
RespecifyOnce(texture, handle, entry, desc, &key, viewOf, bufferHandle, bufOffset, bufSize);
|
||||
if (!accepted) break;
|
||||
}
|
||||
}
|
||||
@@ -833,8 +824,7 @@ namespace MobileGL::MG_Pipe {
|
||||
const MGPTextureParams& params) {
|
||||
Entry& entry = EntryFor(m_textures, handle);
|
||||
const MGPResourceDesc healDesc = MGPipeBuildTextureResourceDesc(
|
||||
texture, handle, bindMask, /*storageDefined=*/false, kMGPipeNullHandle,
|
||||
kMGPipeNullHandle, 0, 0);
|
||||
texture, handle, bindMask, /*storageDefined=*/false, kMGPipeNullHandle, kMGPipeNullHandle, 0, 0);
|
||||
NoteDesc(healDesc, /*isCreate=*/true);
|
||||
PublishCreate(MGPipeKind::Texture, handle, entry, healDesc);
|
||||
const auto* mipmap = MG_State::GLState::AsMipmapTexture(&texture);
|
||||
@@ -897,8 +887,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// at the recycle, as the belt, for a death this emitter was not told about.
|
||||
MGPipeSamplerCsoCache& cache = MGPipeSamplerCsoCacheInstance();
|
||||
Uint64 samplerBytes = 0;
|
||||
const MGPipeHandle builtinSampler =
|
||||
cache.Acquire(sampler->GetAllSamplerParameters(), samplerBytes);
|
||||
const MGPipeHandle builtinSampler = cache.Acquire(sampler->GetAllSamplerParameters(), samplerBytes);
|
||||
m_samplerCsoPayloadBytes += samplerBytes;
|
||||
if (entry.BuiltinSampler == builtinSampler) {
|
||||
// The value did not move, so the cache handed back the handle this entry
|
||||
@@ -947,9 +936,9 @@ namespace MobileGL::MG_Pipe {
|
||||
// deduped away), and the parameters land on the record that now exists. The
|
||||
// same repair covers the served context's teardown scope, where the records are
|
||||
// dropped while the objects live on. One retry, never a loop.
|
||||
const MGPResourceDesc healDesc = MGPipeBuildTextureResourceDesc(
|
||||
texture, handle, entry.BindMask, /*storageDefined=*/false, kMGPipeNullHandle,
|
||||
kMGPipeNullHandle, 0, 0);
|
||||
const MGPResourceDesc healDesc =
|
||||
MGPipeBuildTextureResourceDesc(texture, handle, entry.BindMask, /*storageDefined=*/false,
|
||||
kMGPipeNullHandle, kMGPipeNullHandle, 0, 0);
|
||||
NoteDesc(healDesc, /*isCreate=*/true);
|
||||
PublishCreate(MGPipeKind::Texture, handle, entry, healDesc);
|
||||
const auto* mipmap = MG_State::GLState::AsMipmapTexture(&texture);
|
||||
@@ -983,9 +972,8 @@ namespace MobileGL::MG_Pipe {
|
||||
void EmitRenderbufferCreate(RenderbufferObject& renderbuffer) {
|
||||
const MGPipeHandle handle = AcquireRenderbuffer(renderbuffer.GetLifetimeId());
|
||||
Entry& entry = EntryFor(m_renderbuffers, handle);
|
||||
const MGPResourceDesc desc = MGPipeBuildRenderbufferResourceDesc(renderbuffer, handle,
|
||||
entry.BindMask,
|
||||
/*storageDefined=*/false);
|
||||
const MGPResourceDesc desc = MGPipeBuildRenderbufferResourceDesc(renderbuffer, handle, entry.BindMask,
|
||||
/*storageDefined=*/false);
|
||||
NoteDesc(desc, /*isCreate=*/true);
|
||||
PublishCreate(MGPipeKind::Renderbuffer, handle, entry, desc);
|
||||
}
|
||||
@@ -1003,13 +991,12 @@ namespace MobileGL::MG_Pipe {
|
||||
void EmitRenderbufferRespecify(RenderbufferObject& renderbuffer) {
|
||||
const MGPipeHandle handle = AcquireRenderbuffer(renderbuffer.GetLifetimeId());
|
||||
Entry& entry = EntryFor(m_renderbuffers, handle);
|
||||
const MGPResourceDesc desc = MGPipeBuildRenderbufferResourceDesc(renderbuffer, handle,
|
||||
entry.BindMask,
|
||||
/*storageDefined=*/true);
|
||||
const MGPResourceDesc desc = MGPipeBuildRenderbufferResourceDesc(renderbuffer, handle, entry.BindMask,
|
||||
/*storageDefined=*/true);
|
||||
if (entry.HasLastDesc && std::memcmp(&entry.LastDesc, &desc, sizeof(desc)) == 0) return;
|
||||
if (!MGPipeHandleIsPublished(MGPipeKind::Renderbuffer, handle)) {
|
||||
const MGPResourceDesc createDesc = MGPipeBuildRenderbufferResourceDesc(
|
||||
renderbuffer, handle, entry.BindMask, /*storageDefined=*/false);
|
||||
const MGPResourceDesc createDesc =
|
||||
MGPipeBuildRenderbufferResourceDesc(renderbuffer, handle, entry.BindMask, /*storageDefined=*/false);
|
||||
NoteDesc(createDesc, /*isCreate=*/true);
|
||||
PublishCreate(MGPipeKind::Renderbuffer, handle, entry, createDesc);
|
||||
}
|
||||
@@ -1042,8 +1029,8 @@ namespace MobileGL::MG_Pipe {
|
||||
if (m_draining) return;
|
||||
const MGPipeHandle handle = AcquireTexture(texture.GetLifetimeId(), &texture);
|
||||
Entry& entry = EntryFor(m_textures, handle);
|
||||
const Uint32 key = PackLevelKey(static_cast<MobileGL::TextureUploadTarget>(uploadTarget),
|
||||
static_cast<Uint>(level));
|
||||
const Uint32 key =
|
||||
PackLevelKey(static_cast<MobileGL::TextureUploadTarget>(uploadTarget), static_cast<Uint>(level));
|
||||
for (const Uint32 present : entry.DrainKeys) {
|
||||
if (present == key) return;
|
||||
}
|
||||
@@ -1263,8 +1250,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// (D-I1, c0b): MGPipeHandleIsPublished is what the death helper reads, so latching on
|
||||
// a call the applier refused would emit a resource_destroy for a record that does not
|
||||
// exist - a refused call the applier asserts on in a verify build.
|
||||
void PublishCreate(MGPipeKind kind, MGPipeHandle handle, Entry& entry,
|
||||
const MGPResourceDesc& desc) {
|
||||
void PublishCreate(MGPipeKind kind, MGPipeHandle handle, Entry& entry, const MGPResourceDesc& desc) {
|
||||
Bool accepted = false;
|
||||
Bool dispatched = false;
|
||||
if constexpr (MGPipeTextureRecordsReachTheApplier()) {
|
||||
@@ -1303,9 +1289,9 @@ namespace MobileGL::MG_Pipe {
|
||||
Bool accepted = ApplyRespecify(desc, key);
|
||||
if constexpr (MGPipeTextureRecordsReachTheApplier()) {
|
||||
if (!accepted) {
|
||||
const MGPResourceDesc healDesc = MGPipeBuildTextureResourceDesc(
|
||||
texture, handle, entry.BindMask, /*storageDefined=*/false, viewOf, bufferHandle,
|
||||
bufOffset, bufSize);
|
||||
const MGPResourceDesc healDesc =
|
||||
MGPipeBuildTextureResourceDesc(texture, handle, entry.BindMask, /*storageDefined=*/false,
|
||||
viewOf, bufferHandle, bufOffset, bufSize);
|
||||
NoteDesc(healDesc, /*isCreate=*/true);
|
||||
PublishCreate(MGPipeKind::Texture, handle, entry, healDesc);
|
||||
accepted = ApplyRespecify(desc, key);
|
||||
@@ -1390,15 +1376,16 @@ namespace MobileGL::MG_Pipe {
|
||||
// and a piece clips each to its slab.
|
||||
mipmap->GetStorageDirtyFootprint(uploadTarget, level, m_footprint);
|
||||
m_rectBoxes.clear();
|
||||
const Bool wholeLevelWrite =
|
||||
m_footprint.size() == 1 && m_footprint.front().lo.x() <= 0 && m_footprint.front().lo.y() <= 0 &&
|
||||
m_footprint.front().lo.z() <= 0 && m_footprint.front().hi.x() >= levelSize.x() &&
|
||||
m_footprint.front().hi.y() >= levelSize.y() &&
|
||||
m_footprint.front().hi.z() >= std::max<Int>(levelSize.z(), 1);
|
||||
const Bool wholeLevelWrite = m_footprint.size() == 1 && m_footprint.front().lo.x() <= 0 &&
|
||||
m_footprint.front().lo.y() <= 0 && m_footprint.front().lo.z() <= 0 &&
|
||||
m_footprint.front().hi.x() >= levelSize.x() &&
|
||||
m_footprint.front().hi.y() >= levelSize.y() &&
|
||||
m_footprint.front().hi.z() >= std::max<Int>(levelSize.z(), 1);
|
||||
if (wholeLevelWrite) {
|
||||
// The box is the story.
|
||||
} else if (m_footprint.size() <= static_cast<SizeT>(kMGPipeMaxPendingUploadRegions)) {
|
||||
for (const auto& box : m_footprint) m_rectBoxes.push_back(MGPipeBoxOfDirtyRegion(box));
|
||||
for (const auto& box : m_footprint)
|
||||
m_rectBoxes.push_back(MGPipeBoxOfDirtyRegion(box));
|
||||
} else {
|
||||
MGLOG_W_ONCE("MGPipe: texture {slot=%u, gen=%u} level %u has %zu disjoint dirty boxes, more than one "
|
||||
"record carries (%u); it goes out as the storage's rect list, which covers the writes "
|
||||
@@ -1406,9 +1393,10 @@ namespace MobileGL::MG_Pipe {
|
||||
pending.Handle.Slot, pending.Handle.Gen, static_cast<Uint>(level), m_footprint.size(),
|
||||
kMGPipeMaxPendingUploadRegions);
|
||||
MG_State::GLState::MipmapDirtyRegion rects[MG_State::GLState::MipmapStorage::kMaxDirtyRects];
|
||||
const SizeT coverCount = mipmap->GetStorageDirtyRects(
|
||||
uploadTarget, level, rects, MG_State::GLState::MipmapStorage::kMaxDirtyRects);
|
||||
for (SizeT i = 0; i < coverCount; ++i) m_rectBoxes.push_back(MGPipeBoxOfDirtyRegion(rects[i]));
|
||||
const SizeT coverCount = mipmap->GetStorageDirtyRects(uploadTarget, level, rects,
|
||||
MG_State::GLState::MipmapStorage::kMaxDirtyRects);
|
||||
for (SizeT i = 0; i < coverCount; ++i)
|
||||
m_rectBoxes.push_back(MGPipeBoxOfDirtyRegion(rects[i]));
|
||||
}
|
||||
const SizeT rectCount = m_rectBoxes.size();
|
||||
const MGPBox* rectBoxes = m_rectBoxes.data();
|
||||
@@ -1468,9 +1456,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// is: "the bytes this record declares ARE the level shadow". For a piece that
|
||||
// is the piece's own run of it, and the regions' SrcOffsets index into exactly
|
||||
// that run.
|
||||
pieceAccepted = MGPipeRouteResourceSubData(
|
||||
m_lastSubData, run, runBytes,
|
||||
m_regions.empty() ? nullptr : m_regions.data());
|
||||
pieceAccepted = MGPipeRouteResourceSubData(m_lastSubData, run, runBytes,
|
||||
m_regions.empty() ? nullptr : m_regions.data());
|
||||
} else {
|
||||
(void)run;
|
||||
(void)runBytes;
|
||||
@@ -1496,14 +1483,13 @@ namespace MobileGL::MG_Pipe {
|
||||
// One slot per rect plus one for a piece no rect reaches, which is the
|
||||
// most MGPipeBuildSlabRegions can write.
|
||||
m_regions.assign(std::max<SizeT>(rectCount, 1), MGPSubRegion{});
|
||||
const SizeT pieceRegions = MGPipeBuildSlabRegions(
|
||||
rectBoxes, rectCount, slab, pitch, m_regions.data(), m_regions.size());
|
||||
const SizeT pieceRegions = MGPipeBuildSlabRegions(rectBoxes, rectCount, slab, pitch,
|
||||
m_regions.data(), m_regions.size());
|
||||
m_regions.resize(pieceRegions);
|
||||
fillRecord(slab.Box,
|
||||
static_cast<Uint64>(reinterpret_cast<std::uintptr_t>(shadow)) +
|
||||
slab.RunOffset);
|
||||
const Bool pieceAccepted = emitRecord(
|
||||
static_cast<const Uint8*>(shadow) + slab.RunOffset, slab.RunBytes);
|
||||
static_cast<Uint64>(reinterpret_cast<std::uintptr_t>(shadow)) + slab.RunOffset);
|
||||
const Bool pieceAccepted =
|
||||
emitRecord(static_cast<const Uint8*>(shadow) + slab.RunOffset, slab.RunBytes);
|
||||
accepted = accepted && pieceAccepted;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,21 +38,21 @@ namespace MobileGL::MG_Pipe {
|
||||
// ---- value class: NEW_VERTEX_ELEMENTS is emitted from P3a and the other three from
|
||||
// P4a - the program family, one subsystem, three bits because the frontend moves them
|
||||
// as three separate events ----
|
||||
NewVertexElements, // the bound VAO's attribute configuration -> create/bind_vertex_elements
|
||||
NewShader, // the current program's link version -> create/bind_shader_state,
|
||||
// set_draw_program, set_dispatch_program (P4a)
|
||||
NewShaderBindings, // image units, block bindings, uniform write set (P4a)
|
||||
NewGlobalConstants, // the default-uniform-block image -> set_global_constants (P4a)
|
||||
NewVertexElements, // the bound VAO's attribute configuration -> create/bind_vertex_elements
|
||||
NewShader, // the current program's link version -> create/bind_shader_state,
|
||||
// set_draw_program, set_dispatch_program (P4a)
|
||||
NewShaderBindings, // image units, block bindings, uniform write set (P4a)
|
||||
NewGlobalConstants, // the default-uniform-block image -> set_global_constants (P4a)
|
||||
// ---- object class. THE FIRST TWO ARE P3a's, not P3b/P4b's: the roadmap puts
|
||||
// set_vertex_buffers and set_index_buffer in the same phase as the vertex-elements
|
||||
// trio, and this comment said otherwise until the commit that wired them. THE NEXT
|
||||
// FOUR ARE P4a's. The last three are still computed and counted only, until P4b. ----
|
||||
NewVertexBuffers, // -> set_vertex_buffers (P3a)
|
||||
NewIndexBuffer, // -> set_index_buffer (P3a)
|
||||
NewFramebuffer, // -> set_framebuffer_state, per bound target (P4a)
|
||||
NewSamplerViews, // -> set_sampler_views (P4a)
|
||||
NewSamplers, // -> bind_sampler_states (P4a)
|
||||
NewShaderImages, // -> set_shader_images (P4a)
|
||||
NewVertexBuffers, // -> set_vertex_buffers (P3a)
|
||||
NewIndexBuffer, // -> set_index_buffer (P3a)
|
||||
NewFramebuffer, // -> set_framebuffer_state, per bound target (P4a)
|
||||
NewSamplerViews, // -> set_sampler_views (P4a)
|
||||
NewSamplers, // -> bind_sampler_states (P4a)
|
||||
NewShaderImages, // -> set_shader_images (P4a)
|
||||
NewConstBuffers,
|
||||
NewShaderBuffers,
|
||||
NewSoTargets,
|
||||
@@ -90,8 +90,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// new shutters - and it is also why the two narrowings below are stated as requirements.
|
||||
inline constexpr Uint32 kMGPipeDirtyEmittedAtP4a =
|
||||
kMGPipeDirtyEmittedAtP3a | MGPipeDirtyBit(MGPipeDirty::NewShader) |
|
||||
MGPipeDirtyBit(MGPipeDirty::NewShaderBindings) |
|
||||
MGPipeDirtyBit(MGPipeDirty::NewGlobalConstants) |
|
||||
MGPipeDirtyBit(MGPipeDirty::NewShaderBindings) | MGPipeDirtyBit(MGPipeDirty::NewGlobalConstants) |
|
||||
MGPipeDirtyBit(MGPipeDirty::NewFramebuffer) | MGPipeDirtyBit(MGPipeDirty::NewSamplerViews) |
|
||||
MGPipeDirtyBit(MGPipeDirty::NewSamplers) | MGPipeDirtyBit(MGPipeDirty::NewShaderImages);
|
||||
|
||||
@@ -109,24 +108,11 @@ namespace MobileGL::MG_Pipe {
|
||||
MGPipeDirtyBit(MGPipeDirty::NewShaderBuffers) | MGPipeDirtyBit(MGPipeDirty::NewSoTargets);
|
||||
|
||||
inline constexpr const char* kMGPipeDirtyNames[kMGPipeDirtyCount] = {
|
||||
"NEW_RENDER_STATE",
|
||||
"NEW_PIPELINE_STATE",
|
||||
"NEW_PIXEL_PACK",
|
||||
"NEW_PATCH_STATE",
|
||||
"NEW_VERTEX_ATTRIB_DEFAULTS",
|
||||
"NEW_VERTEX_ELEMENTS",
|
||||
"NEW_SHADER",
|
||||
"NEW_SHADER_BINDINGS",
|
||||
"NEW_GLOBAL_CONSTANTS",
|
||||
"NEW_VERTEX_BUFFERS",
|
||||
"NEW_INDEX_BUFFER",
|
||||
"NEW_FRAMEBUFFER",
|
||||
"NEW_SAMPLER_VIEWS",
|
||||
"NEW_SAMPLERS",
|
||||
"NEW_SHADER_IMAGES",
|
||||
"NEW_CONST_BUFFERS",
|
||||
"NEW_SHADER_BUFFERS",
|
||||
"NEW_SO_TARGETS",
|
||||
"NEW_RENDER_STATE", "NEW_PIPELINE_STATE", "NEW_PIXEL_PACK", "NEW_PATCH_STATE",
|
||||
"NEW_VERTEX_ATTRIB_DEFAULTS", "NEW_VERTEX_ELEMENTS", "NEW_SHADER", "NEW_SHADER_BINDINGS",
|
||||
"NEW_GLOBAL_CONSTANTS", "NEW_VERTEX_BUFFERS", "NEW_INDEX_BUFFER", "NEW_FRAMEBUFFER",
|
||||
"NEW_SAMPLER_VIEWS", "NEW_SAMPLERS", "NEW_SHADER_IMAGES", "NEW_CONST_BUFFERS",
|
||||
"NEW_SHADER_BUFFERS", "NEW_SO_TARGETS",
|
||||
};
|
||||
|
||||
// Which runtime MOBILEGL_PIPE_PUSH subsystem bit gates a dirty bit's emission. Zero for
|
||||
@@ -290,8 +276,7 @@ namespace MobileGL::MG_Pipe {
|
||||
const Uint64 vaoLifetime = vao ? vao->GetLifetimeId() : 0;
|
||||
const Uint32 vaoConfig = vao ? vao->GetConfigVersion() : 0;
|
||||
const Bool vaoChanged = !m_primed || vaoLifetime != m_lastVaoLifetime || vaoConfig != m_lastVaoConfig;
|
||||
const Uint64 vaoIdentity =
|
||||
vao ? MGPipeMixShutter(vaoLifetime, vaoConfig) : 0;
|
||||
const Uint64 vaoIdentity = vao ? MGPipeMixShutter(vaoLifetime, vaoConfig) : 0;
|
||||
now[Index(MGPipeDirty::NewVertexElements)] = vaoIdentity;
|
||||
|
||||
// Reads plain version counters, never GetProgramForDraw(): that joins a pending
|
||||
@@ -321,11 +306,10 @@ namespace MobileGL::MG_Pipe {
|
||||
Uint64 opaqueUnits = 0;
|
||||
if (program) {
|
||||
shader = MGPipeMixShutter(program->GetLifetimeId(), program->GetLinkVersion());
|
||||
bindings = MGPipeMixShutter(
|
||||
MGPipeMixShutter(MGPipeMixShutter(program->GetImageUnitVersion(),
|
||||
program->GetBackendStateVersion()),
|
||||
program->GetBlockBindingVersion()),
|
||||
program->GetUniformWriteSetVersion());
|
||||
bindings = MGPipeMixShutter(MGPipeMixShutter(MGPipeMixShutter(program->GetImageUnitVersion(),
|
||||
program->GetBackendStateVersion()),
|
||||
program->GetBlockBindingVersion()),
|
||||
program->GetUniformWriteSetVersion());
|
||||
constants = MGPipeMixShutter(program->GetLifetimeId(), program->GetUBOContentVersion());
|
||||
// THE IDENTITY IS MIXED IN (P4a fable seam F-2), exactly as the pipeline arm
|
||||
// below mixes stageLinks into its half: the counter alone is a per-program
|
||||
@@ -378,12 +362,12 @@ namespace MobileGL::MG_Pipe {
|
||||
for (SizeT stage = 0; stage < Pipeline::kGraphicsStageCount; ++stage) {
|
||||
const auto& staged = pipeline->GetStageProgram(static_cast<ShaderStage>(stage));
|
||||
if (!staged) continue;
|
||||
stageLinks = MGPipeMixShutter(
|
||||
MGPipeMixShutter(stageLinks, staged->GetLifetimeId()), staged->GetLinkVersion());
|
||||
stageLinks = MGPipeMixShutter(MGPipeMixShutter(stageLinks, staged->GetLifetimeId()),
|
||||
staged->GetLinkVersion());
|
||||
stageState = MGPipeMixShutter(
|
||||
MGPipeMixShutter(MGPipeMixShutter(stageState, staged->GetBackendStateVersion()),
|
||||
MGPipeMixShutter(staged->GetUBOContentVersion(),
|
||||
staged->GetBlockBindingVersion())),
|
||||
MGPipeMixShutter(
|
||||
MGPipeMixShutter(stageState, staged->GetBackendStateVersion()),
|
||||
MGPipeMixShutter(staged->GetUBOContentVersion(), staged->GetBlockBindingVersion())),
|
||||
staged->GetUniformWriteSetVersion());
|
||||
stageImages = MGPipeMixShutter(stageImages, staged->GetImageUnitVersion());
|
||||
stageOpaque = MGPipeMixShutter(stageOpaque, staged->GetBackendStateVersion());
|
||||
@@ -458,10 +442,8 @@ namespace MobileGL::MG_Pipe {
|
||||
now[Index(MGPipeDirty::NewFramebuffer)] = MGPipeMixShutter(
|
||||
MGPipeMixShutter(
|
||||
ctx.GetAnyFramebufferAttachmentGeneration(),
|
||||
m_framebufferBind.Observe(
|
||||
ctx.GetFramebufferBindingSlot(FramebufferTarget::Draw).GetVersion())),
|
||||
m_readFramebufferBind.Observe(
|
||||
ctx.GetFramebufferBindingSlot(FramebufferTarget::Read).GetVersion()));
|
||||
m_framebufferBind.Observe(ctx.GetFramebufferBindingSlot(FramebufferTarget::Draw).GetVersion())),
|
||||
m_readFramebufferBind.Observe(ctx.GetFramebufferBindingSlot(FramebufferTarget::Read).GetVersion()));
|
||||
// Bit 12 reads FOUR things (F-1): the two texture aggregates, the bind generation
|
||||
// and the program input computed above. The params aggregate is here because
|
||||
// SamplerEmit.h drops a unit's view to null when SamplesAsIncompleteTexture says so,
|
||||
@@ -480,11 +462,10 @@ namespace MobileGL::MG_Pipe {
|
||||
// the extra fires are absorbed by the emitter's set-hash suppressor. A missed fire
|
||||
// here means wrong filtering, since bind_sampler_states has no pulled fallback.
|
||||
now[Index(MGPipeDirty::NewSamplers)] = MGPipeMixShutter(
|
||||
MGPipeMixShutter(textureParams, ctx.GetSamplingResolutionGeneration()),
|
||||
ctx.GetTextureBindGeneration());
|
||||
now[Index(MGPipeDirty::NewShaderImages)] = MGPipeMixShutter(
|
||||
MGPipeMixShutter(MGPipeMixShutter(textureContent, textureParams), programImages),
|
||||
ctx.GetTextureBindGeneration());
|
||||
MGPipeMixShutter(textureParams, ctx.GetSamplingResolutionGeneration()), ctx.GetTextureBindGeneration());
|
||||
now[Index(MGPipeDirty::NewShaderImages)] =
|
||||
MGPipeMixShutter(MGPipeMixShutter(MGPipeMixShutter(textureContent, textureParams), programImages),
|
||||
ctx.GetTextureBindGeneration());
|
||||
// Bits 15-17 read the buffer bind-point generations that glBindBufferBase/Range move
|
||||
// (BufferState::NoteBindPointChanged), not the buffer content aggregate: the records
|
||||
// carry {handle, offset, size}, a base binding's size travels as kMGPipeWholeBuffer
|
||||
@@ -493,14 +474,14 @@ namespace MobileGL::MG_Pipe {
|
||||
// indexed by the program's block bindings. Bit 16 covers storage and atomic-counter
|
||||
// points, which are emitted together. Bit 17 adds the transform-feedback generation
|
||||
// (capture points latch at Begin) and has no emitter.
|
||||
now[Index(MGPipeDirty::NewConstBuffers)] = MGPipeMixShutter(
|
||||
ctx.GetBufferBindPointGeneration(BufferTarget::Uniform), shader);
|
||||
now[Index(MGPipeDirty::NewShaderBuffers)] = MGPipeMixShutter(
|
||||
ctx.GetBufferBindPointGeneration(BufferTarget::ShaderStorage),
|
||||
ctx.GetBufferBindPointGeneration(BufferTarget::AtomicCounter));
|
||||
now[Index(MGPipeDirty::NewSoTargets)] = MGPipeMixShutter(
|
||||
ctx.GetBufferBindPointGeneration(BufferTarget::TransformFeedback),
|
||||
ctx.GetTransformFeedbackGeneration());
|
||||
now[Index(MGPipeDirty::NewConstBuffers)] =
|
||||
MGPipeMixShutter(ctx.GetBufferBindPointGeneration(BufferTarget::Uniform), shader);
|
||||
now[Index(MGPipeDirty::NewShaderBuffers)] =
|
||||
MGPipeMixShutter(ctx.GetBufferBindPointGeneration(BufferTarget::ShaderStorage),
|
||||
ctx.GetBufferBindPointGeneration(BufferTarget::AtomicCounter));
|
||||
now[Index(MGPipeDirty::NewSoTargets)] =
|
||||
MGPipeMixShutter(ctx.GetBufferBindPointGeneration(BufferTarget::TransformFeedback),
|
||||
ctx.GetTransformFeedbackGeneration());
|
||||
|
||||
Uint32 dirty = 0;
|
||||
for (SizeT i = 0; i < kMGPipeDirtyCount; ++i) {
|
||||
@@ -520,8 +501,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// own emitters still suppress unchanged records.
|
||||
if (vaoChanged) {
|
||||
dirty |= MGPipeDirtyBit(MGPipeDirty::NewVertexElements) |
|
||||
MGPipeDirtyBit(MGPipeDirty::NewVertexBuffers) |
|
||||
MGPipeDirtyBit(MGPipeDirty::NewIndexBuffer);
|
||||
MGPipeDirtyBit(MGPipeDirty::NewVertexBuffers) | MGPipeDirtyBit(MGPipeDirty::NewIndexBuffer);
|
||||
}
|
||||
m_lastVaoLifetime = vaoLifetime;
|
||||
m_lastVaoConfig = vaoConfig;
|
||||
@@ -530,8 +510,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// must still publish that new prefix, including its null samplers.
|
||||
const Int maxTextureUnit = ctx.GetMaxTouchedTextureUnit();
|
||||
if (!m_primed || maxTextureUnit != m_lastMaxTextureUnit) {
|
||||
dirty |= MGPipeDirtyBit(MGPipeDirty::NewSamplerViews) |
|
||||
MGPipeDirtyBit(MGPipeDirty::NewSamplers);
|
||||
dirty |= MGPipeDirtyBit(MGPipeDirty::NewSamplerViews) | MGPipeDirtyBit(MGPipeDirty::NewSamplers);
|
||||
}
|
||||
m_lastMaxTextureUnit = maxTextureUnit;
|
||||
|
||||
@@ -560,8 +539,8 @@ namespace MobileGL::MG_Pipe {
|
||||
dirty |= MGPipeDirtyBit(MGPipeDirty::NewFramebuffer);
|
||||
}
|
||||
if (content || params) {
|
||||
dirty |= MGPipeDirtyBit(MGPipeDirty::NewSamplerViews) |
|
||||
MGPipeDirtyBit(MGPipeDirty::NewShaderImages);
|
||||
dirty |=
|
||||
MGPipeDirtyBit(MGPipeDirty::NewSamplerViews) | MGPipeDirtyBit(MGPipeDirty::NewShaderImages);
|
||||
}
|
||||
if (params || clocks.SamplingResolution != m_lastSharedClocks.SamplingResolution) {
|
||||
dirty |= MGPipeDirtyBit(MGPipeDirty::NewSamplers);
|
||||
@@ -582,8 +561,10 @@ namespace MobileGL::MG_Pipe {
|
||||
// which is the whole reason this is a byte compare.
|
||||
PatchTrio patch{};
|
||||
patch.PatchVertices = render.PatchVertices;
|
||||
for (SizeT i = 0; i < 4; ++i) patch.Outer[i] = render.PatchDefaultOuterLevel[i];
|
||||
for (SizeT i = 0; i < 2; ++i) patch.Inner[i] = render.PatchDefaultInnerLevel[i];
|
||||
for (SizeT i = 0; i < 4; ++i)
|
||||
patch.Outer[i] = render.PatchDefaultOuterLevel[i];
|
||||
for (SizeT i = 0; i < 2; ++i)
|
||||
patch.Inner[i] = render.PatchDefaultInnerLevel[i];
|
||||
if (!m_primed || std::memcmp(&patch, &m_patch, sizeof(patch)) != 0) {
|
||||
dirty |= MGPipeDirtyBit(MGPipeDirty::NewPatchState);
|
||||
m_patch = patch;
|
||||
@@ -650,15 +631,15 @@ namespace MobileGL::MG_Pipe {
|
||||
}
|
||||
Uint64 FireCount(MGPipeDirty bit) const {
|
||||
Uint64 total = 0;
|
||||
for (SizeT i = 0; i < kMGPipeVerbClassCount; ++i) total += m_fires[Index(bit)][i];
|
||||
for (SizeT i = 0; i < kMGPipeVerbClassCount; ++i)
|
||||
total += m_fires[Index(bit)][i];
|
||||
return total;
|
||||
}
|
||||
Uint64 WalkCount(MGPipeVerbClass verbClass) const {
|
||||
return m_walks[static_cast<SizeT>(verbClass)];
|
||||
}
|
||||
Uint64 WalkCount(MGPipeVerbClass verbClass) const { return m_walks[static_cast<SizeT>(verbClass)]; }
|
||||
Uint64 WalkCount() const {
|
||||
Uint64 total = 0;
|
||||
for (SizeT i = 0; i < kMGPipeVerbClassCount; ++i) total += m_walks[i];
|
||||
for (SizeT i = 0; i < kMGPipeVerbClassCount; ++i)
|
||||
total += m_walks[i];
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -758,16 +739,13 @@ namespace MobileGL::MG_Pipe {
|
||||
// each view from its own array; ValueClass is the record of which view the application
|
||||
// wrote directly, kept for the comparator and for readers - the applier no longer needs
|
||||
// it to rebuild anything.
|
||||
inline void MGPipeFillAttribValue(Uint32 location,
|
||||
const MG_State::GLState::CurrentVertexAttributeValue& value,
|
||||
inline void MGPipeFillAttribValue(Uint32 location, const MG_State::GLState::CurrentVertexAttributeValue& value,
|
||||
Uint32 writtenClass, MGPAttribValue& out) {
|
||||
out = MGPAttribValue{};
|
||||
out.Location = location;
|
||||
out.ValueClass = static_cast<Uint8>(writtenClass);
|
||||
static_assert(sizeof(out.FloatView) == sizeof(value.floatValue),
|
||||
"MGPAttribValue's views are four words each");
|
||||
static_assert(sizeof(out.IntView) == sizeof(value.intValue) &&
|
||||
sizeof(out.UintView) == sizeof(value.uintValue),
|
||||
static_assert(sizeof(out.FloatView) == sizeof(value.floatValue), "MGPAttribValue's views are four words each");
|
||||
static_assert(sizeof(out.IntView) == sizeof(value.intValue) && sizeof(out.UintView) == sizeof(value.uintValue),
|
||||
"MGPAttribValue's views are four words each");
|
||||
std::memcpy(out.FloatView, value.floatValue.data(), sizeof(out.FloatView));
|
||||
std::memcpy(out.IntView, value.intValue.data(), sizeof(out.IntView));
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
namespace MobileGL::MG_Record {
|
||||
|
||||
using MG_State::GLState::BufferObject;
|
||||
using MobileGL::BufferTarget;
|
||||
using MG_State::GLState::ImageTextureBinding;
|
||||
using MobileGL::BufferTarget;
|
||||
|
||||
namespace {
|
||||
// Per-row tallies. Diagnostics, and the only thing a unit case can assert on: an
|
||||
@@ -37,10 +37,9 @@ namespace MobileGL::MG_Record {
|
||||
const auto& program = context->GetTransformFeedbackProgram();
|
||||
if (program == nullptr) return;
|
||||
const SizeT declared = program->GetTransformFeedbackBufferCount();
|
||||
const SizeT count =
|
||||
declared < MG_State::GLState::GLContext::MAX_TRANSFORM_FEEDBACK_BUFFERS
|
||||
? declared
|
||||
: static_cast<SizeT>(MG_State::GLState::GLContext::MAX_TRANSFORM_FEEDBACK_BUFFERS);
|
||||
const SizeT count = declared < MG_State::GLState::GLContext::MAX_TRANSFORM_FEEDBACK_BUFFERS
|
||||
? declared
|
||||
: static_cast<SizeT>(MG_State::GLState::GLContext::MAX_TRANSFORM_FEEDBACK_BUFFERS);
|
||||
for (SizeT i = 0; i < count; ++i) {
|
||||
const auto& point =
|
||||
context->GetBufferBindingPoint(BufferTarget::TransformFeedback, static_cast<Uint>(i));
|
||||
|
||||
@@ -95,8 +95,7 @@ namespace MobileGL::MG_Record {
|
||||
// The one place a row actually marks. Null and duplicate marks are absorbed here so the
|
||||
// walks stay readable, and the per-row counter moves only when a buffer really was
|
||||
// marked.
|
||||
void MarkBufferForProducer(const SharedPtr<MG_State::GLState::BufferObject>& buffer,
|
||||
GpuWriteProducer producer);
|
||||
void MarkBufferForProducer(const SharedPtr<MG_State::GLState::BufferObject>& buffer, GpuWriteProducer producer);
|
||||
|
||||
Uint64 ProducerMarkCount(GpuWriteProducer producer);
|
||||
void ResetProducerMarkCountsForTest();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,9 +26,9 @@ namespace MobileGL::MG_Record {
|
||||
// it. Only MG_Remote implements it; a library without a transport never resolves one.
|
||||
class VerbSession {
|
||||
public:
|
||||
virtual Uint64 EmitAndWait(MG_Pipe::MGPWireOp op, const void* payload, Uint64 payloadBytes,
|
||||
const void* varTail, Uint64 varTailBytes, void* replyOut, Uint64 replyBytes,
|
||||
Int32* statusOut, Uint64* replySizeOut) = 0;
|
||||
virtual Uint64 EmitAndWait(MG_Pipe::MGPWireOp op, const void* payload, Uint64 payloadBytes, const void* varTail,
|
||||
Uint64 varTailBytes, void* replyOut, Uint64 replyBytes, Int32* statusOut,
|
||||
Uint64* replySizeOut) = 0;
|
||||
virtual Uint64 EmitAndWaitTails(MG_Pipe::MGPWireOp op, const void* payload, Uint64 payloadBytes,
|
||||
const MG_Pipe::MGPipeVerbTail* tails, Uint32 tailCount, void* replyOut,
|
||||
Uint64 replyBytes, Int32* statusOut, Uint64* replySizeOut) = 0;
|
||||
@@ -111,9 +111,8 @@ namespace MobileGL::MG_Record {
|
||||
// same reason as the refusal above: the control drives the function the emitter calls
|
||||
// rather than a second copy of GL 4.6 8.4.4's arithmetic. THE GAPS ARE NEVER WRITTEN -
|
||||
// they belong to the application - and that is what the control checks with a sentinel.
|
||||
void ScatterTightReadbackIntoPackState(const void* tight, void* destination, GLsizei width,
|
||||
GLsizei height, Uint64 bytesPerPixel,
|
||||
const PixelStoreParameters& pack);
|
||||
void ScatterTightReadbackIntoPackState(const void* tight, void* destination, GLsizei width, GLsizei height,
|
||||
Uint64 bytesPerPixel, const PixelStoreParameters& pack);
|
||||
|
||||
// A glReadPixels whose tight answer exceeds one reply slot is split into bands, each an
|
||||
// ordinary read_pixels record with its own box and tight DstSize, scattered under the
|
||||
@@ -136,14 +135,12 @@ namespace MobileGL::MG_Record {
|
||||
Bool PlanReadbackBands(Uint64 width, Uint64 height, Uint64 bytesPerPixel, Uint64 maxReplyBytes,
|
||||
ReadbackBandPlan& plan);
|
||||
template <typename Visit>
|
||||
void ForEachReadbackBand(Uint64 width, Uint64 height, const ReadbackBandPlan& plan,
|
||||
Visit&& visit) {
|
||||
void ForEachReadbackBand(Uint64 width, Uint64 height, const ReadbackBandPlan& plan, Visit&& visit) {
|
||||
if (plan.RowsPerBand == 0 || plan.ColumnsPerBand == 0) return;
|
||||
for (Uint64 row = 0; row < height; row += plan.RowsPerBand) {
|
||||
const Uint64 rows = plan.RowsPerBand < height - row ? plan.RowsPerBand : height - row;
|
||||
for (Uint64 column = 0; column < width; column += plan.ColumnsPerBand) {
|
||||
const Uint64 columns =
|
||||
plan.ColumnsPerBand < width - column ? plan.ColumnsPerBand : width - column;
|
||||
const Uint64 columns = plan.ColumnsPerBand < width - column ? plan.ColumnsPerBand : width - column;
|
||||
visit(ReadbackBand{row, rows, column, columns});
|
||||
}
|
||||
}
|
||||
@@ -153,17 +150,15 @@ namespace MobileGL::MG_Record {
|
||||
// where ScatterTightReadbackIntoPackState would have put those pixels of the whole
|
||||
// `width`-wide read. ScatterTightReadbackIntoPackState is this function over the single band
|
||||
// {0, height, 0, width}, so the whole-read arithmetic and the banded one cannot drift.
|
||||
void ScatterReadbackBandIntoPackState(const void* band, void* destination, GLsizei width,
|
||||
const ReadbackBand& where, Uint64 bytesPerPixel,
|
||||
const PixelStoreParameters& pack);
|
||||
void ScatterReadbackBandIntoPackState(const void* band, void* destination, GLsizei width, const ReadbackBand& where,
|
||||
Uint64 bytesPerPixel, const PixelStoreParameters& pack);
|
||||
|
||||
// ID-49. True when the destination layout IS the tight layout, which is the only condition
|
||||
// under which EmitReadPixels may read the reply straight into the application pointer and
|
||||
// skip the bounce. Exported because the FAST PATH and the SCATTER have to agree, and the
|
||||
// only honest way to state that is to drive both and compare - a case that tested either
|
||||
// alone would pass a predicate that said yes to a layout the scatter would have rearranged.
|
||||
Bool ReadbackPackStateIsTightForTest(GLsizei width, Uint64 bytesPerPixel,
|
||||
const PixelStoreParameters& pack);
|
||||
Bool ReadbackPackStateIsTightForTest(GLsizei width, Uint64 bytesPerPixel, const PixelStoreParameters& pack);
|
||||
|
||||
// M2 / codex 11. True exactly when the readback reply is OK and carries the read's own exact
|
||||
// extent (CONTRACT-P5 row 23). EmitReadPixels calls this and Fatals by name when it is false
|
||||
@@ -218,23 +213,22 @@ namespace MobileGL::MG_Record {
|
||||
// non-instanced entry point) and `baseInstance` its gl_BaseInstance value; the sink reads
|
||||
// "instanced" as InstanceCount != 1 || StartInstance != 0, so an instanced call with a
|
||||
// count of 1 and no base instance is dispatched as the plain draw it is equivalent to.
|
||||
MG_Pipe::MGPDrawInfo PlanDrawInfo(GLenum mode, Uint8 indexSize, GLsizei instanceCount,
|
||||
GLuint baseInstance, Uint32 numDraws,
|
||||
const RemoteDrawBindings& bindings);
|
||||
MG_Pipe::MGPDrawInfo PlanDrawInfo(GLenum mode, Uint8 indexSize, GLsizei instanceCount, GLuint baseInstance,
|
||||
Uint32 numDraws, const RemoteDrawBindings& bindings);
|
||||
|
||||
// One MGPDrawRange from one (first | indices, count, basevertex). Arrays: Start = first.
|
||||
// Indexed with an element buffer bound: Start = offset / IndexSize, and FALSE when the byte
|
||||
// offset is not a whole number of indices or does not fit the record's Uint32 Start - the
|
||||
// caller refuses by name rather than round. Indexed with no element buffer: Start = 0 and
|
||||
// the bytes are the client's (the emitter stages `count * IndexSize` of them).
|
||||
Bool PlanDrawRange(const RemoteDrawBindings& bindings, Uint8 indexSize, const void* indicesOrFirst,
|
||||
GLsizei count, GLint baseVertex, MG_Pipe::MGPDrawRange& out);
|
||||
Bool PlanDrawRange(const RemoteDrawBindings& bindings, Uint8 indexSize, const void* indicesOrFirst, GLsizei count,
|
||||
GLint baseVertex, MG_Pipe::MGPDrawRange& out);
|
||||
|
||||
// The kDrawIsIndirect second tail: the bound GL_DRAW_INDIRECT_BUFFER handle, the call's
|
||||
// `indirect` byte offset, the stride and the draw count; for the *IndirectCount forms the
|
||||
// bound GL_PARAMETER_BUFFER handle and the byte offset the call spells as `drawcount`.
|
||||
MG_Pipe::MGPDrawIndirect PlanDrawIndirect(const RemoteDrawBindings& bindings, const void* indirect,
|
||||
GLsizei drawCount, GLsizei stride,
|
||||
GLintptr parameterOffset, Bool hasParameterBuffer);
|
||||
GLsizei drawCount, GLsizei stride, GLintptr parameterOffset,
|
||||
Bool hasParameterBuffer);
|
||||
|
||||
} // namespace MobileGL::MG_Record
|
||||
|
||||
@@ -52,8 +52,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// 32-slot bound is its invariant, not this one's, so a BindingIndex of 256 would wrap
|
||||
// to 0 and silently point every attribute at binding 0, and a negative Stride (the
|
||||
// frontend field is a signed int) would arrive as a ~4 GiB unsigned distance.
|
||||
MOBILEGL_ASSERT(bindingIndex < 256u,
|
||||
"MGPVertexAttribWire::BindingIndex is a Uint8 and cannot carry %u",
|
||||
MOBILEGL_ASSERT(bindingIndex < 256u, "MGPVertexAttribWire::BindingIndex is a Uint8 and cannot carry %u",
|
||||
static_cast<Uint>(bindingIndex));
|
||||
MOBILEGL_ASSERT(attrib.Size >= 0 && attrib.Size <= 255,
|
||||
"MGPVertexAttribWire::Size is a Uint8 and cannot carry %d", attrib.Size);
|
||||
@@ -73,8 +72,8 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
// The ARB_vertex_attrib_binding view. Its initial Stride is 16, not 0 (GL 4.6 core table
|
||||
// 23.4), which is why the wire form keeps it signed and copies it verbatim.
|
||||
inline MGPVertexBindingPointWire
|
||||
MGPipeBuildVertexBindingPointWire(const MG_State::GLState::VertexBufferBindingPoint& point) {
|
||||
inline MGPVertexBindingPointWire MGPipeBuildVertexBindingPointWire(
|
||||
const MG_State::GLState::VertexBufferBindingPoint& point) {
|
||||
MGPVertexBindingPointWire wire{};
|
||||
wire.Offset = static_cast<Uint64>(point.Offset);
|
||||
wire.Stride = static_cast<Int32>(point.Stride);
|
||||
@@ -153,8 +152,8 @@ namespace MobileGL::MG_Pipe {
|
||||
Latch& latch = m_latch[slot];
|
||||
|
||||
Uint64 bytes = 0;
|
||||
const Bool configMoved = !latch.Published || latch.ConfigVersion != configVersion ||
|
||||
latch.Gen != handle.Gen;
|
||||
const Bool configMoved =
|
||||
!latch.Published || latch.ConfigVersion != configVersion || latch.Gen != handle.Gen;
|
||||
if (configMoved) {
|
||||
BuildBlob(*vao);
|
||||
// P15: the version moves on every glBindVertexBuffer, but the record only names
|
||||
@@ -185,8 +184,10 @@ namespace MobileGL::MG_Pipe {
|
||||
// MGPipeVertexElementsRecord). The mirror below says what that is; where it does
|
||||
// not know, the next set goes out whatever it hashes to.
|
||||
auto& suppressor = MGPipeSetHashSuppressorInstance();
|
||||
if (memo.StoredBuffersValid) suppressor.Latch(MGPipeSuppressorSlot::SetVertexBuffers, memo.StoredBuffersHash);
|
||||
else suppressor.Invalidate(MGPipeSuppressorSlot::SetVertexBuffers);
|
||||
if (memo.StoredBuffersValid)
|
||||
suppressor.Latch(MGPipeSuppressorSlot::SetVertexBuffers, memo.StoredBuffersHash);
|
||||
else
|
||||
suppressor.Invalidate(MGPipeSuppressorSlot::SetVertexBuffers);
|
||||
m_serverIndexKnown = memo.StoredIndexValid;
|
||||
m_serverIndexRes = memo.StoredIndexRes;
|
||||
}
|
||||
@@ -203,7 +204,7 @@ namespace MobileGL::MG_Pipe {
|
||||
// fetches at draw emission and calls this again with ownedClientBuffers.
|
||||
// Monolith keeps its existing backend-side client-array upload.
|
||||
Uint64 EmitVertexBuffers(GLContext& ctx, Uint32 baseInstance,
|
||||
const Array<MGPipeHandle, kMGPipeMaxVertexAttribs>* ownedClientBuffers = nullptr) {
|
||||
const Array<MGPipeHandle, kMGPipeMaxVertexAttribs>* ownedClientBuffers = nullptr) {
|
||||
const auto& vao = ctx.GetBoundVertexArray();
|
||||
Uint32 count = 0;
|
||||
// The resolved set is a function of the VAO's configuration alone (buffers, strides,
|
||||
@@ -240,8 +241,8 @@ namespace MobileGL::MG_Pipe {
|
||||
entry.Res = lastHandle;
|
||||
} else {
|
||||
entry.Res = attrib.Buffer ? MGPipeSlots().AcquireHinted(MGPipeKind::Buffer,
|
||||
attrib.Buffer->GetLifetimeId(),
|
||||
attrib.Buffer->PipeHandleHint())
|
||||
attrib.Buffer->GetLifetimeId(),
|
||||
attrib.Buffer->PipeHandleHint())
|
||||
: kMGPipeNullHandle;
|
||||
if (attrib.Buffer) {
|
||||
lastBuffer = attrib.Buffer.get();
|
||||
@@ -274,7 +275,8 @@ namespace MobileGL::MG_Pipe {
|
||||
memo->BuffersValid = memoizable && count <= kVaoMemoBuffers;
|
||||
memo->ConfigVersion = vao->GetConfigVersion();
|
||||
memo->BufferCount = count;
|
||||
for (SizeT i = 0; i < count && i < kVaoMemoBuffers; ++i) memo->Buffers[i] = m_entries[i];
|
||||
for (SizeT i = 0; i < count && i < kVaoMemoBuffers; ++i)
|
||||
memo->Buffers[i] = m_entries[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,7 +495,8 @@ namespace MobileGL::MG_Pipe {
|
||||
if (m_vaoMemo.empty() || (m_vaoMemoUsed + 1) * 2 > m_vaoMemo.size()) GrowVaoMemo();
|
||||
const SizeT mask = m_vaoMemo.size() - 1;
|
||||
SizeT i = VaoMemoHome(lifetimeId, mask);
|
||||
while (m_vaoMemo[i].LifetimeId != 0 && m_vaoMemo[i].LifetimeId != lifetimeId) i = (i + 1) & mask;
|
||||
while (m_vaoMemo[i].LifetimeId != 0 && m_vaoMemo[i].LifetimeId != lifetimeId)
|
||||
i = (i + 1) & mask;
|
||||
VaoMemo& memo = m_vaoMemo[i];
|
||||
m_lastMemoIndex = i;
|
||||
if (memo.LifetimeId == 0) ++m_vaoMemoUsed;
|
||||
@@ -516,7 +519,8 @@ namespace MobileGL::MG_Pipe {
|
||||
for (const VaoMemo& entry : old) {
|
||||
if (entry.LifetimeId == 0) continue;
|
||||
SizeT i = VaoMemoHome(entry.LifetimeId, mask);
|
||||
while (m_vaoMemo[i].LifetimeId != 0) i = (i + 1) & mask;
|
||||
while (m_vaoMemo[i].LifetimeId != 0)
|
||||
i = (i + 1) & mask;
|
||||
m_vaoMemo[i] = entry;
|
||||
++m_vaoMemoUsed;
|
||||
}
|
||||
@@ -551,7 +555,6 @@ namespace MobileGL::MG_Pipe {
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct Latch {
|
||||
// The PER-CONTEXT half: "has this emitter told THIS server about this handle's
|
||||
// configuration". Cleared by Reset() at every make-current.
|
||||
@@ -627,7 +630,7 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
Array<MGPVertexAttribWire, kMGPipeMaxVertexAttribs> m_attributes{};
|
||||
Array<MGPVertexBindingPointWire, kMGPipeMaxVertexAttribs> m_bindingPoints{};
|
||||
Array<Uint8, kMGPipeMaxVertexAttribs *(sizeof(MGPVertexAttribWire) + sizeof(MGPVertexBindingPointWire))>
|
||||
Array<Uint8, kMGPipeMaxVertexAttribs * (sizeof(MGPVertexAttribWire) + sizeof(MGPVertexBindingPointWire))>
|
||||
m_blob{};
|
||||
Array<MGPVertexBuffer, kMGPipeMaxVertexAttribs> m_entries{};
|
||||
|
||||
|
||||
@@ -70,9 +70,11 @@ MOBILEGL_EXPORT int mobilegl_shared_image_formats(uint32_t* formats, uint32_t ca
|
||||
if (total < capacity) formats[total] = format;
|
||||
++total;
|
||||
};
|
||||
for (uint32_t format : kRgbFormats) put(format);
|
||||
for (uint32_t format : kRgbFormats)
|
||||
put(format);
|
||||
if (ActiveBackend(true) != nullptr && MobileGL::MG_Impl::EGLImpl::SharedImageYuvAvailable()) {
|
||||
for (uint32_t format : kYuvFormats) put(format);
|
||||
for (uint32_t format : kYuvFormats)
|
||||
put(format);
|
||||
}
|
||||
return static_cast<int>(total);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* 2: YUV images (NV12, P010), the plane-1 fields of mobilegl_shared_image, and
|
||||
@@ -55,73 +56,73 @@ extern "C" {
|
||||
#define MOBILEGL_SHARED_IMAGE_FOURCC_NV12 0x3231564Eu /* 'NV12' */
|
||||
#define MOBILEGL_SHARED_IMAGE_FOURCC_P010 0x30313050u /* 'P010' */
|
||||
|
||||
/* One allocated image. VERSIONED BY SIZE: the caller sets struct_size to the sizeof it was built
|
||||
* against and the library writes no byte past it, so fields are only ever appended. */
|
||||
struct mobilegl_shared_image {
|
||||
uint32_t struct_size;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t fourcc;
|
||||
uint64_t id; /* the server's name for the image; pass to release */
|
||||
int32_t fd; /* the exported dma-buf, owned by the caller; -1 on failure */
|
||||
uint32_t stride; /* plane 0, bytes */
|
||||
uint32_t offset; /* plane 0, bytes */
|
||||
uint32_t reserved; /* zero */
|
||||
uint64_t modifier; /* DRM format modifier of the layout (DRM_FORMAT_MOD_INVALID today) */
|
||||
/* ABI 2: a YUV image's plane 1 (same fd); zero for the one-plane formats. */
|
||||
uint32_t plane1_stride;
|
||||
uint32_t plane1_offset;
|
||||
};
|
||||
/* One allocated image. VERSIONED BY SIZE: the caller sets struct_size to the sizeof it was built
|
||||
* against and the library writes no byte past it, so fields are only ever appended. */
|
||||
struct mobilegl_shared_image {
|
||||
uint32_t struct_size;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t fourcc;
|
||||
uint64_t id; /* the server's name for the image; pass to release */
|
||||
int32_t fd; /* the exported dma-buf, owned by the caller; -1 on failure */
|
||||
uint32_t stride; /* plane 0, bytes */
|
||||
uint32_t offset; /* plane 0, bytes */
|
||||
uint32_t reserved; /* zero */
|
||||
uint64_t modifier; /* DRM format modifier of the layout (DRM_FORMAT_MOD_INVALID today) */
|
||||
/* ABI 2: a YUV image's plane 1 (same fd); zero for the one-plane formats. */
|
||||
uint32_t plane1_stride;
|
||||
uint32_t plane1_offset;
|
||||
};
|
||||
|
||||
/* Where an imported two-plane buffer's planes are (ABI 2). */
|
||||
struct mobilegl_shared_image_planes {
|
||||
uint32_t struct_size;
|
||||
uint32_t plane_count; /* 2 */
|
||||
uint32_t offset[2];
|
||||
uint32_t pitch[2];
|
||||
uint64_t modifier; /* DRM_FORMAT_MOD_INVALID when none was given */
|
||||
};
|
||||
/* Where an imported two-plane buffer's planes are (ABI 2). */
|
||||
struct mobilegl_shared_image_planes {
|
||||
uint32_t struct_size;
|
||||
uint32_t plane_count; /* 2 */
|
||||
uint32_t offset[2];
|
||||
uint32_t pitch[2];
|
||||
uint64_t modifier; /* DRM_FORMAT_MOD_INVALID when none was given */
|
||||
};
|
||||
|
||||
/* MOBILEGL_SHARED_IMAGE_ABI_VERSION of the library. */
|
||||
uint32_t mobilegl_shared_image_abi_version(void);
|
||||
/* MOBILEGL_SHARED_IMAGE_ABI_VERSION of the library. */
|
||||
uint32_t mobilegl_shared_image_abi_version(void);
|
||||
|
||||
/* The fourccs images can be allocated in. Writes min(capacity, total) entries and returns the
|
||||
* total (formats may be null when capacity is 0). */
|
||||
int mobilegl_shared_image_formats(uint32_t* formats, uint32_t capacity);
|
||||
/* The fourccs images can be allocated in. Writes min(capacity, total) entries and returns the
|
||||
* total (formats may be null when capacity is 0). */
|
||||
int mobilegl_shared_image_formats(uint32_t* formats, uint32_t capacity);
|
||||
|
||||
/* A new width x height image. Brings the process's MobileGL client session up if no EGL/GLX entry
|
||||
* point has yet (exactly as the first eglGetDisplay would). */
|
||||
int mobilegl_shared_image_allocate(uint32_t width, uint32_t height, uint32_t fourcc,
|
||||
struct mobilegl_shared_image* out);
|
||||
/* A new width x height image. Brings the process's MobileGL client session up if no EGL/GLX entry
|
||||
* point has yet (exactly as the first eglGetDisplay would). */
|
||||
int mobilegl_shared_image_allocate(uint32_t width, uint32_t height, uint32_t fourcc,
|
||||
struct mobilegl_shared_image* out);
|
||||
|
||||
/* Names the image `fd` was exported from (the caller keeps `fd`), taking a reference to it.
|
||||
* -EIO: not one of the server's images, or the size/format disagree. */
|
||||
int mobilegl_shared_image_import(int fd, uint32_t width, uint32_t height, uint32_t fourcc, uint64_t* out_id);
|
||||
/* Names the image `fd` was exported from (the caller keeps `fd`), taking a reference to it.
|
||||
* -EIO: not one of the server's images, or the size/format disagree. */
|
||||
int mobilegl_shared_image_import(int fd, uint32_t width, uint32_t height, uint32_t fourcc, uint64_t* out_id);
|
||||
|
||||
/* The same for a YUV fourcc whose two planes are in `fd` as `planes` says (ABI 2). A YUV buffer the
|
||||
* server did not allocate is taken too, read through the server's CPU-copy fallback. */
|
||||
int mobilegl_shared_image_import_planes(int fd, uint32_t width, uint32_t height, uint32_t fourcc,
|
||||
const struct mobilegl_shared_image_planes* planes, uint64_t* out_id);
|
||||
/* The same for a YUV fourcc whose two planes are in `fd` as `planes` says (ABI 2). A YUV buffer the
|
||||
* server did not allocate is taken too, read through the server's CPU-copy fallback. */
|
||||
int mobilegl_shared_image_import_planes(int fd, uint32_t width, uint32_t height, uint32_t fourcc,
|
||||
const struct mobilegl_shared_image_planes* planes, uint64_t* out_id);
|
||||
|
||||
/* Drops this process's reference (an allocation's or an import's). */
|
||||
int mobilegl_shared_image_release(uint64_t id);
|
||||
/* Drops this process's reference (an allocation's or an import's). */
|
||||
int mobilegl_shared_image_release(uint64_t id);
|
||||
|
||||
/* 1 when this process can be served: its session is up, or the server it is configured to dial
|
||||
* answers (one bounded non-blocking connect, cached once true); 0 when not. Never brings the
|
||||
* session up. A component that a system loader picked on MobileGL's behalf (the GBM backend) asks
|
||||
* this first and declines, so the loader moves on to another implementation. Optional: a library
|
||||
* without it is assumed available. */
|
||||
int mobilegl_server_available(void);
|
||||
/* 1 when this process can be served: its session is up, or the server it is configured to dial
|
||||
* answers (one bounded non-blocking connect, cached once true); 0 when not. Never brings the
|
||||
* session up. A component that a system loader picked on MobileGL's behalf (the GBM backend) asks
|
||||
* this first and declines, so the loader moves on to another implementation. Optional: a library
|
||||
* without it is assumed available. */
|
||||
int mobilegl_server_available(void);
|
||||
|
||||
/* dlsym-friendly signatures. */
|
||||
typedef int (*PFN_mobilegl_server_available)(void);
|
||||
typedef uint32_t (*PFN_mobilegl_shared_image_abi_version)(void);
|
||||
typedef int (*PFN_mobilegl_shared_image_formats)(uint32_t*, uint32_t);
|
||||
typedef int (*PFN_mobilegl_shared_image_allocate)(uint32_t, uint32_t, uint32_t, struct mobilegl_shared_image*);
|
||||
typedef int (*PFN_mobilegl_shared_image_import)(int, uint32_t, uint32_t, uint32_t, uint64_t*);
|
||||
typedef int (*PFN_mobilegl_shared_image_release)(uint64_t);
|
||||
typedef int (*PFN_mobilegl_shared_image_import_planes)(int, uint32_t, uint32_t, uint32_t,
|
||||
const struct mobilegl_shared_image_planes*, uint64_t*);
|
||||
/* dlsym-friendly signatures. */
|
||||
typedef int (*PFN_mobilegl_server_available)(void);
|
||||
typedef uint32_t (*PFN_mobilegl_shared_image_abi_version)(void);
|
||||
typedef int (*PFN_mobilegl_shared_image_formats)(uint32_t*, uint32_t);
|
||||
typedef int (*PFN_mobilegl_shared_image_allocate)(uint32_t, uint32_t, uint32_t, struct mobilegl_shared_image*);
|
||||
typedef int (*PFN_mobilegl_shared_image_import)(int, uint32_t, uint32_t, uint32_t, uint64_t*);
|
||||
typedef int (*PFN_mobilegl_shared_image_release)(uint64_t);
|
||||
typedef int (*PFN_mobilegl_shared_image_import_planes)(int, uint32_t, uint32_t, uint32_t,
|
||||
const struct mobilegl_shared_image_planes*, uint64_t*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ extern "C" int WINAPI wglChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR*
|
||||
return WGL::ChoosePixelFormat(hdc, ppfd);
|
||||
}
|
||||
|
||||
extern "C" int WINAPI wglDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes,
|
||||
LPPIXELFORMATDESCRIPTOR ppfd) {
|
||||
extern "C" int WINAPI wglDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd) {
|
||||
return WGL::DescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd);
|
||||
}
|
||||
|
||||
@@ -141,14 +140,12 @@ extern "C" BOOL WINAPI wglUseFontBitmapsW(HDC, DWORD, DWORD, DWORD) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
extern "C" BOOL WINAPI wglUseFontOutlinesA(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int,
|
||||
LPGLYPHMETRICSFLOAT) {
|
||||
extern "C" BOOL WINAPI wglUseFontOutlinesA(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT) {
|
||||
MGLOG_W_ONCE("wglUseFontOutlinesA is not supported");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
extern "C" BOOL WINAPI wglUseFontOutlinesW(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int,
|
||||
LPGLYPHMETRICSFLOAT) {
|
||||
extern "C" BOOL WINAPI wglUseFontOutlinesW(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT) {
|
||||
MGLOG_W_ONCE("wglUseFontOutlinesW is not supported");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -197,8 +197,8 @@ namespace MobileGL::MG_Impl::WGLImpl {
|
||||
if (width == surface.Width && height == surface.Height) {
|
||||
return;
|
||||
}
|
||||
if (EGLImpl::ResizePlatformWindowSurface(surface.Display, surface.Surface,
|
||||
static_cast<EGLint>(width), static_cast<EGLint>(height))) {
|
||||
if (EGLImpl::ResizePlatformWindowSurface(surface.Display, surface.Surface, static_cast<EGLint>(width),
|
||||
static_cast<EGLint>(height))) {
|
||||
surface.Width = width;
|
||||
surface.Height = height;
|
||||
}
|
||||
@@ -220,12 +220,9 @@ namespace MobileGL::MG_Impl::WGLImpl {
|
||||
}
|
||||
|
||||
const EGLAttrib attribs[] = {
|
||||
EGL_WIDTH, static_cast<EGLAttrib>(width),
|
||||
EGL_HEIGHT, static_cast<EGLAttrib>(height),
|
||||
EGL_NONE,
|
||||
EGL_WIDTH, static_cast<EGLAttrib>(width), EGL_HEIGHT, static_cast<EGLAttrib>(height), EGL_NONE,
|
||||
};
|
||||
EGLSurface surface =
|
||||
EGLImpl::CreatePlatformWindowSurface(context.Display, context.Config, hwnd, attribs);
|
||||
EGLSurface surface = EGLImpl::CreatePlatformWindowSurface(context.Display, context.Config, hwnd, attribs);
|
||||
if (surface == EGL_NO_SURFACE) {
|
||||
MGLOG_E_ONCE("wgl: failed to create window surface for HWND %p (%ux%u)", hwnd, width, height);
|
||||
return nullptr;
|
||||
@@ -262,14 +259,22 @@ namespace MobileGL::MG_Impl::WGLImpl {
|
||||
HWND hwnd = WindowFromDC(hdc);
|
||||
const PixelFormatInfo& pixelFormat = PixelFormatForWindow(hwnd);
|
||||
const EGLint configAttribs[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, pixelFormat.AlphaBits,
|
||||
EGL_DEPTH_SIZE, pixelFormat.DepthBits,
|
||||
EGL_STENCIL_SIZE, pixelFormat.StencilBits,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_RED_SIZE,
|
||||
8,
|
||||
EGL_GREEN_SIZE,
|
||||
8,
|
||||
EGL_BLUE_SIZE,
|
||||
8,
|
||||
EGL_ALPHA_SIZE,
|
||||
pixelFormat.AlphaBits,
|
||||
EGL_DEPTH_SIZE,
|
||||
pixelFormat.DepthBits,
|
||||
EGL_STENCIL_SIZE,
|
||||
pixelFormat.StencilBits,
|
||||
EGL_SURFACE_TYPE,
|
||||
EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE,
|
||||
EGL_OPENGL_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
EGLConfig config = nullptr;
|
||||
@@ -345,15 +350,17 @@ namespace MobileGL::MG_Impl::WGLImpl {
|
||||
}
|
||||
}
|
||||
|
||||
if (major < 1 || (profileMask & ~(WGL_CONTEXT_CORE_PROFILE_BIT_ARB |
|
||||
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB))) {
|
||||
if (major < 1 ||
|
||||
(profileMask & ~(WGL_CONTEXT_CORE_PROFILE_BIT_ARB | WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB))) {
|
||||
SetLastError(profileMask ? ERROR_INVALID_PROFILE_ARB : ERROR_INVALID_VERSION_ARB);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vector<EGLint> attribs = {
|
||||
EGL_CONTEXT_MAJOR_VERSION, major,
|
||||
EGL_CONTEXT_MINOR_VERSION, minor,
|
||||
EGL_CONTEXT_MAJOR_VERSION,
|
||||
major,
|
||||
EGL_CONTEXT_MINOR_VERSION,
|
||||
minor,
|
||||
};
|
||||
const Bool wantsCompat = (profileMask & WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) != 0;
|
||||
if (major > 3 || (major == 3 && minor >= 2) || profileMask != 0) {
|
||||
@@ -625,9 +632,12 @@ namespace MobileGL::MG_Impl::WGLImpl {
|
||||
// A legacy WGL context is a compatibility-profile context; MobileGL keys
|
||||
// its relaxed-semantics mode off the explicit compatibility bit.
|
||||
const EGLint attribs[] = {
|
||||
EGL_CONTEXT_MAJOR_VERSION, 3,
|
||||
EGL_CONTEXT_MINOR_VERSION, 3,
|
||||
EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT,
|
||||
EGL_CONTEXT_MAJOR_VERSION,
|
||||
3,
|
||||
EGL_CONTEXT_MINOR_VERSION,
|
||||
3,
|
||||
EGL_CONTEXT_OPENGL_PROFILE_MASK,
|
||||
EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
return CreateContextFromEGLAttribs(hdc, nullptr, attribs);
|
||||
|
||||
Reference in New Issue
Block a user