cleanup remaining ptex specific code in osd layer

- Remove MeshPtexData bit from Osd::MeshBits. It's not used any more
- Rename ptexIndexBuffer in D3D11DrawContext to paramParamBuffer
- Remove Is/SetPtexEnabled from D3D11DrawRegistry
This commit is contained in:
Takahito Tejima 2015-05-11 10:59:16 -07:00
parent 41df98c9cc
commit 94d6eb6491
8 changed files with 33 additions and 41 deletions

View File

@ -909,10 +909,13 @@ bindProgram(Effect effect, OpenSubdiv::Osd::DrawContext::PatchArray const & patc
if (g_mesh->GetDrawContext()->quadOffsetBufferSRV) {
g_pd3dDeviceContext->HSSetShaderResources(2, 1, &g_mesh->GetDrawContext()->quadOffsetBufferSRV);
}
if (g_mesh->GetDrawContext()->ptexCoordinateBufferSRV) {
g_pd3dDeviceContext->HSSetShaderResources(3, 1, &g_mesh->GetDrawContext()->ptexCoordinateBufferSRV);
g_pd3dDeviceContext->DSSetShaderResources(3, 1, &g_mesh->GetDrawContext()->ptexCoordinateBufferSRV);
g_pd3dDeviceContext->GSSetShaderResources(3, 1, &g_mesh->GetDrawContext()->ptexCoordinateBufferSRV);
if (g_mesh->GetDrawContext()->patchParamBufferSRV) {
g_pd3dDeviceContext->HSSetShaderResources(
3, 1, &g_mesh->GetDrawContext()->patchParamBufferSRV);
g_pd3dDeviceContext->DSSetShaderResources(
3, 1, &g_mesh->GetDrawContext()->patchParamBufferSRV);
g_pd3dDeviceContext->GSSetShaderResources(
3, 1, &g_mesh->GetDrawContext()->patchParamBufferSRV);
}
g_pd3dDeviceContext->PSSetShaderResources(4, 1, g_osdPTexImage->GetTexelsSRV());

View File

@ -762,9 +762,11 @@ bindProgram(Effect effect, OpenSubdiv::Osd::DrawContext::PatchArray const & patc
if (g_mesh->GetDrawContext()->quadOffsetBufferSRV) {
g_pd3dDeviceContext->HSSetShaderResources(2, 1, &g_mesh->GetDrawContext()->quadOffsetBufferSRV);
}
if (g_mesh->GetDrawContext()->ptexCoordinateBufferSRV) {
g_pd3dDeviceContext->HSSetShaderResources(3, 1, &g_mesh->GetDrawContext()->ptexCoordinateBufferSRV);
g_pd3dDeviceContext->DSSetShaderResources(3, 1, &g_mesh->GetDrawContext()->ptexCoordinateBufferSRV);
if (g_mesh->GetDrawContext()->patchParamBufferSRV) {
g_pd3dDeviceContext->HSSetShaderResources(
3, 1, &g_mesh->GetDrawContext()->patchParamBufferSRV);
g_pd3dDeviceContext->DSSetShaderResources(
3, 1, &g_mesh->GetDrawContext()->patchParamBufferSRV);
}
}

View File

@ -236,7 +236,6 @@ createOsdMesh() {
bool doAdaptive = true;
OpenSubdiv::Osd::MeshBitset bits;
bits.set(OpenSubdiv::Osd::MeshAdaptive, doAdaptive);
bits.set(OpenSubdiv::Osd::MeshPtexData, true);
g_mesh = new OpenSubdiv::Osd::Mesh<OpenSubdiv::Osd::CpuGLVertexBuffer,
OpenSubdiv::Far::StencilTables,

View File

@ -1005,7 +1005,6 @@ createOsdMesh(int level, int kernel) {
OpenSubdiv::Osd::MeshBitset bits;
bits.set(OpenSubdiv::Osd::MeshAdaptive, doAdaptive);
bits.set(OpenSubdiv::Osd::MeshPtexData, true);
bits.set(OpenSubdiv::Osd::MeshEndCapGregoryBasis, true);
int numVertexElements = g_adaptive ? 3 : 6;

View File

@ -35,8 +35,8 @@ namespace Osd {
D3D11DrawContext::D3D11DrawContext() :
patchIndexBuffer(NULL),
ptexCoordinateBuffer(NULL),
ptexCoordinateBufferSRV(NULL),
patchParamBuffer(NULL),
patchParamBufferSRV(NULL),
fvarDataBuffer(NULL),
fvarDataBufferSRV(NULL),
vertexBufferSRV(NULL),
@ -50,8 +50,8 @@ D3D11DrawContext::D3D11DrawContext() :
D3D11DrawContext::~D3D11DrawContext()
{
if (patchIndexBuffer) patchIndexBuffer->Release();
if (ptexCoordinateBuffer) ptexCoordinateBuffer->Release();
if (ptexCoordinateBufferSRV) ptexCoordinateBufferSRV->Release();
if (patchParamBuffer) patchParamBuffer->Release();
if (patchParamBufferSRV) patchParamBufferSRV->Release();
if (fvarDataBuffer) fvarDataBuffer->Release();
if (fvarDataBufferSRV) fvarDataBufferSRV->Release();
if (vertexBufferSRV) vertexBufferSRV->Release();
@ -116,7 +116,7 @@ D3D11DrawContext::create(Far::PatchTables const &patchTables,
// allocate and initialize additional buffer data
// create ptex coordinate buffer
// create patch param buffer
Far::PatchParamTable const & patchParamTables =
patchTables.GetPatchParamTable();
@ -144,7 +144,7 @@ D3D11DrawContext::create(Far::PatchTables const &patchTables,
bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
bd.MiscFlags = 0;
bd.StructureByteStride = sizeof(unsigned int);
hr = pd3d11Device->CreateBuffer(&bd, NULL, &ptexCoordinateBuffer);
hr = pd3d11Device->CreateBuffer(&bd, NULL, &patchParamBuffer);
if (FAILED(hr)) {
return false;
}
@ -155,17 +155,18 @@ D3D11DrawContext::create(Far::PatchTables const &patchTables,
srvd.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
srvd.Buffer.FirstElement = 0;
srvd.Buffer.NumElements = numElements;
hr = pd3d11Device->CreateShaderResourceView(ptexCoordinateBuffer, &srvd, &ptexCoordinateBufferSRV);
hr = pd3d11Device->CreateShaderResourceView(
patchParamBuffer, &srvd, &patchParamBufferSRV);
if (FAILED(hr)) {
return false;
}
hr = pd3d11DeviceContext->Map(ptexCoordinateBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
hr = pd3d11DeviceContext->Map(patchParamBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(hr)) {
return false;
}
unsigned int * ptexBuffer = (unsigned int *) mappedResource.pData;
memcpy(ptexBuffer, values, numElements * elementSize);
pd3d11DeviceContext->Unmap(ptexCoordinateBuffer, 0);
unsigned int *dst = (unsigned int *) mappedResource.pData;
memcpy(dst, values, numElements * elementSize);
pd3d11DeviceContext->Unmap(patchParamBuffer, 0);
}
// create vertex valence buffer and vertex texture

View File

@ -108,8 +108,8 @@ public:
ID3D11Buffer *patchIndexBuffer;
ID3D11Buffer *ptexCoordinateBuffer;
ID3D11ShaderResourceView *ptexCoordinateBufferSRV;
ID3D11Buffer *patchParamBuffer;
ID3D11ShaderResourceView *patchParamBufferSRV;
ID3D11Buffer *fvarDataBuffer;
ID3D11ShaderResourceView *fvarDataBufferSRV;

View File

@ -84,18 +84,10 @@ public:
typedef D3D11DrawConfig ConfigType;
typedef D3D11DrawSourceConfig SourceConfigType;
D3D11DrawRegistryBase(bool enablePtex=false) : _enablePtex(enablePtex) { }
D3D11DrawRegistryBase() { }
virtual ~D3D11DrawRegistryBase();
bool IsPtexEnabled() const {
return _enablePtex;
}
void SetPtexEnabled(bool b) {
_enablePtex=b;
}
protected:
virtual ConfigType * _NewDrawConfig() { return new ConfigType(); }
virtual ConfigType *
@ -109,9 +101,6 @@ protected:
virtual SourceConfigType * _NewDrawSourceConfig() { return new SourceConfigType(); }
virtual SourceConfigType *
_CreateDrawSourceConfig(DescType const & desc, ID3D11Device * pd3dDevice);
private:
bool _enablePtex;
};
//------------------------------------------------------------------------------

View File

@ -49,13 +49,12 @@ namespace Osd {
enum MeshBits {
MeshAdaptive = 0,
MeshInterleaveVarying = 1,
MeshPtexData = 2,
MeshFVarData = 3,
MeshUseSingleCreasePatch = 4,
MeshEndCapBSplineBasis = 5, // exclusive
MeshEndCapGregoryBasis = 6, // exclusive
MeshEndCapLegacyGregory = 7, // exclusive
NUM_MESH_BITS = 8,
MeshFVarData = 2,
MeshUseSingleCreasePatch = 3,
MeshEndCapBSplineBasis = 4, // exclusive
MeshEndCapGregoryBasis = 5, // exclusive
MeshEndCapLegacyGregory = 6, // exclusive
NUM_MESH_BITS = 7,
};
typedef std::bitset<NUM_MESH_BITS> MeshBitset;