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>
diff --git a/src/dawn_native/opengl/TextureGL.cpp b/src/dawn_native/opengl/TextureGL.cpp
index 8d36bd2..bf9bac6 100644
--- a/src/dawn_native/opengl/TextureGL.cpp
+++ b/src/dawn_native/opengl/TextureGL.cpp
@@ -89,12 +89,6 @@
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 @@
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 @@
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?)