Fix glTexStorage2D errors.

If a GL texture is externally-managed, don't make any GL calls
during the Texture constructor.

Bug: dawn:114

Change-Id: I8ece5cde433fb036f37bda7d18ddb81d9b50a89d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5640
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Stephen White 2019-03-14 15:05:53 +00:00 committed by Commit Bot service account
parent ea2c7f20f2
commit 5625b63202
1 changed files with 6 additions and 7 deletions

View File

@ -89,12 +89,6 @@ namespace dawn_native { namespace opengl {
Texture::Texture(Device* device, const TextureDescriptor* descriptor)
: Texture(device, descriptor, GenTexture()) {
}
Texture::Texture(Device* device, const TextureDescriptor* descriptor, GLuint handle)
: TextureBase(device, descriptor), mHandle(handle) {
mTarget = TargetForDimensionAndArrayLayers(GetDimension(), GetArrayLayers());
uint32_t width = GetSize().width;
uint32_t height = GetSize().height;
uint32_t levels = GetNumMipLevels();
@ -102,7 +96,7 @@ namespace dawn_native { namespace opengl {
auto formatInfo = GetGLFormatInfo(GetFormat());
glBindTexture(mTarget, handle);
glBindTexture(mTarget, mHandle);
// glTextureView() requires the value of GL_TEXTURE_IMMUTABLE_FORMAT for origtexture to be
// GL_TRUE, so the storage of the texture must be allocated with glTexStorage*D.
@ -125,6 +119,11 @@ namespace dawn_native { namespace opengl {
glTexParameteri(mTarget, GL_TEXTURE_MAX_LEVEL, levels - 1);
}
Texture::Texture(Device* device, const TextureDescriptor* descriptor, GLuint handle)
: TextureBase(device, descriptor), mHandle(handle) {
mTarget = TargetForDimensionAndArrayLayers(GetDimension(), GetArrayLayers());
}
Texture::~Texture() {
// TODO(kainino@chromium.org): delete texture (but only when not using the native texture
// constructor?)