Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
YunHsiao committed Aug 24, 2020
1 parent ac37e3f commit c700074
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 44 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,6 @@ endif()
if(CC_USE_METAL)
cocos_source_files(
cocos/renderer/gfx-metal/GFXMTL.h
cocos/renderer/gfx-metal/MTLBindingLayout.cpp
cocos/renderer/gfx-metal/MTLBindingLayout.h
cocos/renderer/gfx-metal/MTLBuffer.h
cocos/renderer/gfx-metal/MTLBuffer.mm
cocos/renderer/gfx-metal/MTLCommandBuffer.h
Expand All @@ -688,8 +686,14 @@ if(CC_USE_METAL)
cocos/renderer/gfx-metal/MTLGPUObjects.h
cocos/renderer/gfx-metal/MTLInputAssembler.h
cocos/renderer/gfx-metal/MTLInputAssembler.mm
cocos/renderer/gfx-metal/MTLDescriptorSetLayout.h
cocos/renderer/gfx-metal/MTLDescriptorSetLayout.mm
cocos/renderer/gfx-metal/MTLPipelineLayout.h
cocos/renderer/gfx-metal/MTLPipelineLayout.mm
cocos/renderer/gfx-metal/MTLPipelineState.h
cocos/renderer/gfx-metal/MTLPipelineState.mm
cocos/renderer/gfx-metal/MTLDescriptorSet.h
cocos/renderer/gfx-metal/MTLDescriptorSet.mm
cocos/renderer/gfx-metal/MTLQueue.h
cocos/renderer/gfx-metal/MTLQueue.mm
cocos/renderer/gfx-metal/MTLRenderPass.h
Expand Down
13 changes: 10 additions & 3 deletions cocos/renderer/core/gfx/GFXCommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CC_DLL CommandBuffer : public GFXObject {
virtual void destroy() = 0;
virtual void begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer) = 0;
virtual void end() = 0;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const vector<Color> &colors, float depth, int stencil) = 0;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, int stencil) = 0;
virtual void endRenderPass() = 0;
virtual void bindPipelineState(PipelineState *pso) = 0;
virtual void bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) = 0;
Expand All @@ -31,16 +31,23 @@ class CC_DLL CommandBuffer : public GFXObject {
virtual void setStencilCompareMask(StencilFace face, int ref, uint mask) = 0;
virtual void draw(InputAssembler *ia) = 0;
virtual void updateBuffer(Buffer *buff, void *data, uint size, uint offset = 0) = 0;
virtual void copyBuffersToTexture(const BufferDataList &buffers, Texture *texture, const BufferTextureCopyList &regions) = 0;
virtual void execute(const CommandBufferList &cmdBuffs, uint32_t count) = 0;
virtual void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) = 0;
virtual void execute(const CommandBuffer *const *cmdBuffs, uint32_t count) = 0;

CC_INLINE void begin() { begin(nullptr, 0, nullptr); }
CC_INLINE void begin(RenderPass *renderPass) { begin(renderPass, 0, nullptr); }
CC_INLINE void begin(RenderPass *renderPass, uint subpass) { begin(renderPass, subpass, nullptr); }
CC_INLINE void execute(const CommandBufferList &cmdBuffs, uint32_t count) { execute(cmdBuffs.data(), count); }
CC_INLINE void bindDescriptorSet(uint set, DescriptorSet *descriptorSet) { bindDescriptorSet(set, descriptorSet, 0, nullptr); }
CC_INLINE void bindDescriptorSet(uint set, DescriptorSet *descriptorSet, const vector<uint> &dynamicOffsets) {
bindDescriptorSet(set, descriptorSet, dynamicOffsets.size(), dynamicOffsets.data());
}
CC_INLINE void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const vector<Color> &colors, float depth, int stencil) {
beginRenderPass(renderPass, fbo, renderArea, colors.data(), depth, stencil);
}
CC_INLINE void copyBuffersToTexture(const BufferDataList &buffers, Texture *texture, const BufferTextureCopyList &regions) {
copyBuffersToTexture(buffers.data(), texture, regions.data(), regions.size());
}

