Descriptorize Texture

This patch introduces texture descriptor for texture creation instead
of texture builders.

This patch also adds "arrayLayer" to texture descriptor and removes
mDevice in TextureD3D12.
This commit is contained in:
Jiawei Shao
2018-08-27 08:44:48 +08:00
committed by Corentin Wallez
parent 75559bf1be
commit 425428f97b
46 changed files with 300 additions and 341 deletions

View File

@@ -98,8 +98,8 @@ namespace dawn_native { namespace opengl {
SwapChainBase* Device::CreateSwapChain(SwapChainBuilder* builder) {
return new SwapChain(builder);
}
TextureBase* Device::CreateTexture(TextureBuilder* builder) {
return new Texture(builder);
ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
return new Texture(this, descriptor);
}
TextureViewBase* Device::CreateTextureView(TextureViewBuilder* builder) {
return new TextureView(builder);

View File

@@ -43,7 +43,6 @@ namespace dawn_native { namespace opengl {
RenderPassDescriptorBuilder* builder) override;
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
TextureBase* CreateTexture(TextureBuilder* builder) override;
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
void TickImpl() override;
@@ -58,6 +57,7 @@ namespace dawn_native { namespace opengl {
ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
const ShaderModuleDescriptor* descriptor) override;
ResultOrError<TextureBase*> CreateTextureImpl(const TextureDescriptor* descriptor) override;
};
}} // namespace dawn_native::opengl

View File

@@ -15,6 +15,7 @@
#include "dawn_native/opengl/SwapChainGL.h"
#include "dawn_native/Device.h"
#include "dawn_native/opengl/Forward.h"
#include "dawn_native/opengl/TextureGL.h"
#include <dawn/dawn_wsi.h>
@@ -29,7 +30,7 @@ namespace dawn_native { namespace opengl {
SwapChain::~SwapChain() {
}
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
const auto& im = GetImplementation();
dawnSwapChainNextTexture next = {};
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
@@ -38,7 +39,7 @@ namespace dawn_native { namespace opengl {
return nullptr;
}
GLuint nativeTexture = next.texture.u32;
return new Texture(builder, nativeTexture);
return new Texture(ToBackend(GetDevice()), descriptor, nativeTexture);
}
void SwapChain::OnBeforePresent(TextureBase*) {

View File

@@ -29,7 +29,7 @@ namespace dawn_native { namespace opengl {
~SwapChain();
protected:
TextureBase* GetNextTextureImpl(TextureBuilder* builder) override;
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
void OnBeforePresent(TextureBase* texture) override;
};

View File

@@ -13,6 +13,7 @@
// limitations under the License.
#include "dawn_native/opengl/TextureGL.h"
#include "dawn_native/opengl/DeviceGL.h"
#include "common/Assert.h"
@@ -67,11 +68,12 @@ namespace dawn_native { namespace opengl {
// Texture
Texture::Texture(TextureBuilder* builder) : Texture(builder, GenTexture()) {
Texture::Texture(Device* device, const TextureDescriptor* descriptor)
: Texture(device, descriptor, GenTexture()) {
}
Texture::Texture(TextureBuilder* builder, GLuint handle)
: TextureBase(builder), mHandle(handle) {
Texture::Texture(Device* device, const TextureDescriptor* descriptor, GLuint handle)
: TextureBase(device, descriptor), mHandle(handle) {
mTarget = TargetForDimension(GetDimension());
uint32_t width = GetWidth();

View File

@@ -21,6 +21,8 @@
namespace dawn_native { namespace opengl {
class Device;
struct TextureFormatInfo {
GLenum internalFormat;
GLenum format;
@@ -29,8 +31,8 @@ namespace dawn_native { namespace opengl {
class Texture : public TextureBase {
public:
Texture(TextureBuilder* builder);
Texture(TextureBuilder* builder, GLuint handle);
Texture(Device* device, const TextureDescriptor* descriptor);
Texture(Device* device, const TextureDescriptor* descriptor, GLuint handle);
~Texture();
GLuint GetHandle() const;