OpenSubdiv: opensubdiv/osd/cpuD3D11VertexBuffer.h Source File

| OpenSubdiv

Loading...
Searching...
No Matches
cpuD3D11VertexBuffer.h
Go to the documentation of this file.
1//
2// Copyright 2013 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_OSD_CPU_D3D11_VERTEX_BUFFER_H
9#define OPENSUBDIV3_OSD_CPU_D3D11_VERTEX_BUFFER_H
10
11#include "../version.h"
12#include <cstddef>
13
14struct ID3D11Buffer;
15struct ID3D11Device;
16struct ID3D11DeviceContext;
17
18namespace OpenSubdiv {
19namespace OPENSUBDIV_VERSION {
20
21namespace Osd {
22
31 class CpuD3D11VertexBuffer {
32public:
34 static CpuD3D11VertexBuffer * Create(int numElements, int numVertices,
35 ID3D11DeviceContext *deviceContext);
36
38 virtual ~CpuD3D11VertexBuffer();
39
42 void UpdateData(const float *src, int startVertex, int numVertices,
43 void *deviceContext = NULL);
44
46 int GetNumElements() const;
47
49 int GetNumVertices() const;
50
52 float * BindCpuBuffer();
53
55 ID3D11Buffer *BindD3D11Buffer(ID3D11DeviceContext *deviceContext);
56
58 ID3D11Buffer *BindVBO(ID3D11DeviceContext *deviceContext) {
59 return BindD3D11Buffer(deviceContext);
60 }
61
62protected:
64 CpuD3D11VertexBuffer(int numElements, int numVertices);
65
66 bool allocate(ID3D11Device *device);
67
68private:
69 int _numElements;
70 int _numVertices;
71 ID3D11Buffer *_d3d11Buffer;
72 float *_cpuBuffer;
73};
74
75} // end namespace Osd
76
77} // end namespace OPENSUBDIV_VERSION
78using namespace OPENSUBDIV_VERSION;
79
80} // end namespace OpenSubdiv
81
82#endif // OPENSUBDIV3_OSD_CPU_D3D11_VERTEX_BUFFER_H
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Osd
Definition bufferDescriptor.h:17
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuD3D11VertexBuffer::Create
static CpuD3D11VertexBuffer * Create(int numElements, int numVertices, ID3D11DeviceContext *deviceContext)
Creator. Returns NULL if error.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuD3D11VertexBuffer::CpuD3D11VertexBuffer
CpuD3D11VertexBuffer(int numElements, int numVertices)
Constructor.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuD3D11VertexBuffer::GetNumElements
int GetNumElements() const
Returns how many elements defined in this vertex buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuD3D11VertexBuffer::UpdateData
void UpdateData(const float *src, int startVertex, int numVertices, void *deviceContext=NULL)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuD3D11VertexBuffer::GetNumVertices
int GetNumVertices() const
Returns how many vertices allocated in this vertex buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuD3D11VertexBuffer::BindD3D11Buffer
ID3D11Buffer * BindD3D11Buffer(ID3D11DeviceContext *deviceContext)
Returns the D3D11 buffer object.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuD3D11VertexBuffer::BindCpuBuffer
float * BindCpuBuffer()
Returns the address of CPU buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuD3D11VertexBuffer::allocate
bool allocate(ID3D11Device *device)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuD3D11VertexBuffer::~CpuD3D11VertexBuffer
virtual ~CpuD3D11VertexBuffer()
Destructor.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuD3D11VertexBuffer::BindVBO
ID3D11Buffer * BindVBO(ID3D11DeviceContext *deviceContext)
Returns the D3D11 buffer object (for Osd::Mesh interface).
Definition cpuD3D11VertexBuffer.h:58