2012-08-22 23:22:08 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-08-22 23:22:08 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
|
|
// with the following modification; you may not use this file except in
|
|
|
|
// compliance with the Apache License and the following modification to it:
|
|
|
|
// Section 6. Trademarks. is deleted and replaced with:
|
2012-08-22 23:22:08 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 6. Trademarks. This License does not grant permission to use the trade
|
|
|
|
// names, trademarks, service marks, or product names of the Licensor
|
|
|
|
// and its affiliates, except as required to comply with Section 4(c) of
|
|
|
|
// the License and to reproduce the content of the NOTICE file.
|
2012-08-22 23:22:08 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2012-08-22 23:22:08 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the Apache License with the above modification is
|
|
|
|
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
// KIND, either express or implied. See the Apache License for the specific
|
|
|
|
// language governing permissions and limitations under the Apache License.
|
2013-05-17 17:21:38 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#ifndef OSD_D3D11L_DRAW_CONTEXT_H
|
|
|
|
#define OSD_D3D11L_DRAW_CONTEXT_H
|
2012-08-22 23:22:08 +00:00
|
|
|
|
|
|
|
#include "../version.h"
|
|
|
|
|
|
|
|
#include "../far/mesh.h"
|
2012-12-11 01:15:13 +00:00
|
|
|
#include "../osd/drawContext.h"
|
2012-08-22 23:22:08 +00:00
|
|
|
#include "../osd/vertex.h"
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#include <map>
|
2012-08-22 23:22:08 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
struct ID3D11VertexShader;
|
|
|
|
struct ID3D11HullShader;
|
|
|
|
struct ID3D11DomainShader;
|
|
|
|
struct ID3D11GeometryShader;
|
|
|
|
struct ID3D11PixelShader;
|
2012-08-22 23:22:08 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
struct ID3D11Buffer;
|
|
|
|
struct ID3D11ShaderResourceView;
|
|
|
|
struct ID3D11Device;
|
|
|
|
struct ID3D11DeviceContext;
|
2012-08-22 23:22:08 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
2012-08-22 23:22:08 +00:00
|
|
|
|
2013-05-17 17:21:38 +00:00
|
|
|
/// \brief D3D11 specialized DrawContext class
|
|
|
|
///
|
|
|
|
/// OsdD3D11DrawContext implements the OSD drawing interface with Microsoft(c)
|
|
|
|
/// DirectX D3D11 API.
|
|
|
|
/// Some functionality may be disabled depending on compile and run-time driver
|
|
|
|
/// support.
|
|
|
|
///
|
|
|
|
/// Contexts interface the serialized topological data pertaining to the
|
|
|
|
/// geometric primitives with the capabilities of the selected discrete
|
|
|
|
/// compute device.
|
|
|
|
///
|
2012-12-11 01:15:13 +00:00
|
|
|
class OsdD3D11DrawContext : public OsdDrawContext {
|
2012-08-22 23:22:08 +00:00
|
|
|
public:
|
2012-12-11 01:15:13 +00:00
|
|
|
typedef ID3D11Buffer * VertexBufferBinding;
|
|
|
|
|
|
|
|
virtual ~OsdD3D11DrawContext();
|
|
|
|
|
2013-07-05 22:35:06 +00:00
|
|
|
/// \brief Create an OsdD3D11DrawContext from FarPatchTables
|
2013-05-17 20:30:43 +00:00
|
|
|
///
|
|
|
|
/// @param patchTables a valid set of FarPatchTables
|
|
|
|
///
|
|
|
|
/// @param pd3d11DeviceContext a device context
|
|
|
|
///
|
|
|
|
/// @param requireFVarData set to true to enable face-varying data to be
|
|
|
|
/// carried over from the Far data structures.
|
|
|
|
///
|
2013-05-14 01:43:05 +00:00
|
|
|
///
|
|
|
|
static OsdD3D11DrawContext *Create(FarPatchTables const *patchTables,
|
|
|
|
ID3D11DeviceContext *pd3d11DeviceContext,
|
|
|
|
bool requireFVarData=false);
|
|
|
|
|
|
|
|
/// Set vbo as a vertex texture (for gregory patch drawing)
|
2013-05-17 20:30:43 +00:00
|
|
|
///
|
|
|
|
/// @param vbo the vertex buffer object to update
|
|
|
|
///
|
|
|
|
/// @param pd3d11DeviceContext a device context
|
|
|
|
///
|
2012-12-11 01:15:13 +00:00
|
|
|
template<class VERTEX_BUFFER>
|
2013-05-14 17:48:48 +00:00
|
|
|
void UpdateVertexTexture(VERTEX_BUFFER *vbo, ID3D11DeviceContext *pd3d11DeviceContext) {
|
2013-09-05 20:09:54 +00:00
|
|
|
if (vbo)
|
|
|
|
updateVertexTexture(vbo->BindD3D11Buffer(pd3d11DeviceContext),
|
|
|
|
pd3d11DeviceContext,
|
|
|
|
vbo->GetNumVertices(),
|
|
|
|
vbo->GetNumElements());
|
2012-12-11 01:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ID3D11Buffer *patchIndexBuffer;
|
|
|
|
|
|
|
|
ID3D11Buffer *ptexCoordinateBuffer;
|
2013-05-14 01:43:05 +00:00
|
|
|
ID3D11ShaderResourceView *ptexCoordinateBufferSRV;
|
2012-12-11 01:15:13 +00:00
|
|
|
ID3D11Buffer *fvarDataBuffer;
|
|
|
|
ID3D11Buffer *fvarDataBufferSRV;
|
|
|
|
|
|
|
|
ID3D11ShaderResourceView *vertexBufferSRV;
|
|
|
|
ID3D11Buffer *vertexValenceBuffer;
|
|
|
|
ID3D11ShaderResourceView *vertexValenceBufferSRV;
|
|
|
|
ID3D11Buffer *quadOffsetBuffer;
|
|
|
|
ID3D11ShaderResourceView *quadOffsetBufferSRV;
|
|
|
|
|
|
|
|
private:
|
2013-05-14 01:43:05 +00:00
|
|
|
OsdD3D11DrawContext();
|
|
|
|
|
|
|
|
// allocate buffers from patchTables
|
2013-05-17 20:30:43 +00:00
|
|
|
bool create(FarPatchTables const *patchTables,
|
|
|
|
ID3D11DeviceContext *pd3d11DeviceContext,
|
|
|
|
bool requireFVarData);
|
2013-05-14 01:43:05 +00:00
|
|
|
|
|
|
|
void updateVertexTexture(ID3D11Buffer *vbo,
|
|
|
|
ID3D11DeviceContext *pd3d11DeviceContext,
|
|
|
|
int numVertices,
|
|
|
|
int numElements);
|
|
|
|
|
|
|
|
int _numVertices;
|
2012-08-22 23:22:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
|
|
|
|
} // end namespace OpenSubdiv
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#endif /* OSD_D3D11L_DRAW_CONTEXT_H */
|