From ed37dcbc175d07134cb0493f5e379a19e97c82f5 Mon Sep 17 00:00:00 2001 From: lucy96chen <47800040+lucy96chen@users.noreply.github.com> Date: Wed, 27 Jul 2022 15:53:36 -0700 Subject: Split render-cpu into smaller files (#2340) * render-cpu split, does not compile * split finished, one compile error * added missing include and missing destructor implementation * Rerun TeamCity CI --- tools/gfx/cpu/cpu-buffer.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tools/gfx/cpu/cpu-buffer.cpp (limited to 'tools/gfx/cpu/cpu-buffer.cpp') diff --git a/tools/gfx/cpu/cpu-buffer.cpp b/tools/gfx/cpu/cpu-buffer.cpp new file mode 100644 index 000000000..2c9c3077d --- /dev/null +++ b/tools/gfx/cpu/cpu-buffer.cpp @@ -0,0 +1,54 @@ +// cpu-buffer.cpp +#include "cpu-buffer.h" + +namespace gfx +{ +using namespace Slang; + +namespace cpu +{ + +BufferResourceImpl::~BufferResourceImpl() +{ + if (m_data) + { + free(m_data); + } +} + +Result BufferResourceImpl::init() +{ + m_data = malloc(m_desc.sizeInBytes); + if (!m_data) + return SLANG_E_OUT_OF_MEMORY; + return SLANG_OK; +} + +Result BufferResourceImpl::setData(size_t offset, size_t size, void const* data) +{ + memcpy((char*)m_data + offset, data, size); + return SLANG_OK; +} + +SLANG_NO_THROW DeviceAddress SLANG_MCALL BufferResourceImpl::getDeviceAddress() +{ + return (DeviceAddress)m_data; +} + +SLANG_NO_THROW Result SLANG_MCALL + BufferResourceImpl::map(MemoryRange* rangeToRead, void** outPointer) +{ + SLANG_UNUSED(rangeToRead); + if (outPointer) + *outPointer = m_data; + return SLANG_OK; +} + +SLANG_NO_THROW Result SLANG_MCALL BufferResourceImpl::unmap(MemoryRange* writtenRange) +{ + SLANG_UNUSED(writtenRange); + return SLANG_OK; +} + +} // namespace cpu +} // namespace gfx -- cgit v1.2.3