Commit 80aa5592 by Olli Etuaho Committed by Commit Bot

Clean up TextureD3D_2DMultisample

This removes some duplicate unreachable calls from TextureD3D_External and TextureD3D_2DMultisample. There will be further use for this once TextureD3D_2DMultisampleArray is implemented. This also cleans up some no-ops from TextureD3D_2DMultisample and sets it correctly as immutable. BUG=angleproject:2775 TEST=angle_end2end_tests Change-Id: Ia253a1ed6f418a24bb0c4a4e61654b1c061dba97 Reviewed-on: https://chromium-review.googlesource.com/1193950Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent f0d0408a
...@@ -3450,27 +3450,22 @@ void TextureD3D_2DArray::markAllImagesDirty() ...@@ -3450,27 +3450,22 @@ void TextureD3D_2DArray::markAllImagesDirty()
mDirtyImages = true; mDirtyImages = true;
} }
TextureD3D_External::TextureD3D_External(const gl::TextureState &state, RendererD3D *renderer) TextureD3DImmutableBase::TextureD3DImmutableBase(const gl::TextureState &state,
RendererD3D *renderer)
: TextureD3D(state, renderer) : TextureD3D(state, renderer)
{ {
} }
TextureD3D_External::~TextureD3D_External() TextureD3DImmutableBase::~TextureD3DImmutableBase()
{ {
} }
ImageD3D *TextureD3D_External::getImage(const gl::ImageIndex &index) const ImageD3D *TextureD3DImmutableBase::getImage(const gl::ImageIndex &index) const
{ {
UNREACHABLE();
return nullptr; return nullptr;
} }
GLsizei TextureD3D_External::getLayerCount(int level) const gl::Error TextureD3DImmutableBase::setImage(const gl::Context *context,
{
return 1;
}
gl::Error TextureD3D_External::setImage(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
...@@ -3479,12 +3474,11 @@ gl::Error TextureD3D_External::setImage(const gl::Context *context, ...@@ -3479,12 +3474,11 @@ gl::Error TextureD3D_External::setImage(const gl::Context *context,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) const uint8_t *pixels)
{ {
// Image setting is not supported for external images
UNREACHABLE(); UNREACHABLE();
return gl::InternalError(); return gl::InternalError();
} }
gl::Error TextureD3D_External::setSubImage(const gl::Context *context, gl::Error TextureD3DImmutableBase::setSubImage(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
...@@ -3496,7 +3490,7 @@ gl::Error TextureD3D_External::setSubImage(const gl::Context *context, ...@@ -3496,7 +3490,7 @@ gl::Error TextureD3D_External::setSubImage(const gl::Context *context,
return gl::InternalError(); return gl::InternalError();
} }
gl::Error TextureD3D_External::setCompressedImage(const gl::Context *context, gl::Error TextureD3DImmutableBase::setCompressedImage(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
...@@ -3508,7 +3502,7 @@ gl::Error TextureD3D_External::setCompressedImage(const gl::Context *context, ...@@ -3508,7 +3502,7 @@ gl::Error TextureD3D_External::setCompressedImage(const gl::Context *context,
return gl::InternalError(); return gl::InternalError();
} }
gl::Error TextureD3D_External::setCompressedSubImage(const gl::Context *context, gl::Error TextureD3DImmutableBase::setCompressedSubImage(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
...@@ -3520,7 +3514,7 @@ gl::Error TextureD3D_External::setCompressedSubImage(const gl::Context *context, ...@@ -3520,7 +3514,7 @@ gl::Error TextureD3D_External::setCompressedSubImage(const gl::Context *context,
return gl::InternalError(); return gl::InternalError();
} }
gl::Error TextureD3D_External::copyImage(const gl::Context *context, gl::Error TextureD3DImmutableBase::copyImage(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
...@@ -3530,7 +3524,7 @@ gl::Error TextureD3D_External::copyImage(const gl::Context *context, ...@@ -3530,7 +3524,7 @@ gl::Error TextureD3D_External::copyImage(const gl::Context *context,
return gl::InternalError(); return gl::InternalError();
} }
gl::Error TextureD3D_External::copySubImage(const gl::Context *context, gl::Error TextureD3DImmutableBase::copySubImage(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
...@@ -3540,16 +3534,32 @@ gl::Error TextureD3D_External::copySubImage(const gl::Context *context, ...@@ -3540,16 +3534,32 @@ gl::Error TextureD3D_External::copySubImage(const gl::Context *context,
return gl::InternalError(); return gl::InternalError();
} }
gl::Error TextureD3D_External::setStorage(const gl::Context *context, gl::Error TextureD3DImmutableBase::bindTexImage(const gl::Context *context, egl::Surface *surface)
gl::TextureType type,
size_t levels,
GLenum internalFormat,
const gl::Extents &size)
{ {
UNREACHABLE(); UNREACHABLE();
return gl::InternalError(); return gl::InternalError();
} }
gl::Error TextureD3DImmutableBase::releaseTexImage(const gl::Context *context)
{
UNREACHABLE();
return gl::InternalError();
}
TextureD3D_External::TextureD3D_External(const gl::TextureState &state, RendererD3D *renderer)
: TextureD3DImmutableBase(state, renderer)
{
}
TextureD3D_External::~TextureD3D_External()
{
}
GLsizei TextureD3D_External::getLayerCount(int level) const
{
return 1;
}
gl::Error TextureD3D_External::setImageExternal(const gl::Context *context, gl::Error TextureD3D_External::setImageExternal(const gl::Context *context,
gl::TextureType type, gl::TextureType type,
egl::Stream *stream, egl::Stream *stream,
...@@ -3568,18 +3578,6 @@ gl::Error TextureD3D_External::setImageExternal(const gl::Context *context, ...@@ -3568,18 +3578,6 @@ gl::Error TextureD3D_External::setImageExternal(const gl::Context *context,
return gl::NoError(); return gl::NoError();
} }
gl::Error TextureD3D_External::bindTexImage(const gl::Context *context, egl::Surface *surface)
{
UNREACHABLE();
return gl::InternalError();
}
gl::Error TextureD3D_External::releaseTexImage(const gl::Context *context)
{
UNREACHABLE();
return gl::InternalError();
}
gl::Error TextureD3D_External::setEGLImageTarget(const gl::Context *context, gl::Error TextureD3D_External::setEGLImageTarget(const gl::Context *context,
gl::TextureType type, gl::TextureType type,
egl::Image *image) egl::Image *image)
...@@ -3668,7 +3666,7 @@ void TextureD3D_External::markAllImagesDirty() ...@@ -3668,7 +3666,7 @@ void TextureD3D_External::markAllImagesDirty()
TextureD3D_2DMultisample::TextureD3D_2DMultisample(const gl::TextureState &state, TextureD3D_2DMultisample::TextureD3D_2DMultisample(const gl::TextureState &state,
RendererD3D *renderer) RendererD3D *renderer)
: TextureD3D(state, renderer) : TextureD3DImmutableBase(state, renderer)
{ {
} }
...@@ -3676,80 +3674,6 @@ TextureD3D_2DMultisample::~TextureD3D_2DMultisample() ...@@ -3676,80 +3674,6 @@ TextureD3D_2DMultisample::~TextureD3D_2DMultisample()
{ {
} }
ImageD3D *TextureD3D_2DMultisample::getImage(const gl::ImageIndex &index) const
{
return nullptr;
}
gl::Error TextureD3D_2DMultisample::setImage(const gl::Context *context,
const gl::ImageIndex &index,
GLenum internalFormat,
const gl::Extents &size,
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
const uint8_t *pixels)
{
UNREACHABLE();
return gl::InternalError();
}
gl::Error TextureD3D_2DMultisample::setSubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Box &area,
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
const uint8_t *pixels)
{
UNREACHABLE();
return gl::InternalError();
}
gl::Error TextureD3D_2DMultisample::setCompressedImage(const gl::Context *context,
const gl::ImageIndex &index,
GLenum internalFormat,
const gl::Extents &size,
const gl::PixelUnpackState &unpack,
size_t imageSize,
const uint8_t *pixels)
{
UNREACHABLE();
return gl::InternalError();
}
gl::Error TextureD3D_2DMultisample::setCompressedSubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Box &area,
GLenum format,
const gl::PixelUnpackState &unpack,
size_t imageSize,
const uint8_t *pixels)
{
UNREACHABLE();
return gl::InternalError();
}
gl::Error TextureD3D_2DMultisample::copyImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Rectangle &sourceArea,
GLenum internalFormat,
gl::Framebuffer *source)
{
UNREACHABLE();
return gl::InternalError();
}
gl::Error TextureD3D_2DMultisample::copySubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Offset &destOffset,
const gl::Rectangle &sourceArea,
gl::Framebuffer *source)
{
UNREACHABLE();
return gl::InternalError();
}
gl::Error TextureD3D_2DMultisample::setStorageMultisample(const gl::Context *context, gl::Error TextureD3D_2DMultisample::setStorageMultisample(const gl::Context *context,
gl::TextureType type, gl::TextureType type,
GLsizei samples, GLsizei samples,
...@@ -3759,6 +3683,8 @@ gl::Error TextureD3D_2DMultisample::setStorageMultisample(const gl::Context *con ...@@ -3759,6 +3683,8 @@ gl::Error TextureD3D_2DMultisample::setStorageMultisample(const gl::Context *con
{ {
ASSERT(type == gl::TextureType::_2DMultisample && size.depth == 1); ASSERT(type == gl::TextureType::_2DMultisample && size.depth == 1);
// We allocate storage immediately instead of doing it lazily like other TextureD3D classes do.
// This requires less state in this class.
TexStoragePointer storage(context); TexStoragePointer storage(context);
storage.reset(mRenderer->createTextureStorage2DMultisample(internalFormat, size.width, storage.reset(mRenderer->createTextureStorage2DMultisample(internalFormat, size.width,
size.height, static_cast<int>(0), size.height, static_cast<int>(0),
...@@ -3767,22 +3693,8 @@ gl::Error TextureD3D_2DMultisample::setStorageMultisample(const gl::Context *con ...@@ -3767,22 +3693,8 @@ gl::Error TextureD3D_2DMultisample::setStorageMultisample(const gl::Context *con
ANGLE_TRY(setCompleteTexStorage(context, storage.get())); ANGLE_TRY(setCompleteTexStorage(context, storage.get()));
storage.release(); storage.release();
ANGLE_TRY(updateStorage(context)); mImmutable = true;
mImmutable = false;
return gl::NoError();
}
gl::Error TextureD3D_2DMultisample::bindTexImage(const gl::Context *context, egl::Surface *surface)
{
UNREACHABLE();
return gl::NoError();
}
gl::Error TextureD3D_2DMultisample::releaseTexImage(const gl::Context *context)
{
UNREACHABLE();
return gl::NoError(); return gl::NoError();
} }
...@@ -3834,42 +3746,26 @@ void TextureD3D_2DMultisample::markAllImagesDirty() ...@@ -3834,42 +3746,26 @@ void TextureD3D_2DMultisample::markAllImagesDirty()
angle::Result TextureD3D_2DMultisample::initializeStorage(const gl::Context *context, angle::Result TextureD3D_2DMultisample::initializeStorage(const gl::Context *context,
bool renderTarget) bool renderTarget)
{ {
// Only initialize the first time this texture is used as a render target or shader resource // initializeStorage should only be called in a situation where the texture already has storage
if (mTexStorage) // associated with it (storage is created in setStorageMultisample).
{
return angle::Result::Continue();
}
bool createRenderTarget = (renderTarget || IsRenderTargetUsage(mState.getUsage()));
TexStoragePointer storage(context);
ANGLE_TRY(createCompleteStorage(createRenderTarget, &storage));
ANGLE_TRY(setCompleteTexStorage(context, storage.get()));
storage.release();
ASSERT(mTexStorage); ASSERT(mTexStorage);
// flush image data to the storage
ANGLE_TRY(updateStorage(context));
return angle::Result::Continue(); return angle::Result::Continue();
} }
angle::Result TextureD3D_2DMultisample::createCompleteStorage(bool renderTarget, angle::Result TextureD3D_2DMultisample::createCompleteStorage(bool renderTarget,
TexStoragePointer *outStorage) const TexStoragePointer *outStorage) const
{ {
UNREACHABLE();
outStorage->reset(mTexStorage); outStorage->reset(mTexStorage);
return angle::Result::Continue(); return angle::Result::Continue();
} }
angle::Result TextureD3D_2DMultisample::setCompleteTexStorage(const gl::Context *context, angle::Result TextureD3D_2DMultisample::setCompleteTexStorage(const gl::Context *context,
TextureStorage *newCompleteTexStorage) TextureStorage *newCompleteTexStorage)
{ {
ANGLE_TRY(releaseTexStorage(context)); // These textures are immutable, so this should only be ever called once.
ASSERT(!mTexStorage);
mTexStorage = newCompleteTexStorage; mTexStorage = newCompleteTexStorage;
return angle::Result::Continue(); return angle::Result::Continue();
} }
...@@ -3880,7 +3776,7 @@ angle::Result TextureD3D_2DMultisample::updateStorage(const gl::Context *context ...@@ -3880,7 +3776,7 @@ angle::Result TextureD3D_2DMultisample::updateStorage(const gl::Context *context
angle::Result TextureD3D_2DMultisample::initMipmapImages(const gl::Context *context) angle::Result TextureD3D_2DMultisample::initMipmapImages(const gl::Context *context)
{ {
UNIMPLEMENTED(); UNREACHABLE();
return angle::Result::Continue(); return angle::Result::Continue();
} }
......
...@@ -663,15 +663,14 @@ class TextureD3D_2DArray : public TextureD3D ...@@ -663,15 +663,14 @@ class TextureD3D_2DArray : public TextureD3D
ImageD3D **mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; ImageD3D **mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
}; };
class TextureD3D_External : public TextureD3D // Base class for immutable textures. These don't support manipulation of individual texture images.
class TextureD3DImmutableBase : public TextureD3D
{ {
public: public:
TextureD3D_External(const gl::TextureState &data, RendererD3D *renderer); TextureD3DImmutableBase(const gl::TextureState &data, RendererD3D *renderer);
~TextureD3D_External() override; ~TextureD3DImmutableBase() override;
ImageD3D *getImage(const gl::ImageIndex &index) const override; ImageD3D *getImage(const gl::ImageIndex &index) const override;
GLsizei getLayerCount(int level) const override;
gl::Error setImage(const gl::Context *context, gl::Error setImage(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
GLenum internalFormat, GLenum internalFormat,
...@@ -714,20 +713,23 @@ class TextureD3D_External : public TextureD3D ...@@ -714,20 +713,23 @@ class TextureD3D_External : public TextureD3D
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error setStorage(const gl::Context *context, gl::Error bindTexImage(const gl::Context *context, egl::Surface *surface) override;
gl::TextureType type, gl::Error releaseTexImage(const gl::Context *context) override;
size_t levels, };
GLenum internalFormat,
const gl::Extents &size) override; class TextureD3D_External : public TextureD3DImmutableBase
{
public:
TextureD3D_External(const gl::TextureState &data, RendererD3D *renderer);
~TextureD3D_External() override;
GLsizei getLayerCount(int level) const override;
gl::Error setImageExternal(const gl::Context *context, gl::Error setImageExternal(const gl::Context *context,
gl::TextureType type, gl::TextureType type,
egl::Stream *stream, egl::Stream *stream,
const egl::Stream::GLTextureDescription &desc) override; const egl::Stream::GLTextureDescription &desc) override;
gl::Error bindTexImage(const gl::Context *context, egl::Surface *surface) override;
gl::Error releaseTexImage(const gl::Context *context) override;
gl::Error setEGLImageTarget(const gl::Context *context, gl::Error setEGLImageTarget(const gl::Context *context,
gl::TextureType type, gl::TextureType type,
egl::Image *image) override; egl::Image *image) override;
...@@ -756,55 +758,12 @@ class TextureD3D_External : public TextureD3D ...@@ -756,55 +758,12 @@ class TextureD3D_External : public TextureD3D
bool isImageComplete(const gl::ImageIndex &index) const override; bool isImageComplete(const gl::ImageIndex &index) const override;
}; };
class TextureD3D_2DMultisample : public TextureD3D class TextureD3D_2DMultisample : public TextureD3DImmutableBase
{ {
public: public:
TextureD3D_2DMultisample(const gl::TextureState &data, RendererD3D *renderer); TextureD3D_2DMultisample(const gl::TextureState &data, RendererD3D *renderer);
~TextureD3D_2DMultisample() override; ~TextureD3D_2DMultisample() override;
ImageD3D *getImage(const gl::ImageIndex &index) const override;
gl::Error setImage(const gl::Context *context,
const gl::ImageIndex &index,
GLenum internalFormat,
const gl::Extents &size,
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override;
gl::Error setSubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Box &area,
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override;
gl::Error setCompressedImage(const gl::Context *context,
const gl::ImageIndex &index,
GLenum internalFormat,
const gl::Extents &size,
const gl::PixelUnpackState &unpack,
size_t imageSize,
const uint8_t *pixels) override;
gl::Error setCompressedSubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Box &area,
GLenum format,
const gl::PixelUnpackState &unpack,
size_t imageSize,
const uint8_t *pixels) override;
gl::Error copyImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Rectangle &sourceArea,
GLenum internalFormat,
gl::Framebuffer *source) override;
gl::Error copySubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Offset &destOffset,
const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override;
gl::Error setStorageMultisample(const gl::Context *context, gl::Error setStorageMultisample(const gl::Context *context,
gl::TextureType type, gl::TextureType type,
GLsizei samples, GLsizei samples,
...@@ -812,9 +771,6 @@ class TextureD3D_2DMultisample : public TextureD3D ...@@ -812,9 +771,6 @@ class TextureD3D_2DMultisample : public TextureD3D
const gl::Extents &size, const gl::Extents &size,
bool fixedSampleLocations) override; bool fixedSampleLocations) override;
gl::Error bindTexImage(const gl::Context *context, egl::Surface *surface) override;
gl::Error releaseTexImage(const gl::Context *context) override;
gl::Error setEGLImageTarget(const gl::Context *context, gl::Error setEGLImageTarget(const gl::Context *context,
gl::TextureType type, gl::TextureType type,
egl::Image *image) override; egl::Image *image) override;
......
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