Commit c8eedebd by Nicolas Capens Committed by Nicolas Capens

Implement missing EGL surface queries.

Fixes dEQP-EGL.functional.query_surface.* tests. Change-Id: I9d0d2dee83140613af24471d350777959ee37565 Reviewed-on: https://swiftshader-review.googlesource.com/18488Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 59975335
...@@ -181,7 +181,7 @@ Config::Config(sw::Format displayFormat, EGLint minInterval, EGLint maxInterval, ...@@ -181,7 +181,7 @@ Config::Config(sw::Format displayFormat, EGLint minInterval, EGLint maxInterval,
mRenderableType = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT; mRenderableType = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT;
mSampleBuffers = (multiSample > 0) ? 1 : 0; mSampleBuffers = (multiSample > 0) ? 1 : 0;
mSamples = multiSample; mSamples = multiSample;
mSurfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; mSurfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT | EGL_MULTISAMPLE_RESOLVE_BOX_BIT;
mTransparentType = EGL_NONE; mTransparentType = EGL_NONE;
mTransparentRedValue = 0; mTransparentRedValue = 0;
mTransparentGreenValue = 0; mTransparentGreenValue = 0;
......
...@@ -183,14 +183,10 @@ bool Display::initialize() ...@@ -183,14 +183,10 @@ bool Display::initialize()
for(unsigned int samplesIndex = 0; samplesIndex < sizeof(samples) / sizeof(int); samplesIndex++) for(unsigned int samplesIndex = 0; samplesIndex < sizeof(samples) / sizeof(int); samplesIndex++)
{ {
for(unsigned int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(sw::Format); formatIndex++) for(sw::Format renderTargetFormat : renderTargetFormats)
{ {
sw::Format renderTargetFormat = renderTargetFormats[formatIndex]; for(sw::Format depthStencilFormat : depthStencilFormats)
for(unsigned int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(sw::Format); depthStencilIndex++)
{ {
sw::Format depthStencilFormat = depthStencilFormats[depthStencilIndex];
configSet.add(currentDisplayFormat, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, samples[samplesIndex]); configSet.add(currentDisplayFormat, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, samples[samplesIndex]);
} }
} }
...@@ -425,7 +421,8 @@ EGLSurface Display::createPBufferSurface(EGLConfig config, const EGLint *attribL ...@@ -425,7 +421,8 @@ EGLSurface Display::createPBufferSurface(EGLConfig config, const EGLint *attribL
case EGL_MIPMAP_TEXTURE: case EGL_MIPMAP_TEXTURE:
if(attribList[1] != EGL_FALSE) if(attribList[1] != EGL_FALSE)
{ {
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); UNIMPLEMENTED();
return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
} }
break; break;
case EGL_VG_COLORSPACE: case EGL_VG_COLORSPACE:
......
...@@ -51,24 +51,6 @@ namespace egl ...@@ -51,24 +51,6 @@ namespace egl
{ {
Surface::Surface(const Display *display, const Config *config) : display(display), config(config) Surface::Surface(const Display *display, const Config *config) : display(display), config(config)
{ {
backBuffer = nullptr;
depthStencil = nullptr;
texture = nullptr;
width = 0;
height = 0;
largestPBuffer = EGL_FALSE;
pixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio
renderBuffer = EGL_BACK_BUFFER;
swapBehavior = EGL_BUFFER_PRESERVED;
textureFormat = EGL_NO_TEXTURE;
textureTarget = EGL_NO_TEXTURE;
clientBufferFormat = EGL_NO_TEXTURE;
clientBufferType = EGL_NO_TEXTURE;
clientBuffer = nullptr;
clientBufferPlane = -1;
swapInterval = -1;
setSwapInterval(1);
} }
Surface::~Surface() Surface::~Surface()
...@@ -167,6 +149,16 @@ egl::Image *Surface::getDepthStencil() ...@@ -167,6 +149,16 @@ egl::Image *Surface::getDepthStencil()
return depthStencil; return depthStencil;
} }
void Surface::setMipmapLevel(EGLint mipmapLevel)
{
this->mipmapLevel = mipmapLevel;
}
void Surface::setMultisampleResolve(EGLenum multisampleResolve)
{
this->multisampleResolve = multisampleResolve;
}
void Surface::setSwapBehavior(EGLenum swapBehavior) void Surface::setSwapBehavior(EGLenum swapBehavior)
{ {
this->swapBehavior = swapBehavior; this->swapBehavior = swapBehavior;
...@@ -204,6 +196,16 @@ EGLint Surface::getHeight() const ...@@ -204,6 +196,16 @@ EGLint Surface::getHeight() const
return height; return height;
} }
EGLint Surface::getMipmapLevel() const
{
return mipmapLevel;
}
EGLenum Surface::getMultisampleResolve() const
{
return multisampleResolve;
}
EGLint Surface::getPixelAspectRatio() const EGLint Surface::getPixelAspectRatio() const
{ {
return pixelAspectRatio; return pixelAspectRatio;
...@@ -292,7 +294,7 @@ egl::Texture *Surface::getBoundTexture() const ...@@ -292,7 +294,7 @@ egl::Texture *Surface::getBoundTexture() const
WindowSurface::WindowSurface(Display *display, const Config *config, EGLNativeWindowType window) WindowSurface::WindowSurface(Display *display, const Config *config, EGLNativeWindowType window)
: Surface(display, config), window(window) : Surface(display, config), window(window)
{ {
frameBuffer = nullptr; pixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio
} }
WindowSurface::~WindowSurface() WindowSurface::~WindowSurface()
......
...@@ -40,6 +40,8 @@ public: ...@@ -40,6 +40,8 @@ public:
egl::Image *getRenderTarget() override; egl::Image *getRenderTarget() override;
egl::Image *getDepthStencil() override; egl::Image *getDepthStencil() override;
void setMipmapLevel(EGLint mipmapLevel);
void setMultisampleResolve(EGLenum multisampleResolve);
void setSwapBehavior(EGLenum swapBehavior); void setSwapBehavior(EGLenum swapBehavior);
void setSwapInterval(EGLint interval); void setSwapInterval(EGLint interval);
...@@ -49,6 +51,8 @@ public: ...@@ -49,6 +51,8 @@ public:
EGLint getWidth() const override; EGLint getWidth() const override;
EGLint getHeight() const override; EGLint getHeight() const override;
EGLenum getTextureTarget() const override; EGLenum getTextureTarget() const override;
virtual EGLint getMipmapLevel() const;
virtual EGLenum getMultisampleResolve() const;
virtual EGLint getPixelAspectRatio() const; virtual EGLint getPixelAspectRatio() const;
virtual EGLenum getRenderBuffer() const; virtual EGLenum getRenderBuffer() const;
virtual EGLenum getSwapBehavior() const; virtual EGLenum getSwapBehavior() const;
...@@ -73,33 +77,38 @@ protected: ...@@ -73,33 +77,38 @@ protected:
sw::Format getClientBufferFormat() const; sw::Format getClientBufferFormat() const;
const Display *const display; const Display *const display;
Image *depthStencil; const Config *const config;
Image *backBuffer;
Texture *texture; Image *depthStencil = nullptr;
Image *backBuffer = nullptr;
Texture *texture = nullptr;
bool reset(int backbufferWidth, int backbufferHeight); bool reset(int backbufferWidth, int backbufferHeight);
const Config *const config; // EGL config surface was created with // Surface attributes:
EGLint width; // Width of surface EGLint width = 0; // Width of surface
EGLint height; // Height of surface EGLint height= 0; // Height of surface
// EGLint horizontalResolution; // Horizontal dot pitch // EGLint horizontalResolution = EGL_UNKNOWN; // Horizontal dot pitch
// EGLint verticalResolution; // Vertical dot pitch // EGLint verticalResolution = EGL_UNKNOWN; // Vertical dot pitch
EGLBoolean largestPBuffer; // If true, create largest pbuffer possible EGLBoolean largestPBuffer = EGL_FALSE; // If true, create largest pbuffer possible
// EGLBoolean mipmapTexture; // True if texture has mipmaps // EGLBoolean mipmapTexture = EGL_FALSE; // True if texture has mipmaps
// EGLint mipmapLevel; // Mipmap level to render to EGLint mipmapLevel = 0; // Mipmap level to render to
// EGLenum multisampleResolve; // Multisample resolve behavior EGLenum multisampleResolve = EGL_MULTISAMPLE_RESOLVE_DEFAULT; // Multisample resolve behavior
EGLint pixelAspectRatio; // Display aspect ratio EGLint pixelAspectRatio = EGL_UNKNOWN; // Display aspect ratio
EGLenum renderBuffer; // Render buffer EGLenum renderBuffer = EGL_BACK_BUFFER; // Render buffer
EGLenum swapBehavior; // Buffer swap behavior EGLenum swapBehavior = EGL_BUFFER_PRESERVED; // Buffer swap behavior (initial value chosen by implementation)
EGLenum textureFormat; // Format of texture: RGB, RGBA, or no texture EGLenum textureFormat = EGL_NO_TEXTURE; // Format of texture: RGB, RGBA, or no texture
EGLenum textureTarget; // Type of texture: 2D or no texture EGLenum textureTarget = EGL_NO_TEXTURE; // Type of texture: 2D or no texture
// EGLenum vgAlphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE; // Alpha format for OpenVG
// EGLenum vgColorSpace = EGL_VG_COLORSPACE_sRGB; // Color space for OpenVG
EGLint swapInterval = 1;
// EGL_ANGLE_iosurface_client_buffer attributes:
EGLClientBuffer clientBuffer = nullptr;
EGLint clientBufferPlane;
EGLenum clientBufferFormat; // Format of the client buffer EGLenum clientBufferFormat; // Format of the client buffer
EGLenum clientBufferType; // Type of the client buffer EGLenum clientBufferType; // Type of the client buffer
// EGLenum vgAlphaFormat; // Alpha format for OpenVG
// EGLenum vgColorSpace; // Color space for OpenVG
EGLint swapInterval;
EGLClientBuffer clientBuffer;
EGLint clientBufferPlane;
}; };
class WindowSurface : public Surface class WindowSurface : public Surface
...@@ -121,7 +130,7 @@ private: ...@@ -121,7 +130,7 @@ private:
bool reset(int backBufferWidth, int backBufferHeight); bool reset(int backBufferWidth, int backBufferHeight);
const EGLNativeWindowType window; const EGLNativeWindowType window;
sw::FrameBuffer *frameBuffer; sw::FrameBuffer *frameBuffer = nullptr;
}; };
class PBufferSurface : public Surface class PBufferSurface : public Surface
......
...@@ -392,10 +392,10 @@ EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EG ...@@ -392,10 +392,10 @@ EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EG
switch(attribute) switch(attribute)
{ {
case EGL_VG_ALPHA_FORMAT: case EGL_VG_ALPHA_FORMAT:
UNIMPLEMENTED(); // FIXME *value = EGL_VG_ALPHA_FORMAT_NONPRE; // Default
break; break;
case EGL_VG_COLORSPACE: case EGL_VG_COLORSPACE:
UNIMPLEMENTED(); // FIXME *value = EGL_VG_COLORSPACE_sRGB; // Default
break; break;
case EGL_CONFIG_ID: case EGL_CONFIG_ID:
*value = eglSurface->getConfigID(); *value = eglSurface->getConfigID();
...@@ -404,7 +404,7 @@ EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EG ...@@ -404,7 +404,7 @@ EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EG
*value = eglSurface->getHeight(); *value = eglSurface->getHeight();
break; break;
case EGL_HORIZONTAL_RESOLUTION: case EGL_HORIZONTAL_RESOLUTION:
UNIMPLEMENTED(); // FIXME *value = EGL_UNKNOWN;
break; break;
case EGL_LARGEST_PBUFFER: case EGL_LARGEST_PBUFFER:
if(eglSurface->isPBufferSurface()) // For a window or pixmap surface, the contents of *value are not modified. if(eglSurface->isPBufferSurface()) // For a window or pixmap surface, the contents of *value are not modified.
...@@ -413,13 +413,19 @@ EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EG ...@@ -413,13 +413,19 @@ EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EG
} }
break; break;
case EGL_MIPMAP_TEXTURE: case EGL_MIPMAP_TEXTURE:
UNIMPLEMENTED(); // FIXME if(eglSurface->isPBufferSurface()) // For a window or pixmap surface, the contents of *value are not modified.
{
*value = EGL_FALSE; // UNIMPLEMENTED
}
break; break;
case EGL_MIPMAP_LEVEL: case EGL_MIPMAP_LEVEL:
UNIMPLEMENTED(); // FIXME if(eglSurface->isPBufferSurface()) // For a window or pixmap surface, the contents of *value are not modified.
{
*value = eglSurface->getMipmapLevel();
}
break; break;
case EGL_MULTISAMPLE_RESOLVE: case EGL_MULTISAMPLE_RESOLVE:
UNIMPLEMENTED(); // FIXME *value = eglSurface->getMultisampleResolve();
break; break;
case EGL_PIXEL_ASPECT_RATIO: case EGL_PIXEL_ASPECT_RATIO:
*value = eglSurface->getPixelAspectRatio(); *value = eglSurface->getPixelAspectRatio();
...@@ -431,13 +437,19 @@ EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EG ...@@ -431,13 +437,19 @@ EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EG
*value = eglSurface->getSwapBehavior(); *value = eglSurface->getSwapBehavior();
break; break;
case EGL_TEXTURE_FORMAT: case EGL_TEXTURE_FORMAT:
*value = eglSurface->getTextureFormat(); if(eglSurface->isPBufferSurface()) // For a window or pixmap surface, the contents of *value are not modified.
{
*value = eglSurface->getTextureFormat();
}
break; break;
case EGL_TEXTURE_TARGET: case EGL_TEXTURE_TARGET:
*value = eglSurface->getTextureTarget(); if(eglSurface->isPBufferSurface()) // For a window or pixmap surface, the contents of *value are not modified.
{
*value = eglSurface->getTextureTarget();
}
break; break;
case EGL_VERTICAL_RESOLUTION: case EGL_VERTICAL_RESOLUTION:
UNIMPLEMENTED(); // FIXME *value = EGL_UNKNOWN;
break; break;
case EGL_WIDTH: case EGL_WIDTH:
*value = eglSurface->getWidth(); *value = eglSurface->getWidth();
...@@ -544,22 +556,43 @@ EGLBoolean SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, E ...@@ -544,22 +556,43 @@ EGLBoolean SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, E
switch(attribute) switch(attribute)
{ {
case EGL_SWAP_BEHAVIOR: case EGL_MIPMAP_LEVEL:
if(value == EGL_BUFFER_PRESERVED) eglSurface->setMipmapLevel(value);
break;
case EGL_MULTISAMPLE_RESOLVE:
switch(value)
{ {
if(!(eglSurface->getSurfaceType() & EGL_SWAP_BEHAVIOR_PRESERVED_BIT)) case EGL_MULTISAMPLE_RESOLVE_DEFAULT:
break;
case EGL_MULTISAMPLE_RESOLVE_BOX:
if(!(eglSurface->getSurfaceType() & EGL_MULTISAMPLE_RESOLVE_BOX_BIT))
{ {
return error(EGL_BAD_MATCH, EGL_FALSE); return error(EGL_BAD_MATCH, EGL_FALSE);
} }
break;
default:
return error(EGL_BAD_PARAMETER, EGL_FALSE);
} }
else if(value != EGL_BUFFER_DESTROYED) eglSurface->setMultisampleResolve(value);
break;
case EGL_SWAP_BEHAVIOR:
switch(value)
{ {
case EGL_BUFFER_DESTROYED:
break;
case EGL_BUFFER_PRESERVED:
if(!(eglSurface->getSurfaceType() & EGL_SWAP_BEHAVIOR_PRESERVED_BIT))
{
return error(EGL_BAD_MATCH, EGL_FALSE);
}
break;
default:
return error(EGL_BAD_PARAMETER, EGL_FALSE); return error(EGL_BAD_PARAMETER, EGL_FALSE);
} }
eglSurface->setSwapBehavior(value); eglSurface->setSwapBehavior(value);
break; break;
default: default:
UNIMPLEMENTED(); // FIXME return error(EGL_BAD_PARAMETER, EGL_FALSE);
} }
return success(EGL_TRUE); return success(EGL_TRUE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment