Commit d47428e2 authored by David E. DeMarle's avatar David E. DeMarle
Browse files

WIP: HACK in a fix for cinema multiblock

Never commit.

What I've done is made sure that compositepolydatamapper sets up
the valuehelper state for each of the blocks inside. Trickier thing
was to make sure that the value arrays correspond to the merged together
arrays that CPDM puts together from the points and cells of its blocks.
Have not attempted to fix cell aligned value arrays.
parent f2c5945d
......@@ -42,6 +42,11 @@
#include "vtkShaderProgram.h"
#include "vtkTextureObject.h"
#if GL_ES_VERSION_2_0 != 1 && GL_ES_VERSION_3_0 != 1
#include "vtkValuePass.h"
#include "vtkValuePassHelper.h"
#endif
#include <algorithm>
#include <sstream>
......@@ -363,7 +368,6 @@ void vtkCompositeMapperHelper2::RenderPiece(vtkRenderer* ren, vtkActor *actor)
}
this->CurrentInput = this->Data.begin()->first;
this->RenderPieceStart(ren, actor);
this->RenderPieceDraw(ren, actor);
this->RenderPieceFinish(ren, actor);
......@@ -412,8 +416,11 @@ void vtkCompositeMapperHelper2::DrawIBO(
prog->SetUniform3f("ambientColorUniform", ambientColor);
}
int i = 0;
for (dataIter it = this->Data.begin(); it != this->Data.end(); )
{
dataIter itnow = it;
cerr << "LOOP CNT " << i++ << endl;
vtkCompositeMapperHelperData *starthdata = it->second;
vtkCompositeMapperHelperData *endhdata = starthdata;
do
......@@ -421,13 +428,29 @@ void vtkCompositeMapperHelper2::DrawIBO(
endhdata = it->second;
it++;
}
while (it != this->Data.end() &&
while (false && //prevent it from trying to accumulate blocks in VP mode
it != this->Data.end() &&
!(this->HaveAppleBug && haveCellTexture) &&
!endhdata->Different(it->second, this->CurrentSelector,
haveCellTexture ? primType : -1));
if (endhdata->Visibility &&
endhdata->NextIndex[primType] > starthdata->StartIndex[primType])
{
#if GL_ES_VERSION_2_0 != 1 && GL_ES_VERSION_3_0 != 1
int off = starthdata->PrimOffsets[primType];
if (this->ValuePassHelper->GetRenderingMode() == vtkValuePass::FLOATING_POINT)
{
this->ValuePassHelper->RenderPieceStart(actor, itnow->first, starthdata->StartVertex);
}
if (this->ValuePassHelper->GetRenderingMode() == vtkValuePass::FLOATING_POINT)
{
this->ValuePassHelper->BindAttributes(CellBO, starthdata->PrimOffsets[primType]);
}
#endif
//compilers think this can exceed the bounds so we also
// test against primType even though we should not need to
if (!this->DrawingEdges && primType < 4)
......@@ -445,6 +468,8 @@ void vtkCompositeMapperHelper2::DrawIBO(
}
CellBO.IBO->Release();
}
}
//-----------------------------------------------------------------------------
......@@ -478,6 +503,7 @@ void vtkCompositeMapperHelper2::RenderPieceDraw(
for (int i = PrimitiveStart;
i < (this->CurrentSelector ? PrimitiveTriStrips + 1 : PrimitiveEnd); i++)
{
cerr << "PRIM NUM " << i << endl;
this->DrawingEdges =
draw_surface_with_edges && (i == PrimitiveTrisEdges
|| i == PrimitiveTriStripsEdges);
......@@ -526,7 +552,7 @@ bool vtkCompositeMapperHelper2::GetNeedToRebuildBufferObjects(
{
return true;
}
return false;
return true;
}
//-------------------------------------------------------------------------
......@@ -1406,8 +1432,10 @@ void vtkCompositePolyDataMapper2::Render(
}
int i = 0;
for (helpIter hiter = this->Helpers.begin(); hiter != this->Helpers.end(); hiter++)
{
cerr << "RENDER HELPER " << i++ << endl;
vtkCompositeMapperHelper2 *helper = hiter->second;
helper->RenderPiece(ren,actor);
}
......
......@@ -589,6 +589,7 @@ void vtkOpenGLPolyDataMapper::ReplaceShaderColor(
#if GL_ES_VERSION_2_0 != 1 && GL_ES_VERSION_3_0 != 1
if (this->ValuePassHelper->GetRenderingMode() == vtkValuePass::FLOATING_POINT)
{
cerr << "UPDATE VP SHADERS" << endl;
this->ValuePassHelper->UpdateShaders(VSSource, FSSource, colorImpl);
}
#endif
......@@ -1737,6 +1738,7 @@ void vtkOpenGLPolyDataMapper::UpdateShaders(
fss->SetType(vtkShader::Fragment);
shaders[vtkShader::Fragment] = fss;
cerr << "BUILD SHADERS" << endl;
this->BuildShaders(shaders, ren, actor);
// compile and bind the program if needed
......@@ -1759,6 +1761,7 @@ void vtkOpenGLPolyDataMapper::UpdateShaders(
}
else
{
cerr << "NO NEED TO REBUILD SHADERS" << endl;
renWin->GetShaderCache()->ReadyShaderProgram(cellBO.Program);
}
......@@ -2473,6 +2476,7 @@ void vtkOpenGLPolyDataMapper::RenderPieceStart(vtkRenderer* ren, vtkActor *actor
this->PrimitiveIDOffset = 0;
// make sure the BOs are up to date
cerr << "ABOUT TO UPDATE BUFFER OBJECTS" << endl;
this->UpdateBufferObjects(ren, actor);
if (this->HaveCellScalars || this->HavePickScalars)
......
......@@ -252,6 +252,7 @@ void vtkValuePass::RenderOpaqueGeometry(const vtkRenderState *s)
this->NumberOfRenderedProps += rendered;
++i;
}
cerr << "RENDERED " << i << " props" << endl;
// Remove set keys
i = 0;
......@@ -288,6 +289,7 @@ void vtkValuePass::RenderOpaqueGeometry(const vtkRenderState *s)
//------------------------------------------------------------------------------
void vtkValuePass::BeginPass(vtkRenderer* ren)
{
cerr << "BEGIN PASS" << endl;
switch(this->RenderingMode)
{
case vtkValuePass::FLOATING_POINT:
......@@ -324,6 +326,7 @@ void vtkValuePass::BeginPass(vtkRenderer* ren)
//------------------------------------------------------------------------------
void vtkValuePass::EndPass()
{
cerr << "END" << endl;
switch(this->RenderingMode)
{
case vtkValuePass::FLOATING_POINT:
......
......@@ -123,8 +123,12 @@ void vtkValuePassHelper::RenderPieceFinish()
}
//-----------------------------------------------------------------------------
void vtkValuePassHelper::RenderPieceStart(vtkActor* actor, vtkDataSet* input)
void vtkValuePassHelper::RenderPieceStart(vtkActor* actor, vtkDataSet* input, int offset)
{
if (!actor || !input)
{
return;
}
vtkInformation *info = actor->GetPropertyKeys();
// TODO It should only be necessary to upload the data if something has changed.
......@@ -149,15 +153,23 @@ void vtkValuePassHelper::RenderPieceStart(vtkActor* actor, vtkDataSet* input)
vtkIdType const numTuples = this->Impl->ValuePassArray->GetNumberOfTuples();
int const comp = info->Get(vp::ARRAY_COMPONENT());
cerr << "RenderPiece Start UPLOAD "
<< this->Impl->ValuePassArray->GetName() << " " << comp << " " << numTuples << " "
<< "FOR " << input->GetNumberOfCells() << " " << input->GetNumberOfPoints() << endl;
this->Impl->CurrentValues->SetNumberOfTuples(numTuples);
this->Impl->CurrentValues->CopyComponent(0, this->Impl->ValuePassArray, comp);
float const* data = static_cast<float*>(this->Impl->CurrentValues->GetVoidPointer(0));
vtkDataArray * da = this->Impl->CurrentValues->NewInstance();
da->SetNumberOfComponents(1);
da->SetNumberOfTuples(offset+numTuples);
da->InsertTuples(offset,numTuples,0,this->Impl->CurrentValues.GetPointer());
float const* data = static_cast<float*>(da->GetVoidPointer(0));
// Upload array data
if (this->Impl->CurrentDataArrayMode == VTK_SCALAR_MODE_USE_POINT_FIELD_DATA)
{
// Point data
this->Impl->PointBuffer->Upload(data, static_cast<size_t>(numTuples),
this->Impl->PointBuffer->Upload(data, static_cast<size_t>(numTuples+offset),
vtkOpenGLBufferObject::ArrayBuffer);
}
else
......@@ -169,6 +181,7 @@ void vtkValuePassHelper::RenderPieceStart(vtkActor* actor, vtkDataSet* input)
this->Impl->CellFloatTexture->CreateTextureBuffer(static_cast<unsigned int>(numTuples),
1, VTK_FLOAT, this->Impl->CellFloatBuffer);
}
da->Delete();
}
// Bind textures
......@@ -188,6 +201,12 @@ void vtkValuePassHelper::UpdateConfiguration(vtkRenderer* ren, vtkActor* act,
{
this->RenderingMode = info->Get(vtkValuePass::RENDER_VALUES());
}
cerr << "UpConfig " << "vphelper " << this
<< " actor " << act
<< " mapper " << mapper
<< " pd " << input << " " << input->GetNumberOfCells() << " " << input->GetNumberOfPoints()
<< " RM " << this->RenderingMode
<< endl;
// Configure the mapper's behavior if the ValuePass is active.
if (this->RenderingMode > 0)
......@@ -249,6 +268,7 @@ void vtkValuePassHelper::AllocateGraphicsResources(vtkRenderer* ren)
void vtkValuePassHelper::UpdateShaders(std::string & VSSource, std::string & FSSource,
std::string & required)
{
cerr << "UPSHADERS" << endl;
// Pass the value pass attribute to the fragment shader.
vtkShaderProgram::Substitute(VSSource, "//VTK::ValuePass::Dec",
"attribute float dataAttribute;\n"
......@@ -291,7 +311,7 @@ void vtkValuePassHelper::UpdateShaders(std::string & VSSource, std::string & FSS
}
//-----------------------------------------------------------------------------
void vtkValuePassHelper::BindAttributes(vtkOpenGLHelper& cellBO)
void vtkValuePassHelper::BindAttributes(vtkOpenGLHelper& cellBO, int offset)
{
if (this->Impl->CurrentDataArrayMode == VTK_SCALAR_MODE_USE_POINT_FIELD_DATA)
{
......@@ -299,6 +319,7 @@ void vtkValuePassHelper::BindAttributes(vtkOpenGLHelper& cellBO)
{
if (cellBO.Program->IsAttributeUsed("dataAttribute"))
{
cerr << "BIND " << this->Impl->ValuePassArray->GetNumberOfTuples() << " " << offset << endl;
size_t const stride = sizeof(float);
if (!cellBO.VAO->AddAttributeArray(cellBO.Program, this->Impl->PointBuffer,
......@@ -327,10 +348,10 @@ void vtkValuePassHelper::BindUniforms(vtkOpenGLHelper& cellBO)
//-----------------------------------------------------------------------------
bool vtkValuePassHelper::RequiresShaderRebuild()
{
if (this->RenderingMode == vtkValuePass::FLOATING_POINT &&
this->Impl->CurrentDataArrayMode != this->Impl->LastDataArrayMode)
this->Impl->LastDataArrayMode = this->Impl->CurrentDataArrayMode;
if (this->RenderingMode == vtkValuePass::FLOATING_POINT)
{
this->Impl->LastDataArrayMode = this->Impl->CurrentDataArrayMode;
return true;
}
......
......@@ -51,6 +51,7 @@ class vtkPolyData;
class VTKRENDERINGOPENGL2_EXPORT vtkValuePassHelper : public vtkObject
{
friend class vtkCompositePolyDataMapper2;
friend class vtkOpenGLPolyDataMapper;
public:
......@@ -59,8 +60,6 @@ public:
vtkTypeMacro(vtkValuePassHelper, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
protected:
vtkValuePassHelper();
~vtkValuePassHelper();
......@@ -76,7 +75,7 @@ protected:
/**
* Upload new data if necessary, bind textures, etc.
*/
void RenderPieceStart(vtkActor* actor, vtkDataSet* input);
void RenderPieceStart(vtkActor* actor, vtkDataSet* input, int offset =0);
/**
* Add necessary shader definitions.
......@@ -88,7 +87,7 @@ protected:
/**
* Bind shader variables.
*/
void BindAttributes(vtkOpenGLHelper& cellBO);
void BindAttributes(vtkOpenGLHelper& cellBO, int offset=0);
void BindUniforms(vtkOpenGLHelper& cellBO);
//@}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment