Skip to content

Commit

Permalink
GFX Descriptor Set: GLES2
Browse files Browse the repository at this point in the history
  • Loading branch information
YunHsiao committed Aug 20, 2020
1 parent 1e945f0 commit c90c536
Show file tree
Hide file tree
Showing 23 changed files with 975 additions and 682 deletions.
4 changes: 2 additions & 2 deletions cocos/renderer/gfx-gles2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ endif()
if(COCOS_PLATFORM_OSX)
list(REMOVE_ITEM ALL_FILES "${COCOS_SRC_PATH}/renderer/gfx-gles2/GLES2Context.mm")
endif()

add_definitions("-DCC_GLES2_EXPORTS")
if(WIN32)
add_definitions("-DGLEW_BUILD")
Expand All @@ -87,4 +87,4 @@ set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME_DEBUG CCGFXGLES2_d)

use_precompiled_header("${CMAKE_CURRENT_SOURCE_DIR}/GLES2Std.h" "${CMAKE_CURRENT_SOURCE_DIR}/GLES2Std.cpp" SOURCE_CPP_FILES)

message(STATUS "${TARGET_NAME} configuration completed.")
message(STATUS "${TARGET_NAME} configuration completed.")
97 changes: 0 additions & 97 deletions cocos/renderer/gfx-gles2/GLES2BindingLayout.cc

This file was deleted.

28 changes: 0 additions & 28 deletions cocos/renderer/gfx-gles2/GLES2BindingLayout.h

This file was deleted.

25 changes: 25 additions & 0 deletions cocos/renderer/gfx-gles2/GLES2Buffer.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "GLES2Std.h"

#include "GLES2Buffer.h"
#include "GLES2Commands.h"

Expand Down Expand Up @@ -57,6 +58,24 @@ bool GLES2Buffer::initialize(const BufferInfo &info) {
return true;
}

bool GLES2Buffer::initialize(const BufferViewInfo &info) {

GLES2Buffer *buffer = (GLES2Buffer *)info.buffer;

_usage = buffer->_usage;
_memUsage = buffer->_memUsage;
_size = _stride = info.range;
_count = 1u;
_flags = buffer->_flags;

_gpuBufferView = CC_NEW(GLES2GPUBufferView);
_gpuBufferView->gpuBuffer = buffer->gpuBuffer();
_gpuBufferView->range = _size;
_gpuBufferView->offset = info.offset;

return true;
}

void GLES2Buffer::destroy() {
if (_gpuBuffer) {
GLES2CmdFuncDestroyBuffer((GLES2Device *)_device, _gpuBuffer);
Expand All @@ -65,6 +84,8 @@ void GLES2Buffer::destroy() {
_gpuBuffer = nullptr;
}

CC_SAFE_DELETE(_gpuBufferView);

if (_buffer) {
CC_FREE(_buffer);
_device->getMemoryStatus().bufferSize -= _size;
Expand All @@ -75,6 +96,8 @@ void GLES2Buffer::destroy() {
}

void GLES2Buffer::resize(uint size) {
CCASSERT(!_gpuBufferView, "Cannot resize buffer views");

if (_size != size) {
const uint oldSize = _size;
_size = size;
Expand Down Expand Up @@ -106,8 +129,10 @@ void GLES2Buffer::resize(uint size) {
}

void GLES2Buffer::update(void *buffer, uint offset, uint size) {
CCASSERT(!_gpuBufferView, "Cannot update through buffer views");
CCASSERT(size != 0, "Should not update buffer with 0 bytes of data");
CCASSERT(buffer, "Buffer should not be nullptr");

if (_buffer) {
memcpy(_buffer + offset, buffer, size);
}
Expand Down
4 changes: 4 additions & 0 deletions cocos/renderer/gfx-gles2/GLES2Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace cc {
namespace gfx {

class GLES2GPUBuffer;
class GLES2GPUBufferView;

class CC_GLES2_API GLES2Buffer : public Buffer {
public:
Expand All @@ -13,14 +14,17 @@ class CC_GLES2_API GLES2Buffer : public Buffer {

public:
virtual bool initialize(const BufferInfo &info) override;
virtual bool initialize(const BufferViewInfo &info) override;
virtual void destroy() override;
virtual void resize(uint size) override;
virtual void update(void *buffer, uint offset, uint size) override;

CC_INLINE GLES2GPUBuffer *gpuBuffer() const { return _gpuBuffer; }
CC_INLINE GLES2GPUBufferView *gpuBufferView() const { return _gpuBufferView; }

private:
GLES2GPUBuffer *_gpuBuffer = nullptr;
GLES2GPUBufferView *_gpuBufferView = nullptr;
};

} // namespace gfx
Expand Down
Loading

0 comments on commit c90c536

Please sign in to comment.