Ian Waters
unread,Sep 29, 2023, 3:44:01 AM9/29/23Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to skia-discuss
Hi all,
I’m wondering if anyone could shed some light on why the following works on macOS, but not on Windows.
* I’ve removed all error checking for brevity.
* The context and target both look to create correctly (they pass validity tests).
* In the below m_msaaSamples is set to 4.
* The error comes with generating the Surface (SkSurface::MakeFromBackendRenderTarget), this just silently fails.
I would appreciate any tips 🫠
// glfw setup
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// … creating window/ making context current omitted.
// Configure Multisample Renderbuffer for color attachment
GLuint msaaColorRBO;
glGenRenderbuffers(1, &msaaColorRBO);
glBindRenderbuffer(GL_RENDERBUFFER, msaaColorRBO);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, m_msaaSamples, GL_RGBA8, width,
height);
// Configure depth and stencil buffers as an RBO
glGenRenderbuffers(1, &m_rbo);
glBindRenderbuffer(GL_RENDERBUFFER, m_rbo);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, m_msaaSamples,
GL_DEPTH24_STENCIL8, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
// Configure FBO
glGenFramebuffers(1, &m_fbo);
glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
msaaColorRBO);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
GL_RENDERBUFFER, m_rbo);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Configure color buffers as 2D Texture for resolving
glGenTextures(1, &m_tex2d);
glBindTexture(GL_TEXTURE_2D, m_tex2d);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
GL_UNSIGNED_INT_8_8_8_8, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
auto options = GrContextOptions();
options.fShaderErrorHandler = &gLogShaderErrorHandler;
options.fSuppressPrints = false;
options.fSkipGLErrorChecks = GrContextOptions::Enable::kNo;
m_context = GrDirectContext::MakeGL(options);
auto target = GrBackendRenderTarget(width, height, m_msaaSamples, 8, {m_fbo, GL_RGBA8});
glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
// This call silently fails
m_surface = SkSurface::MakeFromBackendRenderTarget(
m_context.get(),
target,
kBottomLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType,
nullptr,
nullptr);