Review: bug fix with shaders that have no 'main' instructions (issue193098)


larry...@...
 

Reviewers: ,

Description:
It's possible to write a shader that has no instructions in the main
program, but merely shuffles input params into output params (this is in
fact done for certain "glue nodes" in shader networks).

Due to a bug (mine), we never set the master's "maincodebegin" and
"maincodeend" members, unless there actually was main code (which is the
case for 99% of shaders, but...). Hilarity ensues. And multi-day bug
hunts.

Simple fix attached to initialize these, as well as a couple DASSERTS
that I may as well leave in.


Please review this at http://codereview.appspot.com/193098/show

Affected files:
src/liboslexec/exec.cpp
src/liboslexec/loadshader.cpp
src/liboslexec/master.cpp


Index: src/liboslexec/loadshader.cpp
===================================================================
--- src/liboslexec/loadshader.cpp (revision 547)
+++ src/liboslexec/loadshader.cpp (working copy)
@@ -96,6 +96,8 @@
OSOReaderToMaster::parse (const std::string &filename)
{
m_master->m_osofilename = filename;
+ m_master->m_maincodebegin = 0;
+ m_master->m_maincodeend = 0;
m_codesection.clear ();
m_codesym = -1;
return OSOReader::parse (filename);
Index: src/liboslexec/exec.cpp
===================================================================
--- src/liboslexec/exec.cpp (revision 544)
+++ src/liboslexec/exec.cpp (working copy)
@@ -521,6 +521,7 @@
beginop, endop);
const int *args = &m_master->m_args[0];
for (m_ip = beginop; m_ip < endop && m_beginpoint < m_endpoint; ++m_ip) {
+ DASSERT (m_ip >= 0 && m_ip < (int)m_master->m_ops.size());
Opcode &op (this->op ());
#if 0
if (m_debug) {
Index: src/liboslexec/master.cpp
===================================================================
--- src/liboslexec/master.cpp (revision 544)
+++ src/liboslexec/master.cpp (working copy)
@@ -365,6 +365,7 @@
op.implementation (found->second);
else
op.implementation (OP_missing);
+ DASSERT (op.implementation() != NULL);
}
}

Join osl-dev@lists.aswf.io to automatically receive all group messages.