mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
da2f03ff73
* gfx: swapchain * acquire/release/surface on swapchain * fix swapchain texture creation * acquire/present back on device * formats are swapchain-specific * swapchain: vk works * enable device agent * format fix * update gfxdef * fix enum decl * pipeline adapt * minor * vk: compress attr locations directly in SPIR-V * gles3 adjust * InputAssembler owns an DrawInfo * gles2 adapt * texture keep track of its hash * device cached states * format * glslang finalize * buffer view adapt * fg: subpass support * minor * 3.4 adapt * profiler adapt * buffer update frequency detection * minor * base commit * swapchain works on metal * spirv * mtltexture issue * remote test code * depthtexture * revert ifdef USE_METAL * ios swapchain header * fix some triple buffer issues * resize accept surface transform Co-authored-by: Zeqiang Li <Zeqiang-li@outlook.com>
159 lines
4.6 KiB
C++
159 lines
4.6 KiB
C++
/****************************************************************************
|
|
Copyright (c) 2020-2021 Xiamen Yaji Software Co., Ltd.
|
|
|
|
http://www.cocos.com
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated engine source code (the "Software"), a limited,
|
|
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
|
to use Cocos Creator solely to develop games on your target platforms. You shall
|
|
not use Cocos Creator software for developing other software or tools that's
|
|
used for developing games. You are not granted to publish, distribute,
|
|
sublicense, and/or sell copies of Cocos Creator.
|
|
|
|
The software or tools in this License Agreement are licensed, not sold.
|
|
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
THE SOFTWARE.
|
|
****************************************************************************/
|
|
|
|
#include "base/CoreStd.h"
|
|
|
|
#include "EmptyBuffer.h"
|
|
#include "EmptyCommandBuffer.h"
|
|
#include "EmptyDescriptorSet.h"
|
|
#include "EmptyDescriptorSetLayout.h"
|
|
#include "EmptyDevice.h"
|
|
#include "EmptyFramebuffer.h"
|
|
#include "EmptyInputAssembler.h"
|
|
#include "EmptyPipelineLayout.h"
|
|
#include "EmptyPipelineState.h"
|
|
#include "EmptyQueue.h"
|
|
#include "EmptyRenderPass.h"
|
|
#include "EmptyShader.h"
|
|
#include "EmptySwapchain.h"
|
|
#include "EmptyTexture.h"
|
|
|
|
namespace cc {
|
|
namespace gfx {
|
|
|
|
EmptyDevice *EmptyDevice::instance = nullptr;
|
|
|
|
EmptyDevice *EmptyDevice::getInstance() {
|
|
return EmptyDevice::instance;
|
|
}
|
|
|
|
EmptyDevice::EmptyDevice() {
|
|
EmptyDevice::instance = this;
|
|
}
|
|
|
|
EmptyDevice::~EmptyDevice() {
|
|
EmptyDevice::instance = nullptr;
|
|
}
|
|
|
|
bool EmptyDevice::doInit(const DeviceInfo & /*info*/) {
|
|
QueueInfo queueInfo;
|
|
queueInfo.type = QueueType::GRAPHICS;
|
|
_queue = createQueue(queueInfo);
|
|
|
|
CommandBufferInfo cmdBuffInfo;
|
|
cmdBuffInfo.type = CommandBufferType::PRIMARY;
|
|
cmdBuffInfo.queue = _queue;
|
|
_cmdBuff = createCommandBuffer(cmdBuffInfo);
|
|
|
|
CC_LOG_INFO("Empty device initialized.");
|
|
|
|
return true;
|
|
}
|
|
|
|
void EmptyDevice::doDestroy() {
|
|
CC_SAFE_DESTROY(_cmdBuff);
|
|
CC_SAFE_DESTROY(_queue);
|
|
}
|
|
|
|
void EmptyDevice::acquire(Swapchain *const *swapchains, uint32_t count) {
|
|
}
|
|
|
|
void EmptyDevice::present() {
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(16));
|
|
}
|
|
|
|
CommandBuffer *EmptyDevice::createCommandBuffer(const CommandBufferInfo & /*info*/, bool /*hasAgent*/) {
|
|
return CC_NEW(EmptyCommandBuffer());
|
|
}
|
|
|
|
Queue *EmptyDevice::createQueue() {
|
|
return CC_NEW(EmptyQueue());
|
|
}
|
|
|
|
Swapchain *EmptyDevice::createSwapchain() {
|
|
return CC_NEW(EmptySwapchain());
|
|
}
|
|
|
|
Buffer *EmptyDevice::createBuffer() {
|
|
return CC_NEW(EmptyBuffer());
|
|
}
|
|
|
|
Texture *EmptyDevice::createTexture() {
|
|
return CC_NEW(EmptyTexture());
|
|
}
|
|
|
|
Shader *EmptyDevice::createShader() {
|
|
return CC_NEW(EmptyShader());
|
|
}
|
|
|
|
InputAssembler *EmptyDevice::createInputAssembler() {
|
|
return CC_NEW(EmptyInputAssembler());
|
|
}
|
|
|
|
RenderPass *EmptyDevice::createRenderPass() {
|
|
return CC_NEW(EmptyRenderPass());
|
|
}
|
|
|
|
Framebuffer *EmptyDevice::createFramebuffer() {
|
|
return CC_NEW(EmptyFramebuffer());
|
|
}
|
|
|
|
DescriptorSet *EmptyDevice::createDescriptorSet() {
|
|
return CC_NEW(EmptyDescriptorSet());
|
|
}
|
|
|
|
DescriptorSetLayout *EmptyDevice::createDescriptorSetLayout() {
|
|
return CC_NEW(EmptyDescriptorSetLayout());
|
|
}
|
|
|
|
PipelineLayout *EmptyDevice::createPipelineLayout() {
|
|
return CC_NEW(EmptyPipelineLayout());
|
|
}
|
|
|
|
PipelineState *EmptyDevice::createPipelineState() {
|
|
return CC_NEW(EmptyPipelineState());
|
|
}
|
|
|
|
Sampler *EmptyDevice::createSampler(const SamplerInfo &info) {
|
|
return CC_NEW(Sampler(info));
|
|
}
|
|
|
|
GlobalBarrier *EmptyDevice::createGlobalBarrier(const GlobalBarrierInfo &info) {
|
|
return CC_NEW(GlobalBarrier(info));
|
|
}
|
|
|
|
TextureBarrier *EmptyDevice::createTextureBarrier(const TextureBarrierInfo &info) {
|
|
return CC_NEW(TextureBarrier(info));
|
|
}
|
|
|
|
void EmptyDevice::copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint count) {
|
|
}
|
|
|
|
void EmptyDevice::copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint count) {
|
|
}
|
|
|
|
} // namespace gfx
|
|
} // namespace cc
|