Commit 9acc86b8 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri Committed by Sean McBride

Fix clear shader replacement issue

The replacement would never be erased because of a faulty if check.
Added test code to the relevant tests for regression testing in the
future.

(cherry picked from commit f4f12b96)
parent 1e45e062
...@@ -88,6 +88,18 @@ int TestUserShader(int argc, char *argv[]) ...@@ -88,6 +88,18 @@ int TestUserShader(int argc, char *argv[])
" myNormalMCVSOutput = normalMC;\n", //but we add this " myNormalMCVSOutput = normalMC;\n", //but we add this
false // only do it once false // only do it once
); );
mapper->AddShaderReplacement(
vtkShader::Vertex,
"//VTK::Color::Impl", // dummy replacement for testing clear method
true,
"VTK::Color::Impl\n",
false
);
mapper->ClearShaderReplacement(
vtkShader::Vertex, // clear our dummy replacement
"//VTK::Color::Impl",
true
);
// now modify the fragment shader // now modify the fragment shader
mapper->AddShaderReplacement( mapper->AddShaderReplacement(
......
...@@ -254,7 +254,7 @@ void vtkOpenGLPolyDataMapper::ClearShaderReplacement( ...@@ -254,7 +254,7 @@ void vtkOpenGLPolyDataMapper::ClearShaderReplacement(
typedef std::map<const vtkShader::ReplacementSpec, typedef std::map<const vtkShader::ReplacementSpec,
vtkShader::ReplacementValue>::iterator RIter; vtkShader::ReplacementValue>::iterator RIter;
RIter found = this->UserShaderReplacements.find(spec); RIter found = this->UserShaderReplacements.find(spec);
if (found == this->UserShaderReplacements.end()) if (found != this->UserShaderReplacements.end())
{ {
this->UserShaderReplacements.erase(found); this->UserShaderReplacements.erase(found);
this->Modified(); this->Modified();
......
...@@ -125,6 +125,16 @@ int TestGPURayCastUserShader(int argc, char* argv[]) ...@@ -125,6 +125,16 @@ int TestGPURayCastUserShader(int argc, char* argv[])
"\n (gl_DepthRange.far + gl_DepthRange.near)), 1.0);" "\n (gl_DepthRange.far + gl_DepthRange.near)), 1.0);"
"\n }", "\n }",
false); false);
mapper->AddShaderReplacement(
vtkShader::Fragment, // dummy replacement to test clear method
"//VTK::ComputeGradient::Dec",
true,
"VTK::ComputeGradient::Dec",
false);
mapper->ClearShaderReplacement(
vtkShader::Fragment, // clear the dummy replacement
"//VTK::ComputeGradient::Dec",
true);
vtkNew<vtkVolume> volume; vtkNew<vtkVolume> volume;
volume->SetMapper(mapper.GetPointer()); volume->SetMapper(mapper.GetPointer());
......
...@@ -3042,7 +3042,7 @@ void vtkOpenGLGPUVolumeRayCastMapper::ClearShaderReplacement( ...@@ -3042,7 +3042,7 @@ void vtkOpenGLGPUVolumeRayCastMapper::ClearShaderReplacement(
typedef std::map<const vtkShader::ReplacementSpec, typedef std::map<const vtkShader::ReplacementSpec,
vtkShader::ReplacementValue>::iterator RIter; vtkShader::ReplacementValue>::iterator RIter;
RIter found = this->UserShaderReplacements.find(spec); RIter found = this->UserShaderReplacements.find(spec);
if (found == this->UserShaderReplacements.end()) if (found != this->UserShaderReplacements.end())
{ {
this->UserShaderReplacements.erase(found); this->UserShaderReplacements.erase(found);
} }
......
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