mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-28 14:35:53 +00:00
Bug: dawn:1336 Change-Id: I1fd189bd6e3689df6f10351e8ba19fee569bda23 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122023 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Loko Kung <lokokung@google.com> Reviewed-by: Austin Eng <enga@chromium.org>
77 lines
2.3 KiB
C++
77 lines
2.3 KiB
C++
// Copyright 2017 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#ifndef SRC_DAWN_NATIVE_OPENGL_TEXTUREGL_H_
|
|
#define SRC_DAWN_NATIVE_OPENGL_TEXTUREGL_H_
|
|
|
|
#include "dawn/native/Texture.h"
|
|
|
|
#include "dawn/native/opengl/opengl_platform.h"
|
|
|
|
namespace dawn::native::opengl {
|
|
|
|
class Device;
|
|
struct GLFormat;
|
|
|
|
class Texture final : public TextureBase {
|
|
public:
|
|
static ResultOrError<Ref<Texture>> Create(Device* device, const TextureDescriptor* descriptor);
|
|
Texture(Device* device, const TextureDescriptor* descriptor, GLuint handle, TextureState state);
|
|
|
|
GLuint GetHandle() const;
|
|
GLenum GetGLTarget() const;
|
|
const GLFormat& GetGLFormat() const;
|
|
uint32_t GetGenID() const;
|
|
void Touch();
|
|
|
|
MaybeError EnsureSubresourceContentInitialized(const SubresourceRange& range);
|
|
|
|
private:
|
|
Texture(Device* device, const TextureDescriptor* descriptor);
|
|
~Texture() override;
|
|
|
|
void DestroyImpl() override;
|
|
MaybeError ClearTexture(const SubresourceRange& range, TextureBase::ClearValue clearValue);
|
|
|
|
GLuint mHandle;
|
|
GLenum mTarget;
|
|
uint32_t mGenID = 0;
|
|
};
|
|
|
|
class TextureView final : public TextureViewBase {
|
|
public:
|
|
TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor);
|
|
|
|
GLuint GetHandle() const;
|
|
GLenum GetGLTarget() const;
|
|
void BindToFramebuffer(GLenum target, GLenum attachment);
|
|
void CopyIfNeeded();
|
|
|
|
private:
|
|
~TextureView() override;
|
|
void DestroyImpl() override;
|
|
GLenum GetInternalFormat() const;
|
|
|
|
// TODO(crbug.com/dawn/1355): Delete this handle on texture destroy.
|
|
GLuint mHandle;
|
|
GLenum mTarget;
|
|
bool mOwnsHandle;
|
|
bool mUseCopy = false;
|
|
uint32_t mGenID = 0;
|
|
};
|
|
|
|
} // namespace dawn::native::opengl
|
|
|
|
#endif // SRC_DAWN_NATIVE_OPENGL_TEXTUREGL_H_
|