From 822cca2112e0a4e2bf2ee2a178947a7eb594152e Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 14 Oct 2020 09:42:05 +0800 Subject: [PATCH] Sync SamplerInfo definition & use default values (#2901) --- native/cocos/renderer/core/gfx/GFXDef.h | 27 +++++++++---------- native/cocos/renderer/core/gfx/GFXSampler.h | 2 -- .../cocos/renderer/gfx-gles2/GLES2Sampler.cpp | 1 - .../cocos/renderer/gfx-gles3/GLES3Sampler.cpp | 1 - native/cocos/renderer/gfx-metal/MTLSampler.mm | 1 - .../cocos/renderer/gfx-vulkan/VKSampler.cpp | 1 - native/tools/tojs/gfx.ini | 2 +- 7 files changed, 14 insertions(+), 21 deletions(-) diff --git a/native/cocos/renderer/core/gfx/GFXDef.h b/native/cocos/renderer/core/gfx/GFXDef.h index dcce437f5a..de270eac48 100755 --- a/native/cocos/renderer/core/gfx/GFXDef.h +++ b/native/cocos/renderer/core/gfx/GFXDef.h @@ -561,16 +561,16 @@ enum class VsyncMode : uint8_t { }; struct Offset { - int x; - int y; - int z; + int x = 0; + int y = 0; + int z = 0; }; struct Rect { int x = 0; int y = 0; - uint width = 0u; - uint height = 0u; + uint width = 1u; + uint height = 1u; bool operator==(const Rect &rs) { if (x == rs.x && @@ -588,9 +588,9 @@ struct Rect { }; struct Extent { - uint width; - uint height; - uint depth; + uint width = 0; + uint height = 0; + uint depth = 1; }; struct TextureSubres { @@ -601,17 +601,17 @@ struct TextureSubres { struct TextureCopy { TextureSubres srcSubres; - Offset srcOffset = {0, 0, 0}; + Offset srcOffset; TextureSubres dstSubres; - Offset dstOffset = {0, 0, 0}; - Extent extent = {0, 0, 1}; + Offset dstOffset; + Extent extent; }; struct BufferTextureCopy { uint buffStride = 0; uint buffTexHeight = 0; - Offset texOffset = {0, 0, 0}; - Extent texExtent = {0, 0, 1}; + Offset texOffset; + Extent texExtent; TextureSubres texSubres; }; typedef cc::vector BufferTextureCopyList; @@ -756,7 +756,6 @@ struct TextureViewInfo { }; struct SamplerInfo { - String name; Filter minFilter = Filter::LINEAR; Filter magFilter = Filter::LINEAR; Filter mipFilter = Filter::NONE; diff --git a/native/cocos/renderer/core/gfx/GFXSampler.h b/native/cocos/renderer/core/gfx/GFXSampler.h index 42f5c1d770..0c32176e0a 100755 --- a/native/cocos/renderer/core/gfx/GFXSampler.h +++ b/native/cocos/renderer/core/gfx/GFXSampler.h @@ -16,7 +16,6 @@ public: virtual void destroy() = 0; CC_INLINE Device *getDevice() const { return _device; } - CC_INLINE const String &getName() const { return _name; } CC_INLINE Filter getMinFilter() const { return _minFilter; } CC_INLINE Filter getMagFilter() const { return _magFilter; } CC_INLINE Filter getMipFilter() const { return _mipFilter; } @@ -32,7 +31,6 @@ public: protected: Device *_device = nullptr; - String _name; Filter _minFilter = Filter::NONE; Filter _magFilter = Filter::NONE; Filter _mipFilter = Filter::NONE; diff --git a/native/cocos/renderer/gfx-gles2/GLES2Sampler.cpp b/native/cocos/renderer/gfx-gles2/GLES2Sampler.cpp index 427eebbf9b..f3c08b04ff 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Sampler.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Sampler.cpp @@ -13,7 +13,6 @@ GLES2Sampler::~GLES2Sampler() { } bool GLES2Sampler::initialize(const SamplerInfo &info) { - _name = info.name; _minFilter = info.minFilter; _magFilter = info.magFilter; _mipFilter = info.mipFilter; diff --git a/native/cocos/renderer/gfx-gles3/GLES3Sampler.cpp b/native/cocos/renderer/gfx-gles3/GLES3Sampler.cpp index 2787ccd5a8..747f0c4cfc 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Sampler.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Sampler.cpp @@ -13,7 +13,6 @@ GLES3Sampler::~GLES3Sampler() { } bool GLES3Sampler::initialize(const SamplerInfo &info) { - _name = info.name; _minFilter = info.minFilter; _magFilter = info.magFilter; _mipFilter = info.mipFilter; diff --git a/native/cocos/renderer/gfx-metal/MTLSampler.mm b/native/cocos/renderer/gfx-metal/MTLSampler.mm index 21dfb14e60..667487a70a 100644 --- a/native/cocos/renderer/gfx-metal/MTLSampler.mm +++ b/native/cocos/renderer/gfx-metal/MTLSampler.mm @@ -13,7 +13,6 @@ CCMTLSampler::CCMTLSampler(Device *device) : Sampler(device) {} CCMTLSampler::~CCMTLSampler() { destroy(); } bool CCMTLSampler::initialize(const SamplerInfo &info) { - _name = info.name; _minFilter = info.minFilter; _magFilter = info.magFilter; _mipFilter = info.mipFilter; diff --git a/native/cocos/renderer/gfx-vulkan/VKSampler.cpp b/native/cocos/renderer/gfx-vulkan/VKSampler.cpp index fe35492517..42e5fcf677 100644 --- a/native/cocos/renderer/gfx-vulkan/VKSampler.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKSampler.cpp @@ -15,7 +15,6 @@ CCVKSampler::~CCVKSampler() { } bool CCVKSampler::initialize(const SamplerInfo &info) { - _name = info.name; _minFilter = info.minFilter; _magFilter = info.magFilter; _mipFilter = info.mipFilter; diff --git a/native/tools/tojs/gfx.ini b/native/tools/tojs/gfx.ini index 7848196b4f..637d177d30 100644 --- a/native/tools/tojs/gfx.ini +++ b/native/tools/tojs/gfx.ini @@ -75,7 +75,7 @@ getter_setter = Device::[gfxAPI deviceName width height nativeWidth nativeHeight Context::[sharedContext/sharedContext vsyncMode colorFormat depthStencilFormat], Framebuffer::[renderPass colorTextures depthStencilTexture], Buffer::[usage memUsage stride count size flags], - Sampler::[name minFilter magFilter mipFilter addressU addressV addressW maxAnisotropy cmpFunc borderColor minLOD maxLOD mipLODBias], + Sampler::[minFilter magFilter mipFilter addressU addressV addressW maxAnisotropy cmpFunc borderColor minLOD maxLOD mipLODBias], GFXObject::[gfxType/getType] rename_functions =