Dingoonity.org

GCW Zero => Development => Topic started by: Harteex on September 21, 2014, 01:52:40 pm

Title: Render targets not supported on the Zero / Etnaviv?
Post by: Harteex on September 21, 2014, 01:52:40 pm
I'm trying to use render targets in SDL2 (SDL_TEXTUREACCESS_TARGET), but it doesn't seem to work.

I'm using the following test:
Code: [Select]
#include <iostream>
#include <SDL.h>

bool SDLInited = false;
SDL_Window *win = NULL;
SDL_Renderer *ren = NULL;

bool initializeSDL()
{
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
std::cout << "SDL_Init error: " << SDL_GetError() << std::endl;
return false;
}
SDLInited = true;

win = SDL_CreateWindow("testapp", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 240, SDL_WINDOW_SHOWN);
if (win == NULL)
{
std::cout << SDL_GetError() << std::endl;
return false;
}

ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE);
if (ren == NULL)
{
std::cout << SDL_GetError() << std::endl;
return false;
}

SDL_RendererInfo renInfo;
if (SDL_GetRendererInfo(ren, &renInfo) < 0)
{
std::cout << "Unablet to query renderer" << std::endl;
return false;
}

if ((renInfo.flags & SDL_RENDERER_TARGETTEXTURE) == 0)
{
std::cout << "Renderer does not support render targets" << std::endl;
return false;
}

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");

return true;
}

void terminateSDL()
{
if (ren != NULL)
{
SDL_DestroyRenderer(ren);
ren = NULL;
}

if (win != NULL)
{
SDL_DestroyWindow(win);
win = NULL;
}

if (SDLInited)
{
SDL_Quit();
SDLInited = false;
}
}

int main(int argc, char **argv)
{
std::cout << "main()" << std::endl;
std::cout << "Initializing SDL... " << std::endl;
if (!initializeSDL())
{
terminateSDL();
return 1;
}
std::cout << "SDL is init!!" << std::endl;

SDL_Texture* texture = SDL_CreateTexture(ren, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_TARGET, 64, 64);
if (texture == NULL)
{
  std::cout << "Texture creation failed: " << SDL_GetError() << std::endl;
  terminateSDL();
  return 1;
}

if (SDL_SetRenderTarget(ren, texture) < 0)
  std::cout << "SetRenderTarget FAILED: " << SDL_GetError() << std::endl;
else
  std::cout << "SetRenderTarget OK!" << std::endl;

SDL_SetRenderTarget(ren, NULL);

SDL_DestroyTexture(texture);

terminateSDL();
return 0;
}

which gives me the following through apitrace / eglretrace (thanks to JohnnyonFlame):
Code: [Select]
0 101 glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat = GL_RGBA, width = 64, height = 64, border = 0, format = GL_RGBA, type = GL_UNSIGNED_BYTE, pixels = NULL)
0 102 glGenFramebuffers(n = 1, framebuffers = &1)
0 103 glBindFramebuffer(target = GL_FRAMEBUFFER, framebuffer = 1)
0 104 glFramebufferTexture2D(target = GL_FRAMEBUFFER, attachment = GL_COLOR_ATTACHMENT0, textarget = GL_TEXTURE_2D, texture = 1, level = 0)
0 105 glCheckFramebufferStatus(target = GL_FRAMEBUFFER) = GL_FRAMEBUFFER_UNSUPPORTED

I have also tried setting different pixelformats on the SDL texture, but I don't think that's the problem.

Could there be a problem in etnaviv or something? or are rendertargets simply not supported at all?
Title: Re: Render targets not supported on the Zero / Etnaviv?
Post by: Pickle on September 22, 2014, 01:45:28 pm
Are you specifically requesting the gles 2.0 profile at some point?
Title: Re: Render targets not supported on the Zero / Etnaviv?
Post by: Harteex on September 23, 2014, 04:59:45 pm
I don't, but I assume SDL2 handled that, since I do get this printed in the output:
Kernel: Vivante GPL kernel driver 4.6.6.1381

And the error message I get from SDL2 comes from SDL_render_gles2.c