mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
Destroy frontend and backend for Textures
Same idea as for buffers, Destroy can be used to free GPU memory associated with resources without waiting for javascript garbage collection to occur. Bug: dawn:46 Change-Id: Ia796b06b5228cbec4cfe8d78a500f967181d8c1f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5540 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Natasha Lee <natlee@microsoft.com>
This commit is contained in:
committed by
Commit Bot service account
parent
889d743baa
commit
cae68ff846
@@ -119,7 +119,7 @@ namespace dawn_native { namespace opengl {
|
||||
// Texture
|
||||
|
||||
Texture::Texture(Device* device, const TextureDescriptor* descriptor)
|
||||
: Texture(device, descriptor, GenTexture()) {
|
||||
: Texture(device, descriptor, GenTexture(), TextureState::OwnedInternal) {
|
||||
uint32_t width = GetSize().width;
|
||||
uint32_t height = GetSize().height;
|
||||
uint32_t levels = GetNumMipLevels();
|
||||
@@ -150,14 +150,21 @@ 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) {
|
||||
Texture::Texture(Device* device,
|
||||
const TextureDescriptor* descriptor,
|
||||
GLuint handle,
|
||||
TextureState state)
|
||||
: TextureBase(device, descriptor, state), mHandle(handle) {
|
||||
mTarget = TargetForDimensionAndArrayLayers(GetDimension(), GetArrayLayers());
|
||||
}
|
||||
|
||||
Texture::~Texture() {
|
||||
// TODO(kainino@chromium.org): delete texture (but only when not using the native texture
|
||||
// constructor?)
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void Texture::DestroyImpl() {
|
||||
glDeleteTextures(1, &mHandle);
|
||||
mHandle = 0;
|
||||
}
|
||||
|
||||
GLuint Texture::GetHandle() const {
|
||||
|
||||
Reference in New Issue
Block a user