void D3DUniformBuffer::upload_data(const GraphicContextPtr &gc, const void *data, int data_size) { if (data_size != size) throw Exception("Upload data size does not match vertex array buffer"); auto d3d_window = static_cast<D3DGraphicContext*>(gc.get())->get_window(); const auto &device = d3d_window->get_device(); const auto &device_context = d3d_window->get_device_context(); device_context->UpdateSubresource(get_handles(device).buffer, 0, 0, data, 0, 0); }
void D3DUniformBuffer::copy_to(const GraphicContextPtr &gc, const StagingBufferPtr &buffer, int dest_pos, int src_pos, int copy_size) { auto d3d_window = static_cast<D3DGraphicContext*>(gc.get())->get_window(); const auto &device = d3d_window->get_device(); const auto &device_context = d3d_window->get_device_context(); ComPtr<ID3D11Buffer> &staging_buffer = static_cast<D3DStagingBuffer*>(buffer.get())->get_buffer(device); int staging_buffer_size = static_cast<D3DStagingBuffer*>(buffer.get())->get_size(); if (copy_size == -1) copy_size = staging_buffer_size; if (dest_pos < 0 || copy_size < 0 || dest_pos + copy_size > staging_buffer_size || src_pos < 0 || src_pos + copy_size > size) throw Exception("Out of bounds!"); D3D11_BOX box; box.left = dest_pos; box.right = dest_pos + copy_size; box.top = 0; box.bottom = 1; box.front = 0; box.back = 1; device_context->CopySubresourceRegion(staging_buffer, 0, src_pos, 0, 0, get_handles(device).buffer, 0, &box); }
std::shared_ptr<StagingBuffer> StagingBuffer::create(const GraphicContextPtr &gc, const void *data, int size, BufferUsage usage) { return static_cast<GraphicContextImpl*>(gc.get())->create_staging_buffer(data, size, usage); }
std::shared_ptr<Texture2DArray> Texture2DArray::create(const GraphicContextPtr &context, int width, int height, int array_size, TextureFormat texture_format, int levels) { return static_cast<GraphicContextImpl*>(context.get())->create_texture_2d_array(width, height, array_size, texture_format, levels); }
std::shared_ptr<Texture2D> Texture2D::create(const GraphicContextPtr &context, int width, int height, TextureFormat format, int levels) { return static_cast<GraphicContextImpl*>(context.get())->create_texture_2d(width, height, format, levels); }
std::shared_ptr<FrameBuffer> FrameBuffer::create(const GraphicContextPtr &gc) { return static_cast<GraphicContextImpl*>(gc.get())->create_frame_buffer(); }
std::shared_ptr<ElementArrayBuffer> ElementArrayBuffer::create(const GraphicContextPtr &gc, const void *data, int size, BufferUsage usage) { return static_cast<GraphicContextImpl*>(gc.get())->create_element_array_buffer(data, size, usage); }