CC_INLINE Device *getDevice() const { return _device; }
CC_INLINE Queue *getQueue() const { return _queue; }
Expand Down
16 changes: 8 additions & 8 deletions cocos/renderer/gfx-gles2/GLES2CommandBuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ void GLES2CommandBuffer::end() {
_isInRenderPass = false;
}

void GLES2CommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const vector<Color> &colors, float depth, int stencil) {
void GLES2CommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, int stencil) {
_isInRenderPass = true;

GLES2CmdBeginRenderPass *cmd = _gles2Allocator->beginRenderPassCmdPool.alloc();
cmd->gpuRenderPass = ((GLES2RenderPass *)renderPass)->gpuRenderPass();
cmd->gpuFBO = ((GLES2Framebuffer *)fbo)->gpuFBO();
cmd->renderArea = renderArea;
cmd->numClearColors = (uint32_t)colors.size();
for (uint i = 0; i < colors.size(); ++i) {
cmd->numClearColors = cmd->gpuRenderPass->colorAttachments.size();
for (uint i = 0; i < cmd->numClearColors; ++i) {
cmd->clearColors[i] = colors[i];
}
cmd->clearDepth = depth;
Expand Down Expand Up @@ -255,16 +255,16 @@ void GLES2CommandBuffer::updateBuffer(Buffer *buff, void *data, uint size, uint
}
}

void GLES2CommandBuffer::copyBuffersToTexture(const BufferDataList &buffers, Texture *texture, const BufferTextureCopyList &regions) {
void GLES2CommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) {
if ((_type == CommandBufferType::PRIMARY && !_isInRenderPass) ||
(_type == CommandBufferType::SECONDARY)) {
GLES2GPUTexture *gpuTexture = ((GLES2Texture *)texture)->gpuTexture();
if (gpuTexture) {
GLES2CmdCopyBufferToTexture *cmd = _gles2Allocator->copyBufferToTextureCmdPool.alloc();
cmd->gpuTexture = gpuTexture;
cmd->buffers.resize(buffers.size());
cmd->regions.resize(regions.size());
for (uint i = 0; i < static_cast<uint>(regions.size()); ++i) {
cmd->buffers.resize(count);
cmd->regions.resize(count);
for (uint i = 0; i < count; ++i) {
cmd->buffers[i] = buffers[i];
cmd->regions[i] = regions[i];
}
Expand All @@ -277,7 +277,7 @@ void GLES2CommandBuffer::copyBuffersToTexture(const BufferDataList &buffers, Tex
}
}

void GLES2CommandBuffer::execute(const CommandBufferList &cmdBuffs, uint32_t count) {
void GLES2CommandBuffer::execute(const CommandBuffer *const *cmdBuffs, uint32_t count) {
for (uint i = 0; i < count; ++i) {
GLES2CommandBuffer *cmdBuff = (GLES2CommandBuffer *)cmdBuffs[i];

Expand Down
6 changes: 3 additions & 3 deletions cocos/renderer/gfx-gles2/GLES2CommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CC_GLES2_API GLES2CommandBuffer : public CommandBuffer {

virtual void begin(RenderPass *renderPass = nullptr, uint subpass = 0, Framebuffer *frameBuffer = nullptr) override;
virtual void end() override;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const vector<Color> &colors, float depth, int stencil) override;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, int stencil) override;
virtual void endRenderPass() override;
virtual void bindPipelineState(PipelineState *pso) override;
virtual void bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) override;
Expand All @@ -36,8 +36,8 @@ class CC_GLES2_API GLES2CommandBuffer : public CommandBuffer {
virtual void setStencilCompareMask(StencilFace face, int ref, uint mask) override;
virtual void draw(InputAssembler *ia) override;
virtual void updateBuffer(Buffer *buff, void *data, uint size, uint offset) override;
virtual void copyBuffersToTexture(const BufferDataList &buffers, Texture *texture, const BufferTextureCopyList &regions) override;
virtual void execute(const CommandBufferList &cmdBuffs, uint32_t count) override;
virtual void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) override;
virtual void execute(const CommandBuffer *const *cmdBuffs, uint32_t count) override;

private:
void BindStates();
Expand Down
16 changes: 8 additions & 8 deletions cocos/renderer/gfx-gles3/GLES3CommandBuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ void GLES3CommandBuffer::end() {
_isInRenderPass = false;
}

void GLES3CommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const vector<Color> &colors, float depth, int stencil) {
void GLES3CommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, int stencil) {
_isInRenderPass = true;

GLES3CmdBeginRenderPass *cmd = _gles3Allocator->beginRenderPassCmdPool.alloc();
cmd->gpuRenderPass = ((GLES3RenderPass *)renderPass)->gpuRenderPass();
cmd->gpuFBO = ((GLES3Framebuffer *)fbo)->gpuFBO();
cmd->renderArea = renderArea;
cmd->numClearColors = (uint32_t)colors.size();
for (uint i = 0; i < colors.size(); ++i) {
cmd->numClearColors = cmd->gpuRenderPass->colorAttachments.size();
for (uint i = 0; i < cmd->numClearColors; ++i) {
cmd->clearColors[i] = colors[i];
}
cmd->clearDepth = depth;
Expand Down Expand Up @@ -260,17 +260,17 @@ void GLES3CommandBuffer::updateBuffer(Buffer *buff, void *data, uint size, uint
}
}

void GLES3CommandBuffer::copyBuffersToTexture(const BufferDataList &buffers, Texture *texture, const BufferTextureCopyList &regions) {
void GLES3CommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) {
if ((_type == CommandBufferType::PRIMARY && !_isInRenderPass) ||
(_type == CommandBufferType::SECONDARY)) {

GLES3GPUTexture *gpuTexture = ((GLES3Texture *)texture)->gpuTexture();
if (gpuTexture) {
GLES3CmdCopyBufferToTexture *cmd = _gles3Allocator->copyBufferToTextureCmdPool.alloc();
cmd->gpuTexture = gpuTexture;
cmd->buffers.resize(buffers.size());
cmd->regions.resize(regions.size());
for (uint i = 0; i < static_cast<uint>(regions.size()); ++i) {
cmd->buffers.resize(count);
cmd->regions.resize(count);
for (uint i = 0; i < count; ++i) {
cmd->buffers[i] = buffers[i];
cmd->regions[i] = regions[i];
}
Expand All @@ -283,7 +283,7 @@ void GLES3CommandBuffer::copyBuffersToTexture(const BufferDataList &buffers, Tex
}
}

void GLES3CommandBuffer::execute(const CommandBufferList &cmdBuffs, uint32_t count) {
void GLES3CommandBuffer::execute(const CommandBuffer *const *cmdBuffs, uint32_t count) {
for (uint i = 0; i < count; ++i) {
GLES3CommandBuffer *cmdBuff = (GLES3CommandBuffer *)cmdBuffs[i];

Expand Down
6 changes: 3 additions & 3 deletions cocos/renderer/gfx-gles3/GLES3CommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CC_GLES3_API GLES3CommandBuffer : public CommandBuffer {

virtual void begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer) override;
virtual void end() override;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const vector<Color> &colors, float depth, int stencil) override;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, int stencil) override;
virtual void endRenderPass() override;
virtual void bindPipelineState(PipelineState *pso) override;
virtual void bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) override;
Expand All @@ -36,8 +36,8 @@ class CC_GLES3_API GLES3CommandBuffer : public CommandBuffer {
virtual void setStencilCompareMask(StencilFace face, int ref, uint mask) override;
virtual void draw(InputAssembler *ia) override;
virtual void updateBuffer(Buffer *buff, void *data, uint size, uint offset) override;
virtual void copyBuffersToTexture(const BufferDataList &buffers, Texture *texture, const BufferTextureCopyList &regions) override;
virtual void execute(const CommandBufferList &cmdBuffs, uint32_t count) override;
virtual void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) override;
virtual void execute(const CommandBuffer *const *cmdBuffs, uint32_t count) override;

private:
void BindStates();
Expand Down
6 changes: 3 additions & 3 deletions cocos/renderer/gfx-metal/MTLCommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CCMTLCommandBuffer : public CommandBuffer {
virtual void destroy() override;
virtual void begin(RenderPass *renderPass = nullptr, uint subpass = 0, Framebuffer *frameBuffer = nullptr) override;
virtual void end() override;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const vector<Color> &colors, float depth, int stencil) override;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, int stencil) override;
virtual void endRenderPass() override;
virtual void bindPipelineState(PipelineState *pso) override;
virtual void bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) override;
Expand All @@ -39,8 +39,8 @@ class CCMTLCommandBuffer : public CommandBuffer {
virtual void setStencilCompareMask(StencilFace face, int ref, uint mask) override;
virtual void draw(InputAssembler *ia) override;
virtual void updateBuffer(Buffer *buff, void *data, uint size, uint offset = 0) override;
virtual void copyBuffersToTexture(const BufferDataList &buffers, Texture *texture, const BufferTextureCopyList &regions) override;
virtual void execute(const CommandBufferList &cmdBuffs, uint32_t count) override;
virtual void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) override;
virtual void execute(const CommandBuffer *const *cmdBuffs, uint32_t count) override;

private:
void bindStates();
Expand Down
6 changes: 3 additions & 3 deletions cocos/renderer/gfx-metal/MTLCommandBuffer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@
}
}

void CCMTLCommandBuffer::copyBuffersToTexture(const BufferDataList &buffers, Texture *texture, const BufferTextureCopyList &regions) {
void CCMTLCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) {
if ((_type == CommandBufferType::PRIMARY) ||
(_type == CommandBufferType::SECONDARY)) {
if (texture) {
static_cast<CCMTLTexture *>(texture)->update(buffers.data(), regions);
static_cast<CCMTLTexture *>(texture)->update(buffers, regions, count);
} else {
CC_LOG_ERROR("CCMTLCommandBuffer::copyBufferToTexture: texture is nullptr");
}
Expand All @@ -337,7 +337,7 @@
}
}

void CCMTLCommandBuffer::execute(const CommandBufferList &commandBuffs, uint32_t count) {
void CCMTLCommandBuffer::execute(const CommandBuffer *const *commandBuffs, uint32_t count) {
for (uint i = 0; i < count; ++i) {
auto commandBuffer = static_cast<CCMTLCommandBuffer *>(commandBuffs[i]);
_numDrawCalls += commandBuffer->_numDrawCalls;
Expand Down
2 changes: 1 addition & 1 deletion cocos/renderer/gfx-metal/MTLTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CCMTLTexture : public Texture {
CC_INLINE Format getConvertedFormat() const { return _convertedFormat; }

private:
void update(const uint8_t *const *datas, const BufferTextureCopyList &regions);
void update(const uint8_t *const *datas, const BufferTextureCopy *regions, uint count);
bool createMTLTexture();
void generateMipmaps();

Expand Down
6 changes: 3 additions & 3 deletions cocos/renderer/gfx-metal/MTLTexture.mm
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
_status = Status::SUCCESS;
}

void CCMTLTexture::update(const uint8_t *const *datas, const BufferTextureCopyList &regions) {
void CCMTLTexture::update(const uint8_t *const *datas, const BufferTextureCopy *regions, uint count) {
if (!_mtlTexture)
return;

Expand All @@ -249,7 +249,7 @@
auto mtlTextureType = mu::toMTLTextureType(_type);
switch (mtlTextureType) {
case MTLTextureType2D:
for (size_t i = 0; i < regions.size(); i++) {
for (size_t i = 0; i < count; i++) {
const auto &region = regions[i];
w = region.texExtent.width;
h = region.texExtent.height;
Expand All @@ -269,7 +269,7 @@
break;
case MTLTextureType2DArray:
case MTLTextureTypeCube:
for (size_t i = 0; i < regions.size(); i++) {
for (size_t i = 0; i < count; i++) {
const auto &region = regions[i];
auto layer = region.texSubres.baseArrayLayer;
auto layerCount = layer + region.texSubres.layerCount;
Expand Down
6 changes: 3 additions & 3 deletions cocos/renderer/gfx-vulkan/VKCommandBuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void CCVKCommandBuffer::end() {
}

void CCVKCommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea,
const vector<Color> &colors, float depth, int stencil) {
const Color *colors, float depth, int stencil) {
_curGPUFBO = ((CCVKFramebuffer *)fbo)->gpuFBO();
CCVKGPURenderPass *gpuRenderPass = ((CCVKRenderPass *)renderPass)->gpuRenderPass();
VkFramebuffer framebuffer = _curGPUFBO->vkFramebuffer;
Expand Down Expand Up @@ -333,7 +333,7 @@ void CCVKCommandBuffer::draw(InputAssembler *ia) {
}
}

void CCVKCommandBuffer::execute(const CommandBufferList &cmdBuffs, uint count) {
void CCVKCommandBuffer::execute(const CommandBuffer *const *cmdBuffs, uint count) {
if (!count) {
return;
}
Expand All @@ -356,7 +356,7 @@ void CCVKCommandBuffer::updateBuffer(Buffer *buff, void *data, uint size, uint o
CCVKCmdFuncUpdateBuffer((CCVKDevice *)_device, ((CCVKBuffer *)buff)->gpuBuffer(), data, offset, size);
}

void CCVKCommandBuffer::copyBuffersToTexture(const BufferDataList &buffers, Texture *texture, const BufferTextureCopyList &regions) {
void CCVKCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) {
//const CCVKGPUBuffer* gpuBuffer = ((CCVKBuffer*)src)->gpuBuffer();
//const CCVKGPUTexture* gpuTexture = ((CCVKTexture*)dst)->gpuTexture();
//vkCmdCopyBufferToImage(_gpuCommandBuffer->vkCommandBuffer, gpuBuffer->vkBuffer, gpuTexture->vkImage, MapVkImageLayout(layout),
Expand Down
6 changes: 3 additions & 3 deletions cocos/renderer/gfx-vulkan/VKCommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CC_VULKAN_API CCVKCommandBuffer : public CommandBuffer {

virtual void begin(RenderPass *renderPass = nullptr, uint subpass = 0, Framebuffer *frameBuffer = nullptr) override;
virtual void end() override;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const vector<Color> &colors, float depth, int stencil) override;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, int stencil) override;
virtual void endRenderPass() override;
virtual void bindPipelineState(PipelineState *pso) override;
virtual void bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) override;
Expand All @@ -34,8 +34,8 @@ class CC_VULKAN_API CCVKCommandBuffer : public CommandBuffer {
virtual void setStencilCompareMask(StencilFace face, int reference, uint mask) override;
virtual void draw(InputAssembler *ia) override;
virtual void updateBuffer(Buffer *buff, void *data, uint size, uint offset) override;
virtual void copyBuffersToTexture(const BufferDataList &buffers, Texture *texture, const BufferTextureCopyList &regions) override;
virtual void execute(const CommandBufferList &cmdBuffs, uint count) override;
virtual void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) override;
virtual void execute(const CommandBuffer *const *cmdBuffs, uint count) override;

CCVKGPUCommandBuffer *gpuCommandBuffer() const { return _gpuCommandBuffer; }

Expand Down
2 changes: 1 addition & 1 deletion cocos/renderer/gfx-vulkan/VKCommands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void CCVKCmdFuncCreatePipelineState(CCVKDevice *device, CCVKGPUPipelineState *gp
break;
}
}
if (!attributeFound) { //handle absent attribute
if (!attributeFound) { // handle absent attribute
attributeDescriptions[i].location = shaderAttrs[i].location;
attributeDescriptions[i].format = MapVkFormat(shaderAttrs[i].format);
attributeDescriptions[i].offset = 0; // reuse the first attribute as dummy data
Expand Down

0 comments on commit c700074

Please sign in to comment.