line endings
This commit is contained in:
Родитель
d2f36b0029
Коммит
d4cdab63f9
|
@ -1,190 +1,190 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "InitializeDll.h"
|
||||
#include "../hlslang/Include/InitializeGlobals.h"
|
||||
#include "../hlslang/Include/InitializeParseContext.h"
|
||||
|
||||
#include "../include/hlsl2glsl.h"
|
||||
|
||||
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
|
||||
|
||||
bool InitProcess()
|
||||
{
|
||||
if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX)
|
||||
{
|
||||
//
|
||||
// Function is re-entrant.
|
||||
//
|
||||
return true;
|
||||
}
|
||||
|
||||
ThreadInitializeIndex = OS_AllocTLSIndex();
|
||||
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
|
||||
{
|
||||
assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!InitializePoolIndex())
|
||||
{
|
||||
assert(0 && "InitProcess(): Failed to initalize global pool");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!InitializeParseContextIndex())
|
||||
{
|
||||
assert(0 && "InitProcess(): Failed to initalize parse context");
|
||||
return false;
|
||||
}
|
||||
|
||||
InitThread();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InitThread()
|
||||
{
|
||||
//
|
||||
// This function is re-entrant
|
||||
//
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
|
||||
{
|
||||
assert(0 && "InitThread(): Process hasn't been initalised.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
|
||||
return true;
|
||||
|
||||
InitializeGlobalPools();
|
||||
|
||||
if (!InitializeGlobalParseContext())
|
||||
return false;
|
||||
|
||||
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)1))
|
||||
{
|
||||
assert(0 && "InitThread(): Unable to set init flag.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DetachThread()
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
|
||||
return true;
|
||||
|
||||
//
|
||||
// Function is re-entrant and this thread may not have been initalised.
|
||||
//
|
||||
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
|
||||
{
|
||||
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0))
|
||||
{
|
||||
assert(0 && "DetachThread(): Unable to clear init flag.");
|
||||
success = false;
|
||||
}
|
||||
|
||||
FreeGlobalPools();
|
||||
|
||||
if (!FreeParseContext())
|
||||
success = false;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool DetachProcess()
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
|
||||
return true;
|
||||
|
||||
Hlsl2Glsl_Finalize();
|
||||
|
||||
success = DetachThread();
|
||||
|
||||
FreePoolIndex();
|
||||
|
||||
if (!FreeParseContextIndex())
|
||||
success = false;
|
||||
|
||||
OS_FreeTLSIndex(ThreadInitializeIndex);
|
||||
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "InitializeDll.h"
|
||||
#include "../hlslang/Include/InitializeGlobals.h"
|
||||
#include "../hlslang/Include/InitializeParseContext.h"
|
||||
|
||||
#include "../include/hlsl2glsl.h"
|
||||
|
||||
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
|
||||
|
||||
bool InitProcess()
|
||||
{
|
||||
if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX)
|
||||
{
|
||||
//
|
||||
// Function is re-entrant.
|
||||
//
|
||||
return true;
|
||||
}
|
||||
|
||||
ThreadInitializeIndex = OS_AllocTLSIndex();
|
||||
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
|
||||
{
|
||||
assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!InitializePoolIndex())
|
||||
{
|
||||
assert(0 && "InitProcess(): Failed to initalize global pool");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!InitializeParseContextIndex())
|
||||
{
|
||||
assert(0 && "InitProcess(): Failed to initalize parse context");
|
||||
return false;
|
||||
}
|
||||
|
||||
InitThread();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InitThread()
|
||||
{
|
||||
//
|
||||
// This function is re-entrant
|
||||
//
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
|
||||
{
|
||||
assert(0 && "InitThread(): Process hasn't been initalised.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
|
||||
return true;
|
||||
|
||||
InitializeGlobalPools();
|
||||
|
||||
if (!InitializeGlobalParseContext())
|
||||
return false;
|
||||
|
||||
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)1))
|
||||
{
|
||||
assert(0 && "InitThread(): Unable to set init flag.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DetachThread()
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
|
||||
return true;
|
||||
|
||||
//
|
||||
// Function is re-entrant and this thread may not have been initalised.
|
||||
//
|
||||
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
|
||||
{
|
||||
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0))
|
||||
{
|
||||
assert(0 && "DetachThread(): Unable to clear init flag.");
|
||||
success = false;
|
||||
}
|
||||
|
||||
FreeGlobalPools();
|
||||
|
||||
if (!FreeParseContext())
|
||||
success = false;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool DetachProcess()
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
|
||||
return true;
|
||||
|
||||
Hlsl2Glsl_Finalize();
|
||||
|
||||
success = DetachThread();
|
||||
|
||||
FreePoolIndex();
|
||||
|
||||
if (!FreeParseContextIndex())
|
||||
success = false;
|
||||
|
||||
OS_FreeTLSIndex(ThreadInitializeIndex);
|
||||
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,82 +1,82 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef __INITIALIZEDLL_H
|
||||
#define __INITIALIZEDLL_H
|
||||
|
||||
|
||||
#include "osinclude.h"
|
||||
|
||||
|
||||
bool InitProcess();
|
||||
bool InitThread();
|
||||
bool DetachThread();
|
||||
bool DetachProcess();
|
||||
|
||||
#endif // __INITIALIZEDLL_H
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef __INITIALIZEDLL_H
|
||||
#define __INITIALIZEDLL_H
|
||||
|
||||
|
||||
#include "osinclude.h"
|
||||
|
||||
|
||||
bool InitProcess();
|
||||
bool InitThread();
|
||||
bool DetachThread();
|
||||
bool DetachProcess();
|
||||
|
||||
#endif // __INITIALIZEDLL_H
|
||||
|
||||
|
|
|
@ -1,93 +1,93 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/ShHandle.h"
|
||||
|
||||
#include "hlslCrossCompiler.h"
|
||||
|
||||
|
||||
|
||||
//
|
||||
// This function must be provided to create the actual
|
||||
// compile object used by higher level code. It returns
|
||||
// a subclass of TCompiler.
|
||||
//
|
||||
TCompiler* ConstructCompiler(EShLanguage language, int debugOptions)
|
||||
{
|
||||
return new HlslCrossCompiler(language, debugOptions);
|
||||
}
|
||||
|
||||
//
|
||||
// Delete the compiler made by ConstructCompiler
|
||||
//
|
||||
void DeleteCompiler(TCompiler* compiler)
|
||||
{
|
||||
delete compiler;
|
||||
}
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/ShHandle.h"
|
||||
|
||||
#include "hlslCrossCompiler.h"
|
||||
|
||||
|
||||
|
||||
//
|
||||
// This function must be provided to create the actual
|
||||
// compile object used by higher level code. It returns
|
||||
// a subclass of TCompiler.
|
||||
//
|
||||
TCompiler* ConstructCompiler(EShLanguage language, int debugOptions)
|
||||
{
|
||||
return new HlslCrossCompiler(language, debugOptions);
|
||||
}
|
||||
|
||||
//
|
||||
// Delete the compiler made by ConstructCompiler
|
||||
//
|
||||
void DeleteCompiler(TCompiler* compiler)
|
||||
{
|
||||
delete compiler;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,101 +1,101 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// The top level algorithms for linking multiple
|
||||
// shaders together.
|
||||
//
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/ShHandle.h"
|
||||
|
||||
#include "HlslLinker.h"
|
||||
|
||||
|
||||
|
||||
TShHandleBase* ConstructLinker(int debugOptions)
|
||||
{
|
||||
return new HlslLinker(debugOptions);
|
||||
}
|
||||
|
||||
void DeleteLinker(TShHandleBase* linker)
|
||||
{
|
||||
delete linker;
|
||||
}
|
||||
|
||||
|
||||
|
||||
TShHandleBase* ConstructBindings()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DeleteBindingList(TShHandleBase* bindingList)
|
||||
{
|
||||
delete bindingList;
|
||||
}
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// The top level algorithms for linking multiple
|
||||
// shaders together.
|
||||
//
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/ShHandle.h"
|
||||
|
||||
#include "HlslLinker.h"
|
||||
|
||||
|
||||
|
||||
TShHandleBase* ConstructLinker(int debugOptions)
|
||||
{
|
||||
return new HlslLinker(debugOptions);
|
||||
}
|
||||
|
||||
void DeleteLinker(TShHandleBase* linker)
|
||||
{
|
||||
delete linker;
|
||||
}
|
||||
|
||||
|
||||
|
||||
TShHandleBase* ConstructBindings()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DeleteBindingList(TShHandleBase* bindingList)
|
||||
{
|
||||
delete bindingList;
|
||||
}
|
||||
|
|
|
@ -1,256 +1,256 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of GLSL common utility functions
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
#include "glslStruct.h"
|
||||
|
||||
/// Table to convert GLSL variable types to strings
|
||||
const char typeString[EgstTypeCount][32] =
|
||||
{
|
||||
"void",
|
||||
"bool",
|
||||
"bvec2",
|
||||
"bvec3",
|
||||
"bvec4",
|
||||
"int",
|
||||
"ivec2",
|
||||
"ivec3",
|
||||
"ivec4",
|
||||
"float",
|
||||
"vec2",
|
||||
"vec3",
|
||||
"vec4",
|
||||
"mat2",
|
||||
"mat3",
|
||||
"mat4",
|
||||
"sampler",
|
||||
"sampler1D",
|
||||
"sampler2D",
|
||||
"sampler3D",
|
||||
"samplerCube",
|
||||
"struct"
|
||||
};
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public Functions
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Outputs the type of the symbol to the output buffer
|
||||
/// \param out
|
||||
/// The output buffer to write the type to
|
||||
/// \param type
|
||||
/// The type of the GLSL symbol to output
|
||||
/// \param s
|
||||
/// If it is a structure, a pointer to the structure to write out
|
||||
//=========================================================================================================
|
||||
void writeType( std::stringstream &out, EGlslSymbolType type, GlslStruct *s )
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EgstVoid:
|
||||
case EgstBool:
|
||||
case EgstBool2:
|
||||
case EgstBool3:
|
||||
case EgstBool4:
|
||||
case EgstInt:
|
||||
case EgstInt2:
|
||||
case EgstInt3:
|
||||
case EgstInt4:
|
||||
case EgstFloat:
|
||||
case EgstFloat2:
|
||||
case EgstFloat3:
|
||||
case EgstFloat4:
|
||||
case EgstFloat2x2:
|
||||
case EgstFloat3x3:
|
||||
case EgstFloat4x4:
|
||||
case EgstSamplerGeneric:
|
||||
case EgstSampler1D:
|
||||
case EgstSampler2D:
|
||||
case EgstSampler3D:
|
||||
case EgstSamplerCube:
|
||||
out << typeString[type];
|
||||
break;
|
||||
case EgstStruct:
|
||||
if (s)
|
||||
out << s->getName();
|
||||
else
|
||||
out << "struct";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Gets the type as a string
|
||||
/// \param t
|
||||
/// The type to convert to a string
|
||||
/// \return
|
||||
/// The type converted to a string
|
||||
//=========================================================================================================
|
||||
const char* getTypeString( const EGlslSymbolType t )
|
||||
{
|
||||
assert (t >= EgstVoid && t < EgstTypeCount);
|
||||
return typeString[t];
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Translates the type to a GLSL symbol type
|
||||
/// \param type
|
||||
/// Type to convert to a GLSL symbol
|
||||
/// \return
|
||||
/// The GLSL symbol type associated with the TType
|
||||
//=========================================================================================================
|
||||
EGlslSymbolType translateType( const TType *type )
|
||||
{
|
||||
if ( type->isMatrix() )
|
||||
{
|
||||
switch (type->getNominalSize())
|
||||
{
|
||||
case 2: return EgstFloat2x2;
|
||||
case 3: return EgstFloat3x3;
|
||||
case 4: return EgstFloat4x4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (type->getBasicType())
|
||||
{
|
||||
case EbtVoid:
|
||||
return EgstVoid;
|
||||
case EbtBool:
|
||||
return EGlslSymbolType(EgstBool + (type->getNominalSize() - 1));
|
||||
case EbtInt:
|
||||
return EGlslSymbolType(EgstInt + (type->getNominalSize() - 1));
|
||||
case EbtFloat:
|
||||
return EGlslSymbolType(EgstFloat + (type->getNominalSize() - 1));
|
||||
case EbtSamplerGeneric:
|
||||
return EgstSamplerGeneric;
|
||||
case EbtSampler1D:
|
||||
return EgstSampler1D;
|
||||
case EbtSampler2D:
|
||||
return EgstSampler2D;
|
||||
case EbtSampler3D:
|
||||
return EgstSampler3D;
|
||||
case EbtSamplerCube:
|
||||
return EgstSamplerCube;
|
||||
case EbtStruct:
|
||||
return EgstStruct;
|
||||
}
|
||||
}
|
||||
|
||||
return EgstVoid;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns whether the qualifier is associated with a local or global
|
||||
/// \param qual
|
||||
/// GLSL qualifier type
|
||||
/// \return
|
||||
/// Whether the qualifier is associated with a local or global
|
||||
//=========================================================================================================
|
||||
bool isLocal( EGlslQualifier qual )
|
||||
{
|
||||
switch (qual)
|
||||
{
|
||||
case EqtNone: return true;
|
||||
case EqtUniform: return false;
|
||||
case EqtMutableUniform: return false;
|
||||
case EqtConst: return true;
|
||||
case EqtIn: return true;
|
||||
case EqtOut: return true;
|
||||
case EqtInOut: return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Translates the qualifier to a GLSL qualifier enumerant
|
||||
/// \param qual
|
||||
/// GLSL qualifier type
|
||||
/// \return
|
||||
/// The qualifier translated to a GLSL qualifier.
|
||||
//=========================================================================================================
|
||||
EGlslQualifier translateQualifier( TQualifier qual )
|
||||
{
|
||||
switch (qual)
|
||||
{
|
||||
case EvqTemporary: return EqtNone;
|
||||
case EvqGlobal: return EqtNone;
|
||||
case EvqConst: return EqtConst;
|
||||
case EvqAttribute: return EqtNone;
|
||||
case EvqVaryingIn: return EqtNone;
|
||||
case EvqVaryingOut: return EqtNone;
|
||||
case EvqUniform: return EqtUniform;
|
||||
case EvqMutableUniform: return EqtMutableUniform;
|
||||
|
||||
|
||||
// parameters
|
||||
case EvqIn: return EqtIn;
|
||||
case EvqOut: return EqtOut;
|
||||
case EvqInOut: return EqtInOut;
|
||||
case EvqConstReadOnly: return EqtConst;
|
||||
|
||||
// built-ins written by vertex shader
|
||||
case EvqPosition: return EqtNone;
|
||||
case EvqPointSize: return EqtNone;
|
||||
case EvqClipVertex: return EqtNone;
|
||||
|
||||
// built-ins read by fragment shader
|
||||
case EvqFace: return EqtNone;
|
||||
case EvqFragCoord: return EqtNone;
|
||||
|
||||
// built-ins written by fragment shader
|
||||
case EvqFragColor: return EqtNone;
|
||||
case EvqFragDepth: return EqtNone;
|
||||
|
||||
}
|
||||
|
||||
return EqtNone;
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of GLSL common utility functions
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
#include "glslStruct.h"
|
||||
|
||||
/// Table to convert GLSL variable types to strings
|
||||
const char typeString[EgstTypeCount][32] =
|
||||
{
|
||||
"void",
|
||||
"bool",
|
||||
"bvec2",
|
||||
"bvec3",
|
||||
"bvec4",
|
||||
"int",
|
||||
"ivec2",
|
||||
"ivec3",
|
||||
"ivec4",
|
||||
"float",
|
||||
"vec2",
|
||||
"vec3",
|
||||
"vec4",
|
||||
"mat2",
|
||||
"mat3",
|
||||
"mat4",
|
||||
"sampler",
|
||||
"sampler1D",
|
||||
"sampler2D",
|
||||
"sampler3D",
|
||||
"samplerCube",
|
||||
"struct"
|
||||
};
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public Functions
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Outputs the type of the symbol to the output buffer
|
||||
/// \param out
|
||||
/// The output buffer to write the type to
|
||||
/// \param type
|
||||
/// The type of the GLSL symbol to output
|
||||
/// \param s
|
||||
/// If it is a structure, a pointer to the structure to write out
|
||||
//=========================================================================================================
|
||||
void writeType( std::stringstream &out, EGlslSymbolType type, GlslStruct *s )
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EgstVoid:
|
||||
case EgstBool:
|
||||
case EgstBool2:
|
||||
case EgstBool3:
|
||||
case EgstBool4:
|
||||
case EgstInt:
|
||||
case EgstInt2:
|
||||
case EgstInt3:
|
||||
case EgstInt4:
|
||||
case EgstFloat:
|
||||
case EgstFloat2:
|
||||
case EgstFloat3:
|
||||
case EgstFloat4:
|
||||
case EgstFloat2x2:
|
||||
case EgstFloat3x3:
|
||||
case EgstFloat4x4:
|
||||
case EgstSamplerGeneric:
|
||||
case EgstSampler1D:
|
||||
case EgstSampler2D:
|
||||
case EgstSampler3D:
|
||||
case EgstSamplerCube:
|
||||
out << typeString[type];
|
||||
break;
|
||||
case EgstStruct:
|
||||
if (s)
|
||||
out << s->getName();
|
||||
else
|
||||
out << "struct";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Gets the type as a string
|
||||
/// \param t
|
||||
/// The type to convert to a string
|
||||
/// \return
|
||||
/// The type converted to a string
|
||||
//=========================================================================================================
|
||||
const char* getTypeString( const EGlslSymbolType t )
|
||||
{
|
||||
assert (t >= EgstVoid && t < EgstTypeCount);
|
||||
return typeString[t];
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Translates the type to a GLSL symbol type
|
||||
/// \param type
|
||||
/// Type to convert to a GLSL symbol
|
||||
/// \return
|
||||
/// The GLSL symbol type associated with the TType
|
||||
//=========================================================================================================
|
||||
EGlslSymbolType translateType( const TType *type )
|
||||
{
|
||||
if ( type->isMatrix() )
|
||||
{
|
||||
switch (type->getNominalSize())
|
||||
{
|
||||
case 2: return EgstFloat2x2;
|
||||
case 3: return EgstFloat3x3;
|
||||
case 4: return EgstFloat4x4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (type->getBasicType())
|
||||
{
|
||||
case EbtVoid:
|
||||
return EgstVoid;
|
||||
case EbtBool:
|
||||
return EGlslSymbolType(EgstBool + (type->getNominalSize() - 1));
|
||||
case EbtInt:
|
||||
return EGlslSymbolType(EgstInt + (type->getNominalSize() - 1));
|
||||
case EbtFloat:
|
||||
return EGlslSymbolType(EgstFloat + (type->getNominalSize() - 1));
|
||||
case EbtSamplerGeneric:
|
||||
return EgstSamplerGeneric;
|
||||
case EbtSampler1D:
|
||||
return EgstSampler1D;
|
||||
case EbtSampler2D:
|
||||
return EgstSampler2D;
|
||||
case EbtSampler3D:
|
||||
return EgstSampler3D;
|
||||
case EbtSamplerCube:
|
||||
return EgstSamplerCube;
|
||||
case EbtStruct:
|
||||
return EgstStruct;
|
||||
}
|
||||
}
|
||||
|
||||
return EgstVoid;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns whether the qualifier is associated with a local or global
|
||||
/// \param qual
|
||||
/// GLSL qualifier type
|
||||
/// \return
|
||||
/// Whether the qualifier is associated with a local or global
|
||||
//=========================================================================================================
|
||||
bool isLocal( EGlslQualifier qual )
|
||||
{
|
||||
switch (qual)
|
||||
{
|
||||
case EqtNone: return true;
|
||||
case EqtUniform: return false;
|
||||
case EqtMutableUniform: return false;
|
||||
case EqtConst: return true;
|
||||
case EqtIn: return true;
|
||||
case EqtOut: return true;
|
||||
case EqtInOut: return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Translates the qualifier to a GLSL qualifier enumerant
|
||||
/// \param qual
|
||||
/// GLSL qualifier type
|
||||
/// \return
|
||||
/// The qualifier translated to a GLSL qualifier.
|
||||
//=========================================================================================================
|
||||
EGlslQualifier translateQualifier( TQualifier qual )
|
||||
{
|
||||
switch (qual)
|
||||
{
|
||||
case EvqTemporary: return EqtNone;
|
||||
case EvqGlobal: return EqtNone;
|
||||
case EvqConst: return EqtConst;
|
||||
case EvqAttribute: return EqtNone;
|
||||
case EvqVaryingIn: return EqtNone;
|
||||
case EvqVaryingOut: return EqtNone;
|
||||
case EvqUniform: return EqtUniform;
|
||||
case EvqMutableUniform: return EqtMutableUniform;
|
||||
|
||||
|
||||
// parameters
|
||||
case EvqIn: return EqtIn;
|
||||
case EvqOut: return EqtOut;
|
||||
case EvqInOut: return EqtInOut;
|
||||
case EvqConstReadOnly: return EqtConst;
|
||||
|
||||
// built-ins written by vertex shader
|
||||
case EvqPosition: return EqtNone;
|
||||
case EvqPointSize: return EqtNone;
|
||||
case EvqClipVertex: return EqtNone;
|
||||
|
||||
// built-ins read by fragment shader
|
||||
case EvqFace: return EqtNone;
|
||||
case EvqFragCoord: return EqtNone;
|
||||
|
||||
// built-ins written by fragment shader
|
||||
case EvqFragColor: return EqtNone;
|
||||
case EvqFragDepth: return EqtNone;
|
||||
|
||||
}
|
||||
|
||||
return EqtNone;
|
||||
}
|
|
@ -1,117 +1,117 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of GLSL common utility functions
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef GLSL_COMMON_H
|
||||
#define GLSL_COMMON_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "localintermediate.h"
|
||||
|
||||
// GLSL symbol types
|
||||
enum EGlslSymbolType
|
||||
{
|
||||
EgstVoid,
|
||||
EgstBool,
|
||||
EgstBool2,
|
||||
EgstBool3,
|
||||
EgstBool4,
|
||||
EgstInt,
|
||||
EgstInt2,
|
||||
EgstInt3,
|
||||
EgstInt4,
|
||||
EgstFloat,
|
||||
EgstFloat2,
|
||||
EgstFloat3,
|
||||
EgstFloat4,
|
||||
EgstFloat2x2,
|
||||
EgstFloat3x3,
|
||||
EgstFloat4x4,
|
||||
EgstSamplerGeneric,
|
||||
EgstSampler1D,
|
||||
EgstSampler2D,
|
||||
EgstSampler3D,
|
||||
EgstSamplerCube,
|
||||
EgstStruct,
|
||||
EgstTypeCount
|
||||
};
|
||||
|
||||
// GLSL qualifier enums
|
||||
enum EGlslQualifier
|
||||
{
|
||||
EqtNone,
|
||||
EqtUniform,
|
||||
EqtMutableUniform,
|
||||
EqtConst,
|
||||
EqtIn,
|
||||
EqtOut,
|
||||
EqtInOut
|
||||
};
|
||||
|
||||
|
||||
// Forward Declarations
|
||||
class GlslStruct;
|
||||
|
||||
//=========================================================================================================
|
||||
/// Outputs the type of the symbol to the output buffer
|
||||
//=========================================================================================================
|
||||
void writeType( std::stringstream &out, EGlslSymbolType type, GlslStruct *s );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Gets the type as a string
|
||||
//=========================================================================================================
|
||||
const char *getTypeString( const EGlslSymbolType t );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Translates the type to a GLSL symbol type
|
||||
//=========================================================================================================
|
||||
EGlslSymbolType translateType( const TType *type );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns whether the qualifier is associated with a local or global
|
||||
//=========================================================================================================
|
||||
bool isLocal( EGlslQualifier qual );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Translates the qualifier to a GLSL qualifier enumerant
|
||||
//=========================================================================================================
|
||||
EGlslQualifier translateQualifier( TQualifier qual);
|
||||
|
||||
#endif //GLSL_COMMON_H
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of GLSL common utility functions
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef GLSL_COMMON_H
|
||||
#define GLSL_COMMON_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "localintermediate.h"
|
||||
|
||||
// GLSL symbol types
|
||||
enum EGlslSymbolType
|
||||
{
|
||||
EgstVoid,
|
||||
EgstBool,
|
||||
EgstBool2,
|
||||
EgstBool3,
|
||||
EgstBool4,
|
||||
EgstInt,
|
||||
EgstInt2,
|
||||
EgstInt3,
|
||||
EgstInt4,
|
||||
EgstFloat,
|
||||
EgstFloat2,
|
||||
EgstFloat3,
|
||||
EgstFloat4,
|
||||
EgstFloat2x2,
|
||||
EgstFloat3x3,
|
||||
EgstFloat4x4,
|
||||
EgstSamplerGeneric,
|
||||
EgstSampler1D,
|
||||
EgstSampler2D,
|
||||
EgstSampler3D,
|
||||
EgstSamplerCube,
|
||||
EgstStruct,
|
||||
EgstTypeCount
|
||||
};
|
||||
|
||||
// GLSL qualifier enums
|
||||
enum EGlslQualifier
|
||||
{
|
||||
EqtNone,
|
||||
EqtUniform,
|
||||
EqtMutableUniform,
|
||||
EqtConst,
|
||||
EqtIn,
|
||||
EqtOut,
|
||||
EqtInOut
|
||||
};
|
||||
|
||||
|
||||
// Forward Declarations
|
||||
class GlslStruct;
|
||||
|
||||
//=========================================================================================================
|
||||
/// Outputs the type of the symbol to the output buffer
|
||||
//=========================================================================================================
|
||||
void writeType( std::stringstream &out, EGlslSymbolType type, GlslStruct *s );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Gets the type as a string
|
||||
//=========================================================================================================
|
||||
const char *getTypeString( const EGlslSymbolType t );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Translates the type to a GLSL symbol type
|
||||
//=========================================================================================================
|
||||
EGlslSymbolType translateType( const TType *type );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns whether the qualifier is associated with a local or global
|
||||
//=========================================================================================================
|
||||
bool isLocal( EGlslQualifier qual );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Translates the qualifier to a GLSL qualifier enumerant
|
||||
//=========================================================================================================
|
||||
EGlslQualifier translateQualifier( TQualifier qual);
|
||||
|
||||
#endif //GLSL_COMMON_H
|
||||
|
|
|
@ -1,347 +1,347 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of GlslFunction
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
#include "glslFunction.h"
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Constructor(s) / Destructor(s) Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
GlslFunction::GlslFunction( const std::string &n, const std::string &m, EGlslSymbolType type, const std::string &s ) :
|
||||
name(n),
|
||||
mangledName(m),
|
||||
returnType(type),
|
||||
semantic(s),
|
||||
structPtr(0),
|
||||
depth(0),
|
||||
inStatement(false)
|
||||
{
|
||||
active <<std::showpoint;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
GlslFunction::~GlslFunction()
|
||||
{
|
||||
for (std::vector<GlslSymbol*>::iterator it = symbols.begin(); it < symbols.end(); it++)
|
||||
{
|
||||
(*it)->releaseRef ();
|
||||
if ( (*it)->getRef() == 0 )
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public methods block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns whether the symbol id is found in the function's symbol ID map
|
||||
/// \param id
|
||||
/// Id of symbol to search for in ID map
|
||||
/// \return
|
||||
/// True if symbol is found in the ID map, false otherwise
|
||||
//=========================================================================================================
|
||||
bool GlslFunction::hasSymbol( int id )
|
||||
{
|
||||
|
||||
if (symbolIdMap.find(id) != symbolIdMap.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns a reference to the symbol referred to by id
|
||||
/// \param id
|
||||
/// Id of symbol to search for in ID map
|
||||
/// \return
|
||||
/// Reference to the symbol in the ID map
|
||||
//=========================================================================================================
|
||||
GlslSymbol& GlslFunction::getSymbol( int id )
|
||||
{
|
||||
return *symbolIdMap[id];
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a symbol to the function
|
||||
/// \param sym
|
||||
/// Symbol to add to the function
|
||||
//=========================================================================================================
|
||||
void GlslFunction::addSymbol( GlslSymbol *sym )
|
||||
{
|
||||
// Add a reference count to the symbol
|
||||
sym->addRef();
|
||||
|
||||
// mangle the name to avoid conflicts
|
||||
while ( symbolNameMap.find(sym->getName()) != symbolNameMap.end())
|
||||
{
|
||||
sym->mangleName();
|
||||
}
|
||||
|
||||
symbols.push_back( sym);
|
||||
symbolNameMap[sym->getName()] = sym;
|
||||
symbolIdMap[sym->getId()] = sym;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a symbol to the function, mark it as a parameter
|
||||
/// \param sym
|
||||
/// Symbol to add to the function, to be marked as a function parameter
|
||||
//=========================================================================================================
|
||||
void GlslFunction::addParameter( GlslSymbol *sym )
|
||||
{
|
||||
// Add a reference count to the symbol
|
||||
sym->addRef();
|
||||
|
||||
sym->setIsParameter(true);
|
||||
|
||||
//mangle the name to avoid conflicts
|
||||
while ( symbolNameMap.find(sym->getName()) != symbolNameMap.end())
|
||||
{
|
||||
sym->mangleName();
|
||||
}
|
||||
|
||||
symbols.push_back( sym);
|
||||
symbolNameMap[sym->getName()] = sym;
|
||||
symbolIdMap[sym->getId()] = sym;
|
||||
parameters.push_back( sym);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the prototype for the function
|
||||
/// \return
|
||||
/// As a string, the prototype of the function
|
||||
//=========================================================================================================
|
||||
std::string GlslFunction::getPrototype()
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
writeType( out, returnType, structPtr);
|
||||
out << " " << name << "( ";
|
||||
|
||||
std::vector<GlslSymbol*>::iterator it = parameters.begin();
|
||||
|
||||
if (it != parameters.end())
|
||||
{
|
||||
(*it)->writeDecl(out);
|
||||
it++;
|
||||
}
|
||||
|
||||
while ( it != parameters.end())
|
||||
{
|
||||
out << ", ";
|
||||
(*it)->writeDecl(out);
|
||||
it++;
|
||||
}
|
||||
|
||||
out << " )";
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the local declarations in the function
|
||||
/// \param indentLevel
|
||||
/// How many levels to indent the output
|
||||
/// \return
|
||||
/// As a string, local declarations of the function
|
||||
//=========================================================================================================
|
||||
std::string GlslFunction::getLocalDecls( int indentLevel )
|
||||
{
|
||||
std::stringstream out;
|
||||
int oldDepth;
|
||||
|
||||
// Make sure that decimal points are printed to the output string. Otherwise, the following:
|
||||
// float fTemp = 1.0;
|
||||
// will come out:
|
||||
// float fTemp = 1;
|
||||
// causing a GLSL parse error
|
||||
out.setf ( std::stringstream::showpoint );
|
||||
|
||||
//save off the old depth, to restore later, this is probably unnecessary
|
||||
oldDepth = depth;
|
||||
depth = indentLevel;
|
||||
|
||||
for (std::vector<GlslSymbol*>::iterator it = symbols.begin(); it < symbols.end(); it++)
|
||||
{
|
||||
if ( (!(*it)->getIsParameter() && !(*it)->getIsGlobal() && !(*it)->getIsMutable()) )
|
||||
{
|
||||
indent(out);
|
||||
if ((*it)->hasInitializer())
|
||||
{
|
||||
(*it)->writeDecl(out, true);
|
||||
if ((*it)->isArray())
|
||||
{
|
||||
out <<";\n";
|
||||
for (int ii = 0; ii < (*it)->getArraySize(); ii++)
|
||||
{
|
||||
indent(out);
|
||||
out << (*it)->getName() << "[" << ii << "] = ";
|
||||
(*it)->writeInitializer(out,ii);
|
||||
if ( (ii+1) != (*it)->getArraySize())
|
||||
out << ";\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out << " = ";
|
||||
(*it)->writeInitializer(out);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(*it)->writeDecl(out, true);
|
||||
}
|
||||
out << ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
depth = oldDepth;
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the mutable declarations in the function. Takes a set of other functions to
|
||||
/// check whether the mutable has already been declared.
|
||||
/// \param indentLevel
|
||||
/// How many levels to indent the output
|
||||
/// \param funcBegin
|
||||
/// First function which for which mutables have already been processed
|
||||
/// \param funcEnd
|
||||
/// Current function being processed for mutables
|
||||
/// \return
|
||||
/// As a string, local declarations of the function
|
||||
//=========================================================================================================
|
||||
std::string GlslFunction::getMutableDecls( int indentLevel, std::set<GlslFunction*>::iterator funcBegin,
|
||||
std::set<GlslFunction*>::iterator funcEnd )
|
||||
{
|
||||
std::stringstream out;
|
||||
int oldDepth;
|
||||
|
||||
// Make sure that decimal points are printed to the output string. Otherwise, the following:
|
||||
// float fTemp = 1.0;
|
||||
// will come out:
|
||||
// float fTemp = 1;
|
||||
// causing a GLSL parse error
|
||||
out.setf ( std::stringstream::showpoint );
|
||||
|
||||
//save off the old depth, to restore later, this is probably unnecessary
|
||||
oldDepth = depth;
|
||||
depth = indentLevel;
|
||||
|
||||
for (std::vector<GlslSymbol*>::iterator it = symbols.begin(); it < symbols.end(); it++)
|
||||
{
|
||||
if ( (*it)->getIsMutable() )
|
||||
{
|
||||
bool bMutableAlreadyProcessed = false;
|
||||
|
||||
// Check the set of already processed functions to see if the mutable was already
|
||||
// written out
|
||||
std::set<GlslFunction*>::iterator fit = funcBegin;
|
||||
while ( fit != funcEnd && bMutableAlreadyProcessed == false)
|
||||
{
|
||||
std::vector<GlslSymbol*> funcSymbols = (*fit)->getSymbols();
|
||||
|
||||
for (size_t i = 0; i < funcSymbols.size(); i++ )
|
||||
{
|
||||
if ( (*it)->getName() == funcSymbols[i]->getName() )
|
||||
{
|
||||
// Symbol found, this mutable has already been processed. Don't do it again.
|
||||
bMutableAlreadyProcessed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fit++;
|
||||
}
|
||||
|
||||
if ( bMutableAlreadyProcessed == false )
|
||||
{
|
||||
indent(out);
|
||||
if ((*it)->isArray())
|
||||
{
|
||||
for (int ii = 0; ii < (*it)->getArraySize(); ii++)
|
||||
{
|
||||
out << (*it)->getName() << "[" << ii << "] = ";
|
||||
out << (*it)->getName(false) << "[" << ii << "]";
|
||||
if ( (ii+1) != (*it)->getArraySize())
|
||||
{
|
||||
out << ";\n";
|
||||
indent(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out << (*it)->getName() << " = " << (*it)->getName(false);
|
||||
}
|
||||
|
||||
out << ";\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
depth = oldDepth;
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of GlslFunction
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
#include "glslFunction.h"
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Constructor(s) / Destructor(s) Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
GlslFunction::GlslFunction( const std::string &n, const std::string &m, EGlslSymbolType type, const std::string &s ) :
|
||||
name(n),
|
||||
mangledName(m),
|
||||
returnType(type),
|
||||
semantic(s),
|
||||
structPtr(0),
|
||||
depth(0),
|
||||
inStatement(false)
|
||||
{
|
||||
active <<std::showpoint;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
GlslFunction::~GlslFunction()
|
||||
{
|
||||
for (std::vector<GlslSymbol*>::iterator it = symbols.begin(); it < symbols.end(); it++)
|
||||
{
|
||||
(*it)->releaseRef ();
|
||||
if ( (*it)->getRef() == 0 )
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public methods block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns whether the symbol id is found in the function's symbol ID map
|
||||
/// \param id
|
||||
/// Id of symbol to search for in ID map
|
||||
/// \return
|
||||
/// True if symbol is found in the ID map, false otherwise
|
||||
//=========================================================================================================
|
||||
bool GlslFunction::hasSymbol( int id )
|
||||
{
|
||||
|
||||
if (symbolIdMap.find(id) != symbolIdMap.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns a reference to the symbol referred to by id
|
||||
/// \param id
|
||||
/// Id of symbol to search for in ID map
|
||||
/// \return
|
||||
/// Reference to the symbol in the ID map
|
||||
//=========================================================================================================
|
||||
GlslSymbol& GlslFunction::getSymbol( int id )
|
||||
{
|
||||
return *symbolIdMap[id];
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a symbol to the function
|
||||
/// \param sym
|
||||
/// Symbol to add to the function
|
||||
//=========================================================================================================
|
||||
void GlslFunction::addSymbol( GlslSymbol *sym )
|
||||
{
|
||||
// Add a reference count to the symbol
|
||||
sym->addRef();
|
||||
|
||||
// mangle the name to avoid conflicts
|
||||
while ( symbolNameMap.find(sym->getName()) != symbolNameMap.end())
|
||||
{
|
||||
sym->mangleName();
|
||||
}
|
||||
|
||||
symbols.push_back( sym);
|
||||
symbolNameMap[sym->getName()] = sym;
|
||||
symbolIdMap[sym->getId()] = sym;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a symbol to the function, mark it as a parameter
|
||||
/// \param sym
|
||||
/// Symbol to add to the function, to be marked as a function parameter
|
||||
//=========================================================================================================
|
||||
void GlslFunction::addParameter( GlslSymbol *sym )
|
||||
{
|
||||
// Add a reference count to the symbol
|
||||
sym->addRef();
|
||||
|
||||
sym->setIsParameter(true);
|
||||
|
||||
//mangle the name to avoid conflicts
|
||||
while ( symbolNameMap.find(sym->getName()) != symbolNameMap.end())
|
||||
{
|
||||
sym->mangleName();
|
||||
}
|
||||
|
||||
symbols.push_back( sym);
|
||||
symbolNameMap[sym->getName()] = sym;
|
||||
symbolIdMap[sym->getId()] = sym;
|
||||
parameters.push_back( sym);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the prototype for the function
|
||||
/// \return
|
||||
/// As a string, the prototype of the function
|
||||
//=========================================================================================================
|
||||
std::string GlslFunction::getPrototype()
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
writeType( out, returnType, structPtr);
|
||||
out << " " << name << "( ";
|
||||
|
||||
std::vector<GlslSymbol*>::iterator it = parameters.begin();
|
||||
|
||||
if (it != parameters.end())
|
||||
{
|
||||
(*it)->writeDecl(out);
|
||||
it++;
|
||||
}
|
||||
|
||||
while ( it != parameters.end())
|
||||
{
|
||||
out << ", ";
|
||||
(*it)->writeDecl(out);
|
||||
it++;
|
||||
}
|
||||
|
||||
out << " )";
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the local declarations in the function
|
||||
/// \param indentLevel
|
||||
/// How many levels to indent the output
|
||||
/// \return
|
||||
/// As a string, local declarations of the function
|
||||
//=========================================================================================================
|
||||
std::string GlslFunction::getLocalDecls( int indentLevel )
|
||||
{
|
||||
std::stringstream out;
|
||||
int oldDepth;
|
||||
|
||||
// Make sure that decimal points are printed to the output string. Otherwise, the following:
|
||||
// float fTemp = 1.0;
|
||||
// will come out:
|
||||
// float fTemp = 1;
|
||||
// causing a GLSL parse error
|
||||
out.setf ( std::stringstream::showpoint );
|
||||
|
||||
//save off the old depth, to restore later, this is probably unnecessary
|
||||
oldDepth = depth;
|
||||
depth = indentLevel;
|
||||
|
||||
for (std::vector<GlslSymbol*>::iterator it = symbols.begin(); it < symbols.end(); it++)
|
||||
{
|
||||
if ( (!(*it)->getIsParameter() && !(*it)->getIsGlobal() && !(*it)->getIsMutable()) )
|
||||
{
|
||||
indent(out);
|
||||
if ((*it)->hasInitializer())
|
||||
{
|
||||
(*it)->writeDecl(out, true);
|
||||
if ((*it)->isArray())
|
||||
{
|
||||
out <<";\n";
|
||||
for (int ii = 0; ii < (*it)->getArraySize(); ii++)
|
||||
{
|
||||
indent(out);
|
||||
out << (*it)->getName() << "[" << ii << "] = ";
|
||||
(*it)->writeInitializer(out,ii);
|
||||
if ( (ii+1) != (*it)->getArraySize())
|
||||
out << ";\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out << " = ";
|
||||
(*it)->writeInitializer(out);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(*it)->writeDecl(out, true);
|
||||
}
|
||||
out << ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
depth = oldDepth;
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the mutable declarations in the function. Takes a set of other functions to
|
||||
/// check whether the mutable has already been declared.
|
||||
/// \param indentLevel
|
||||
/// How many levels to indent the output
|
||||
/// \param funcBegin
|
||||
/// First function which for which mutables have already been processed
|
||||
/// \param funcEnd
|
||||
/// Current function being processed for mutables
|
||||
/// \return
|
||||
/// As a string, local declarations of the function
|
||||
//=========================================================================================================
|
||||
std::string GlslFunction::getMutableDecls( int indentLevel, std::set<GlslFunction*>::iterator funcBegin,
|
||||
std::set<GlslFunction*>::iterator funcEnd )
|
||||
{
|
||||
std::stringstream out;
|
||||
int oldDepth;
|
||||
|
||||
// Make sure that decimal points are printed to the output string. Otherwise, the following:
|
||||
// float fTemp = 1.0;
|
||||
// will come out:
|
||||
// float fTemp = 1;
|
||||
// causing a GLSL parse error
|
||||
out.setf ( std::stringstream::showpoint );
|
||||
|
||||
//save off the old depth, to restore later, this is probably unnecessary
|
||||
oldDepth = depth;
|
||||
depth = indentLevel;
|
||||
|
||||
for (std::vector<GlslSymbol*>::iterator it = symbols.begin(); it < symbols.end(); it++)
|
||||
{
|
||||
if ( (*it)->getIsMutable() )
|
||||
{
|
||||
bool bMutableAlreadyProcessed = false;
|
||||
|
||||
// Check the set of already processed functions to see if the mutable was already
|
||||
// written out
|
||||
std::set<GlslFunction*>::iterator fit = funcBegin;
|
||||
while ( fit != funcEnd && bMutableAlreadyProcessed == false)
|
||||
{
|
||||
std::vector<GlslSymbol*> funcSymbols = (*fit)->getSymbols();
|
||||
|
||||
for (size_t i = 0; i < funcSymbols.size(); i++ )
|
||||
{
|
||||
if ( (*it)->getName() == funcSymbols[i]->getName() )
|
||||
{
|
||||
// Symbol found, this mutable has already been processed. Don't do it again.
|
||||
bMutableAlreadyProcessed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fit++;
|
||||
}
|
||||
|
||||
if ( bMutableAlreadyProcessed == false )
|
||||
{
|
||||
indent(out);
|
||||
if ((*it)->isArray())
|
||||
{
|
||||
for (int ii = 0; ii < (*it)->getArraySize(); ii++)
|
||||
{
|
||||
out << (*it)->getName() << "[" << ii << "] = ";
|
||||
out << (*it)->getName(false) << "[" << ii << "]";
|
||||
if ( (ii+1) != (*it)->getArraySize())
|
||||
{
|
||||
out << ";\n";
|
||||
indent(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out << (*it)->getName() << " = " << (*it)->getName(false);
|
||||
}
|
||||
|
||||
out << ";\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
depth = oldDepth;
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,258 +1,258 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of glslFunction
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef GLSL_FUNCTION_H
|
||||
#define GLSL_FUNCTION_H
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "glslCommon.h"
|
||||
#include "glslStruct.h"
|
||||
#include "glslSymbol.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// GlslFunction
|
||||
///
|
||||
/// \brief This class represents all the data necessary to represent a
|
||||
/// function for the linker to create a complete output program.
|
||||
//=================================================================================================================================
|
||||
class GlslFunction
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
GlslFunction( const std::string &n, const std::string &m, EGlslSymbolType type, const std::string &s );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
virtual ~GlslFunction();
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a symbol to the function
|
||||
//=========================================================================================================
|
||||
void addSymbol( GlslSymbol *sym );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a symbol to the function, mark it as a parameter
|
||||
//=========================================================================================================
|
||||
void addParameter( GlslSymbol *sym );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns whether the symbol id is found in the function's symbol ID map
|
||||
//=========================================================================================================
|
||||
bool hasSymbol( int id );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns a reference to the symbol referred to by id
|
||||
//=========================================================================================================
|
||||
GlslSymbol& getSymbol( int id );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the prototype for the function
|
||||
//=========================================================================================================
|
||||
std::string getPrototype();
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the local declarations in the function
|
||||
//=========================================================================================================
|
||||
std::string getLocalDecls( int indentLevel );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the mutable declarations in the function. Takes a set of other functions to
|
||||
/// check whether the mutable has already been declared.
|
||||
//=========================================================================================================
|
||||
std::string getMutableDecls( int indentLevel, std::set<GlslFunction*>::iterator funcBegin,
|
||||
std::set<GlslFunction*>::iterator funcEnd );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns the active scope
|
||||
//=========================================================================================================
|
||||
std::string getCode() { return active.str(); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns the number of parameters to the function
|
||||
//=========================================================================================================
|
||||
int getParameterCount() { return (int)parameters.size();}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns the parameter i as a GLSL symbol
|
||||
//=========================================================================================================
|
||||
GlslSymbol* getParameter( int i ) { return parameters[i];}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a function called by this function
|
||||
//=========================================================================================================
|
||||
void addCalledFunction( const std::string& func ) { calledFunctions.insert(func); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the set of functions called by this function
|
||||
//=========================================================================================================
|
||||
const std::set<std::string>& getCalledFunctions() const { return calledFunctions; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add an HLSL support library function by opcode
|
||||
//=========================================================================================================
|
||||
void addLibFunction( TOperator op ) { libFunctions.insert( op); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the HLSL support library functions used by this function
|
||||
//=========================================================================================================
|
||||
const std::set<TOperator>& getLibFunctions() const { return libFunctions; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get a vector of symbols used in this function
|
||||
//=========================================================================================================
|
||||
const std::vector<GlslSymbol*>& getSymbols() { return symbols; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Increase function depth
|
||||
//=========================================================================================================
|
||||
void increaseDepth() { depth++; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Decrease function depth
|
||||
//=========================================================================================================
|
||||
void decreaseDepth() { depth = depth ? depth-1 : depth; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Indent the function based on the current depth
|
||||
//=========================================================================================================
|
||||
void indent( std::stringstream &s ) { for (int ii = 0; ii < depth; ii++) s << " "; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Indent the active function stream
|
||||
//=========================================================================================================
|
||||
void indent() { indent(active); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Begin a new block on the active function stream
|
||||
//=========================================================================================================
|
||||
void beginBlock( bool brace = true) { if (brace) active << "{\n"; increaseDepth(); inStatement = false; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// End the current block in the active function stream
|
||||
//=========================================================================================================
|
||||
void endBlock() { endStatement(); decreaseDepth(); indent(); active << "}\n"; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Begin a new statement in the active function stream
|
||||
//=========================================================================================================
|
||||
void beginStatement() { if (!inStatement) { indent(); inStatement = true;}}
|
||||
|
||||
//=========================================================================================================
|
||||
/// End the current statement in the active function stream
|
||||
//=========================================================================================================
|
||||
void endStatement() { if (inStatement) { active << ";\n"; inStatement = false;}}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the name of the function
|
||||
//=========================================================================================================
|
||||
const std::string &getName() { return name; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the mangled name of the function
|
||||
//=========================================================================================================
|
||||
const std::string &getMangledName() { return mangledName; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the return type of the function
|
||||
//=========================================================================================================
|
||||
EGlslSymbolType getReturnType() { return returnType; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the semantic of the function return
|
||||
//=========================================================================================================
|
||||
const std::string& getSemantic() const { return semantic; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the struct of the function return
|
||||
//=========================================================================================================
|
||||
GlslStruct* getStruct() { return structPtr; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the the struct of the function return
|
||||
//=========================================================================================================
|
||||
void setStruct( GlslStruct *s ) { structPtr = s;}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the active output stream for the function
|
||||
//=========================================================================================================
|
||||
std::stringstream& getActiveOutput () { return active; }
|
||||
|
||||
protected:
|
||||
|
||||
// Function info
|
||||
std::string name;
|
||||
std::string mangledName;
|
||||
EGlslSymbolType returnType;
|
||||
std::string semantic;
|
||||
|
||||
// Structure return value
|
||||
GlslStruct *structPtr;
|
||||
|
||||
// Present indent depth
|
||||
int depth;
|
||||
|
||||
// These are the symbols referenced
|
||||
std::vector<GlslSymbol*> symbols;
|
||||
std::map<std::string,GlslSymbol*> symbolNameMap;
|
||||
std::map<int,GlslSymbol*> symbolIdMap;
|
||||
std::vector<GlslSymbol*> parameters;
|
||||
|
||||
// Functions called by this function
|
||||
std::set<std::string> calledFunctions;
|
||||
|
||||
// Built-in functions needing the support lib that were called
|
||||
std::set<TOperator> libFunctions;
|
||||
|
||||
// Stores the active output of the function
|
||||
std::stringstream active;
|
||||
|
||||
bool inStatement;
|
||||
|
||||
};
|
||||
|
||||
#endif //GLSL_FUNCTION_H
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of glslFunction
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef GLSL_FUNCTION_H
|
||||
#define GLSL_FUNCTION_H
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "glslCommon.h"
|
||||
#include "glslStruct.h"
|
||||
#include "glslSymbol.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// GlslFunction
|
||||
///
|
||||
/// \brief This class represents all the data necessary to represent a
|
||||
/// function for the linker to create a complete output program.
|
||||
//=================================================================================================================================
|
||||
class GlslFunction
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
GlslFunction( const std::string &n, const std::string &m, EGlslSymbolType type, const std::string &s );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
virtual ~GlslFunction();
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a symbol to the function
|
||||
//=========================================================================================================
|
||||
void addSymbol( GlslSymbol *sym );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a symbol to the function, mark it as a parameter
|
||||
//=========================================================================================================
|
||||
void addParameter( GlslSymbol *sym );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns whether the symbol id is found in the function's symbol ID map
|
||||
//=========================================================================================================
|
||||
bool hasSymbol( int id );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns a reference to the symbol referred to by id
|
||||
//=========================================================================================================
|
||||
GlslSymbol& getSymbol( int id );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the prototype for the function
|
||||
//=========================================================================================================
|
||||
std::string getPrototype();
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the local declarations in the function
|
||||
//=========================================================================================================
|
||||
std::string getLocalDecls( int indentLevel );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns, as a string, the mutable declarations in the function. Takes a set of other functions to
|
||||
/// check whether the mutable has already been declared.
|
||||
//=========================================================================================================
|
||||
std::string getMutableDecls( int indentLevel, std::set<GlslFunction*>::iterator funcBegin,
|
||||
std::set<GlslFunction*>::iterator funcEnd );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns the active scope
|
||||
//=========================================================================================================
|
||||
std::string getCode() { return active.str(); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns the number of parameters to the function
|
||||
//=========================================================================================================
|
||||
int getParameterCount() { return (int)parameters.size();}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Returns the parameter i as a GLSL symbol
|
||||
//=========================================================================================================
|
||||
GlslSymbol* getParameter( int i ) { return parameters[i];}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a function called by this function
|
||||
//=========================================================================================================
|
||||
void addCalledFunction( const std::string& func ) { calledFunctions.insert(func); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the set of functions called by this function
|
||||
//=========================================================================================================
|
||||
const std::set<std::string>& getCalledFunctions() const { return calledFunctions; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add an HLSL support library function by opcode
|
||||
//=========================================================================================================
|
||||
void addLibFunction( TOperator op ) { libFunctions.insert( op); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the HLSL support library functions used by this function
|
||||
//=========================================================================================================
|
||||
const std::set<TOperator>& getLibFunctions() const { return libFunctions; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get a vector of symbols used in this function
|
||||
//=========================================================================================================
|
||||
const std::vector<GlslSymbol*>& getSymbols() { return symbols; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Increase function depth
|
||||
//=========================================================================================================
|
||||
void increaseDepth() { depth++; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Decrease function depth
|
||||
//=========================================================================================================
|
||||
void decreaseDepth() { depth = depth ? depth-1 : depth; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Indent the function based on the current depth
|
||||
//=========================================================================================================
|
||||
void indent( std::stringstream &s ) { for (int ii = 0; ii < depth; ii++) s << " "; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Indent the active function stream
|
||||
//=========================================================================================================
|
||||
void indent() { indent(active); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Begin a new block on the active function stream
|
||||
//=========================================================================================================
|
||||
void beginBlock( bool brace = true) { if (brace) active << "{\n"; increaseDepth(); inStatement = false; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// End the current block in the active function stream
|
||||
//=========================================================================================================
|
||||
void endBlock() { endStatement(); decreaseDepth(); indent(); active << "}\n"; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Begin a new statement in the active function stream
|
||||
//=========================================================================================================
|
||||
void beginStatement() { if (!inStatement) { indent(); inStatement = true;}}
|
||||
|
||||
//=========================================================================================================
|
||||
/// End the current statement in the active function stream
|
||||
//=========================================================================================================
|
||||
void endStatement() { if (inStatement) { active << ";\n"; inStatement = false;}}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the name of the function
|
||||
//=========================================================================================================
|
||||
const std::string &getName() { return name; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the mangled name of the function
|
||||
//=========================================================================================================
|
||||
const std::string &getMangledName() { return mangledName; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the return type of the function
|
||||
//=========================================================================================================
|
||||
EGlslSymbolType getReturnType() { return returnType; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the semantic of the function return
|
||||
//=========================================================================================================
|
||||
const std::string& getSemantic() const { return semantic; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the struct of the function return
|
||||
//=========================================================================================================
|
||||
GlslStruct* getStruct() { return structPtr; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the the struct of the function return
|
||||
//=========================================================================================================
|
||||
void setStruct( GlslStruct *s ) { structPtr = s;}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the active output stream for the function
|
||||
//=========================================================================================================
|
||||
std::stringstream& getActiveOutput () { return active; }
|
||||
|
||||
protected:
|
||||
|
||||
// Function info
|
||||
std::string name;
|
||||
std::string mangledName;
|
||||
EGlslSymbolType returnType;
|
||||
std::string semantic;
|
||||
|
||||
// Structure return value
|
||||
GlslStruct *structPtr;
|
||||
|
||||
// Present indent depth
|
||||
int depth;
|
||||
|
||||
// These are the symbols referenced
|
||||
std::vector<GlslSymbol*> symbols;
|
||||
std::map<std::string,GlslSymbol*> symbolNameMap;
|
||||
std::map<int,GlslSymbol*> symbolIdMap;
|
||||
std::vector<GlslSymbol*> parameters;
|
||||
|
||||
// Functions called by this function
|
||||
std::set<std::string> calledFunctions;
|
||||
|
||||
// Built-in functions needing the support lib that were called
|
||||
std::set<TOperator> libFunctions;
|
||||
|
||||
// Stores the active output of the function
|
||||
std::stringstream active;
|
||||
|
||||
bool inStatement;
|
||||
|
||||
};
|
||||
|
||||
#endif //GLSL_FUNCTION_H
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,156 +1,156 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of TGlslOutputTraverser. Interface for a traverser designed to iterate the tree and generate valid
|
||||
// GLSL code.
|
||||
//=================================================================================================================================
|
||||
#ifndef GLSL_OUTPUT_H
|
||||
#define GLSL_OUTPUT_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "localintermediate.h"
|
||||
#include "glslCommon.h"
|
||||
#include "glslStruct.h"
|
||||
#include "glslSymbol.h"
|
||||
#include "glslFunction.h"
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
/// TGlslOutputTraverser
|
||||
///
|
||||
/// \brief This class implements the tree traverser that outputs GLSL code for the tree
|
||||
//=================================================================================================================================
|
||||
class TGlslOutputTraverser : public TIntermTraverser
|
||||
{
|
||||
private:
|
||||
//=========================================================================================================
|
||||
/// Traverse a symbol node, add the name to the output buffer
|
||||
//=========================================================================================================
|
||||
static void traverseSymbol(TIntermSymbol*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a symbol node which is a function parameter, add the name to the output buffer
|
||||
//=========================================================================================================
|
||||
static void traverseParameterSymbol(TIntermSymbol *node, TIntermTraverser *it);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a node in the tree representing a constant
|
||||
//=========================================================================================================
|
||||
static void traverseConstantUnion(TIntermConstantUnion*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a node in the tree representing a constant intended for immediate use, such as a direct reference
|
||||
//=========================================================================================================
|
||||
static void traverseImmediateConstant( TIntermConstantUnion *node, TIntermTraverser *it);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a binary node generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseBinary(bool preVisit, TIntermBinary*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a unary node generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseUnary(bool preVisit, TIntermUnary*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a selection generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseSelection(bool preVisit, TIntermSelection*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse an aggregate node generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseAggregate(bool preVisit, TIntermAggregate*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a loop node generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseLoop(bool preVisit, TIntermLoop*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a branch node generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseBranch(bool preVisit, TIntermBranch*, TIntermTraverser*);
|
||||
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
TGlslOutputTraverser(TInfoSink& i, std::vector<GlslFunction*> &funcList, std::vector<GlslStruct*> &sList);
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Create a GLSL structure from a structure TType
|
||||
//=========================================================================================================
|
||||
GlslStruct *createStructFromType( TType *type );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Parse a binary node that represents an variable initalizer
|
||||
//=========================================================================================================
|
||||
bool parseInitializer( TIntermBinary *node );
|
||||
|
||||
// Info Sink
|
||||
TInfoSink& infoSink;
|
||||
|
||||
// Global function
|
||||
GlslFunction *global;
|
||||
|
||||
// Current function
|
||||
GlslFunction *current;
|
||||
|
||||
// Are we currently generating code?
|
||||
bool generatingCode;
|
||||
|
||||
// List of functions
|
||||
std::vector<GlslFunction*> &functionList;
|
||||
|
||||
// List of structures
|
||||
std::vector<GlslStruct*> &structList;
|
||||
|
||||
// Map of structure names to GLSL structures
|
||||
std::map<std::string,GlslStruct*> structMap;
|
||||
|
||||
// Persistent data for collecting indices
|
||||
std::vector<int> indexList;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of TGlslOutputTraverser. Interface for a traverser designed to iterate the tree and generate valid
|
||||
// GLSL code.
|
||||
//=================================================================================================================================
|
||||
#ifndef GLSL_OUTPUT_H
|
||||
#define GLSL_OUTPUT_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "localintermediate.h"
|
||||
#include "glslCommon.h"
|
||||
#include "glslStruct.h"
|
||||
#include "glslSymbol.h"
|
||||
#include "glslFunction.h"
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
/// TGlslOutputTraverser
|
||||
///
|
||||
/// \brief This class implements the tree traverser that outputs GLSL code for the tree
|
||||
//=================================================================================================================================
|
||||
class TGlslOutputTraverser : public TIntermTraverser
|
||||
{
|
||||
private:
|
||||
//=========================================================================================================
|
||||
/// Traverse a symbol node, add the name to the output buffer
|
||||
//=========================================================================================================
|
||||
static void traverseSymbol(TIntermSymbol*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a symbol node which is a function parameter, add the name to the output buffer
|
||||
//=========================================================================================================
|
||||
static void traverseParameterSymbol(TIntermSymbol *node, TIntermTraverser *it);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a node in the tree representing a constant
|
||||
//=========================================================================================================
|
||||
static void traverseConstantUnion(TIntermConstantUnion*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a node in the tree representing a constant intended for immediate use, such as a direct reference
|
||||
//=========================================================================================================
|
||||
static void traverseImmediateConstant( TIntermConstantUnion *node, TIntermTraverser *it);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a binary node generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseBinary(bool preVisit, TIntermBinary*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a unary node generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseUnary(bool preVisit, TIntermUnary*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a selection generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseSelection(bool preVisit, TIntermSelection*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse an aggregate node generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseAggregate(bool preVisit, TIntermAggregate*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a loop node generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseLoop(bool preVisit, TIntermLoop*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a branch node generating the output GLSL code
|
||||
//=========================================================================================================
|
||||
static bool traverseBranch(bool preVisit, TIntermBranch*, TIntermTraverser*);
|
||||
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
TGlslOutputTraverser(TInfoSink& i, std::vector<GlslFunction*> &funcList, std::vector<GlslStruct*> &sList);
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Create a GLSL structure from a structure TType
|
||||
//=========================================================================================================
|
||||
GlslStruct *createStructFromType( TType *type );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Parse a binary node that represents an variable initalizer
|
||||
//=========================================================================================================
|
||||
bool parseInitializer( TIntermBinary *node );
|
||||
|
||||
// Info Sink
|
||||
TInfoSink& infoSink;
|
||||
|
||||
// Global function
|
||||
GlslFunction *global;
|
||||
|
||||
// Current function
|
||||
GlslFunction *current;
|
||||
|
||||
// Are we currently generating code?
|
||||
bool generatingCode;
|
||||
|
||||
// List of functions
|
||||
std::vector<GlslFunction*> &functionList;
|
||||
|
||||
// List of structures
|
||||
std::vector<GlslStruct*> &structList;
|
||||
|
||||
// Map of structure names to GLSL structures
|
||||
std::map<std::string,GlslStruct*> structMap;
|
||||
|
||||
// Persistent data for collecting indices
|
||||
std::vector<int> indexList;
|
||||
|
||||
};
|
||||
|
||||
#endif //GLSL_OUTPUT_H
|
|
@ -1,82 +1,82 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of GlslStruct
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
#include "glslStruct.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public methods block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the declaration for the structure in GLSL as a string
|
||||
/// \return
|
||||
/// The declaration for the structure in GLSL as a string
|
||||
//=========================================================================================================
|
||||
std::string GlslStruct::getDecl()
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
out << "struct " << name << " {\n";
|
||||
|
||||
for (std::vector<member>::iterator it = memberList.begin(); it != memberList.end(); it++)
|
||||
{
|
||||
out << " ";
|
||||
writeType( out, it->type, 0);
|
||||
out << " " << it->name;
|
||||
|
||||
if (it->arraySize > 0)
|
||||
out << "[" << it->arraySize << "]";
|
||||
|
||||
out << ";\n";
|
||||
}
|
||||
|
||||
out << "};\n";
|
||||
|
||||
return out.str();
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of GlslStruct
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
#include "glslStruct.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public methods block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the declaration for the structure in GLSL as a string
|
||||
/// \return
|
||||
/// The declaration for the structure in GLSL as a string
|
||||
//=========================================================================================================
|
||||
std::string GlslStruct::getDecl()
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
out << "struct " << name << " {\n";
|
||||
|
||||
for (std::vector<member>::iterator it = memberList.begin(); it != memberList.end(); it++)
|
||||
{
|
||||
out << " ";
|
||||
writeType( out, it->type, 0);
|
||||
out << " " << it->name;
|
||||
|
||||
if (it->arraySize > 0)
|
||||
out << "[" << it->arraySize << "]";
|
||||
|
||||
out << ";\n";
|
||||
}
|
||||
|
||||
out << "};\n";
|
||||
|
||||
return out.str();
|
||||
}
|
|
@ -1,107 +1,107 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of GlslStruct
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef GLSL_STRUCT_H
|
||||
#define GLSL_STRUCT_H
|
||||
|
||||
#include "glslCommon.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// GlslStruct
|
||||
///
|
||||
/// \brief This class provides the support for struct types.
|
||||
//=================================================================================================================================
|
||||
class GlslStruct
|
||||
{
|
||||
public:
|
||||
// Struct member description, presently does not handle structs of structs
|
||||
struct member
|
||||
{
|
||||
std::string name;
|
||||
std::string semantic;
|
||||
EGlslSymbolType type;
|
||||
int arraySize;
|
||||
};
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
GlslStruct( const std::string &n) : name(n) {}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
virtual ~GlslStruct() {}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the structure name
|
||||
//=========================================================================================================
|
||||
const std::string& getName() { return name; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a new member to the structure
|
||||
//=========================================================================================================
|
||||
void addMember( const member& m ) { memberList.push_back(m); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the structure member specified by which
|
||||
//=========================================================================================================
|
||||
const member& getMember( int which ) { return memberList[which]; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the number of structure members
|
||||
//=========================================================================================================
|
||||
int memberCount() { return int(memberList.size()); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the declaration for the structure in GLSL as a string
|
||||
//=========================================================================================================
|
||||
std::string getDecl();
|
||||
private:
|
||||
|
||||
// Members in structure
|
||||
std::vector<member> memberList;
|
||||
|
||||
// Name of structure
|
||||
std::string name;
|
||||
};
|
||||
|
||||
#endif //GLSL_STRUCT_H
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of GlslStruct
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef GLSL_STRUCT_H
|
||||
#define GLSL_STRUCT_H
|
||||
|
||||
#include "glslCommon.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// GlslStruct
|
||||
///
|
||||
/// \brief This class provides the support for struct types.
|
||||
//=================================================================================================================================
|
||||
class GlslStruct
|
||||
{
|
||||
public:
|
||||
// Struct member description, presently does not handle structs of structs
|
||||
struct member
|
||||
{
|
||||
std::string name;
|
||||
std::string semantic;
|
||||
EGlslSymbolType type;
|
||||
int arraySize;
|
||||
};
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
GlslStruct( const std::string &n) : name(n) {}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
virtual ~GlslStruct() {}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the structure name
|
||||
//=========================================================================================================
|
||||
const std::string& getName() { return name; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a new member to the structure
|
||||
//=========================================================================================================
|
||||
void addMember( const member& m ) { memberList.push_back(m); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the structure member specified by which
|
||||
//=========================================================================================================
|
||||
const member& getMember( int which ) { return memberList[which]; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the number of structure members
|
||||
//=========================================================================================================
|
||||
int memberCount() { return int(memberList.size()); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the declaration for the structure in GLSL as a string
|
||||
//=========================================================================================================
|
||||
std::string getDecl();
|
||||
private:
|
||||
|
||||
// Members in structure
|
||||
std::vector<member> memberList;
|
||||
|
||||
// Name of structure
|
||||
std::string name;
|
||||
};
|
||||
|
||||
#endif //GLSL_STRUCT_H
|
||||
|
|
|
@ -1,382 +1,382 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of GlslSymbol
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
#include "glslSymbol.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Helper Functions Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Write boolean value to output buffer
|
||||
/// \param out
|
||||
/// Output string buffer
|
||||
/// \param b
|
||||
/// Boolean value to write as string
|
||||
//=========================================================================================================
|
||||
static void writeBool( std::stringstream &out, bool b )
|
||||
{
|
||||
out << ((b) ? "true" : "false");
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Constructor(s) / Destructor(s) Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
// Constructor
|
||||
//=========================================================================================================
|
||||
GlslSymbol::GlslSymbol( const std::string &n, const std::string &s, int id, EGlslSymbolType t, EGlslQualifier q, int as ) :
|
||||
semantic(s),
|
||||
identifier(id),
|
||||
type(t),
|
||||
qual(q),
|
||||
arraySize(as),
|
||||
mangle(0),
|
||||
structPtr(0),
|
||||
isParameter(false),
|
||||
refCount(0)
|
||||
{
|
||||
if ( isReservedGlslKeyword ( n ) )
|
||||
{
|
||||
name = "xlat_var_" + n;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = n;
|
||||
}
|
||||
mangledName = name;
|
||||
|
||||
if ( qual == EqtMutableUniform)
|
||||
mutableMangledName = "xlat_mutable_" + mangledName;
|
||||
else
|
||||
mutableMangledName = mangledName;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
GlslSymbol::~GlslSymbol()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Private methods block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Is the variable name a reserved GLSL keyword that could have passed through the lexer?
|
||||
/// \param name
|
||||
/// Name to check against keywords
|
||||
//=========================================================================================================
|
||||
bool GlslSymbol::isReservedGlslKeyword ( const std::string &name ) const
|
||||
{
|
||||
// Check against names that are keywords in GLSL, but not HLSL
|
||||
if ( (name == "input") ||
|
||||
(name == "output") )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public methods block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Write symbol declaration to the output stream
|
||||
/// \param out
|
||||
/// Output string buffer
|
||||
/// \param local
|
||||
/// Is the parameter local
|
||||
//=========================================================================================================
|
||||
void GlslSymbol::writeDecl( std::stringstream &out, bool local )
|
||||
{
|
||||
switch (qual)
|
||||
{
|
||||
case EqtNone: break;
|
||||
case EqtUniform: out << "uniform "; break;
|
||||
case EqtMutableUniform:
|
||||
if (!local)
|
||||
out << "uniform ";
|
||||
break;
|
||||
case EqtConst: out << "const "; break;
|
||||
case EqtIn: out << "in "; break;
|
||||
case EqtOut: out << "out "; break;
|
||||
case EqtInOut: out << "inout "; break;
|
||||
}
|
||||
|
||||
writeType( out, type, structPtr);
|
||||
|
||||
out << " ";
|
||||
|
||||
if (local)
|
||||
out << mutableMangledName;
|
||||
else
|
||||
out << mangledName;
|
||||
|
||||
if (arraySize)
|
||||
{
|
||||
out << "[" << arraySize << "]";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Write symbol initializer to the output stream
|
||||
/// \param out
|
||||
/// Output string buffer
|
||||
/// \param local
|
||||
/// Element in symbol to initialize
|
||||
//=========================================================================================================
|
||||
void GlslSymbol::writeInitializer( std::stringstream &out, int element )
|
||||
{
|
||||
int elementCount = 0;
|
||||
EGlslSymbolType baseType = EgstVoid;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EgstBool:
|
||||
case EgstBool2:
|
||||
case EgstBool3:
|
||||
case EgstBool4:
|
||||
baseType = EgstBool;
|
||||
elementCount = type - EgstBool + 1;
|
||||
break;
|
||||
|
||||
case EgstInt:
|
||||
case EgstInt2:
|
||||
case EgstInt3:
|
||||
case EgstInt4:
|
||||
baseType = EgstInt;
|
||||
elementCount = type - EgstInt + 1;
|
||||
break;
|
||||
|
||||
case EgstFloat:
|
||||
case EgstFloat2:
|
||||
case EgstFloat3:
|
||||
case EgstFloat4:
|
||||
baseType = EgstFloat;
|
||||
elementCount = type - EgstFloat + 1;
|
||||
break;
|
||||
|
||||
case EgstFloat2x2:
|
||||
case EgstFloat3x3:
|
||||
case EgstFloat4x4:
|
||||
baseType = EgstFloat;
|
||||
elementCount = type - EgstFloat2x2 + 2;
|
||||
elementCount *= elementCount;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
int offset = elementCount * element;
|
||||
|
||||
if (baseType == EgstBool)
|
||||
{
|
||||
if (elementCount > 1)
|
||||
out << getTypeString(type) << "( ";
|
||||
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
if (ii != 0) out << ", ";
|
||||
writeBool( out, initializer[ ii + offset] != 0.0f);
|
||||
}
|
||||
|
||||
if (elementCount > 1)
|
||||
out << ")";
|
||||
}
|
||||
else if (baseType == EgstInt)
|
||||
{
|
||||
if (elementCount > 1)
|
||||
out << getTypeString(type) << "( ";
|
||||
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
if (ii != 0) out << ", ";
|
||||
out << (int)initializer[ ii + offset];
|
||||
}
|
||||
|
||||
if (elementCount > 1)
|
||||
out << ")";
|
||||
}
|
||||
else if (baseType == EgstFloat)
|
||||
{
|
||||
if (elementCount > 1)
|
||||
out << getTypeString(type) << "( ";
|
||||
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
if (ii != 0) out << ", ";
|
||||
out << initializer[ ii + offset];
|
||||
}
|
||||
|
||||
if (elementCount > 1)
|
||||
out << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set symbol to be initialized to a constant value
|
||||
/// \param ptr
|
||||
/// Constant union representing value to initialize symbol to
|
||||
//=========================================================================================================
|
||||
void GlslSymbol::setInitializer( const constUnion *ptr )
|
||||
{
|
||||
int elementCount = 0;
|
||||
EGlslSymbolType baseType = EgstVoid;
|
||||
int as = arraySize;
|
||||
|
||||
as = (as) ? as : 1;
|
||||
|
||||
// No support for initialization of samplers or structures presently
|
||||
assert( type < EgstSamplerGeneric);
|
||||
|
||||
initializer.clear();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EgstBool:
|
||||
case EgstBool2:
|
||||
case EgstBool3:
|
||||
case EgstBool4:
|
||||
baseType = EgstBool;
|
||||
elementCount = type - EgstBool + 1;
|
||||
break;
|
||||
|
||||
case EgstInt:
|
||||
case EgstInt2:
|
||||
case EgstInt3:
|
||||
case EgstInt4:
|
||||
baseType = EgstInt;
|
||||
elementCount = type - EgstInt + 1;
|
||||
break;
|
||||
|
||||
case EgstFloat:
|
||||
case EgstFloat2:
|
||||
case EgstFloat3:
|
||||
case EgstFloat4:
|
||||
baseType = EgstFloat;
|
||||
elementCount = type - EgstFloat + 1;
|
||||
break;
|
||||
|
||||
case EgstFloat2x2:
|
||||
case EgstFloat3x3:
|
||||
case EgstFloat4x4:
|
||||
baseType = EgstFloat;
|
||||
elementCount = type - EgstFloat2x2 + 2;
|
||||
elementCount *= elementCount; //square it
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
// Handle the all the array elements
|
||||
elementCount *= as;
|
||||
|
||||
if (baseType == EgstBool)
|
||||
{
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
initializer.push_back( ptr[ii].getBConst() ? 1.0f : 0.0f);
|
||||
}
|
||||
}
|
||||
else if (baseType == EgstInt)
|
||||
{
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
initializer.push_back( (float)ptr[ii].getIConst());
|
||||
}
|
||||
}
|
||||
else if (baseType == EgstFloat)
|
||||
{
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
initializer.push_back( ptr[ii].getFConst());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the mangled name for the symbol
|
||||
//=========================================================================================================
|
||||
void GlslSymbol::mangleName()
|
||||
{
|
||||
std::stringstream s;
|
||||
mangle++;
|
||||
s << "_" << mangle;
|
||||
mangledName = name + s.str();
|
||||
if ( qual == EqtMutableUniform)
|
||||
mutableMangledName = "xlat_mutable_" + mangledName;
|
||||
else
|
||||
mutableMangledName = mangledName;
|
||||
}
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of GlslSymbol
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
#include "glslSymbol.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Helper Functions Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Write boolean value to output buffer
|
||||
/// \param out
|
||||
/// Output string buffer
|
||||
/// \param b
|
||||
/// Boolean value to write as string
|
||||
//=========================================================================================================
|
||||
static void writeBool( std::stringstream &out, bool b )
|
||||
{
|
||||
out << ((b) ? "true" : "false");
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Constructor(s) / Destructor(s) Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
// Constructor
|
||||
//=========================================================================================================
|
||||
GlslSymbol::GlslSymbol( const std::string &n, const std::string &s, int id, EGlslSymbolType t, EGlslQualifier q, int as ) :
|
||||
semantic(s),
|
||||
identifier(id),
|
||||
type(t),
|
||||
qual(q),
|
||||
arraySize(as),
|
||||
mangle(0),
|
||||
structPtr(0),
|
||||
isParameter(false),
|
||||
refCount(0)
|
||||
{
|
||||
if ( isReservedGlslKeyword ( n ) )
|
||||
{
|
||||
name = "xlat_var_" + n;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = n;
|
||||
}
|
||||
mangledName = name;
|
||||
|
||||
if ( qual == EqtMutableUniform)
|
||||
mutableMangledName = "xlat_mutable_" + mangledName;
|
||||
else
|
||||
mutableMangledName = mangledName;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
GlslSymbol::~GlslSymbol()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Private methods block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Is the variable name a reserved GLSL keyword that could have passed through the lexer?
|
||||
/// \param name
|
||||
/// Name to check against keywords
|
||||
//=========================================================================================================
|
||||
bool GlslSymbol::isReservedGlslKeyword ( const std::string &name ) const
|
||||
{
|
||||
// Check against names that are keywords in GLSL, but not HLSL
|
||||
if ( (name == "input") ||
|
||||
(name == "output") )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public methods block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Write symbol declaration to the output stream
|
||||
/// \param out
|
||||
/// Output string buffer
|
||||
/// \param local
|
||||
/// Is the parameter local
|
||||
//=========================================================================================================
|
||||
void GlslSymbol::writeDecl( std::stringstream &out, bool local )
|
||||
{
|
||||
switch (qual)
|
||||
{
|
||||
case EqtNone: break;
|
||||
case EqtUniform: out << "uniform "; break;
|
||||
case EqtMutableUniform:
|
||||
if (!local)
|
||||
out << "uniform ";
|
||||
break;
|
||||
case EqtConst: out << "const "; break;
|
||||
case EqtIn: out << "in "; break;
|
||||
case EqtOut: out << "out "; break;
|
||||
case EqtInOut: out << "inout "; break;
|
||||
}
|
||||
|
||||
writeType( out, type, structPtr);
|
||||
|
||||
out << " ";
|
||||
|
||||
if (local)
|
||||
out << mutableMangledName;
|
||||
else
|
||||
out << mangledName;
|
||||
|
||||
if (arraySize)
|
||||
{
|
||||
out << "[" << arraySize << "]";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Write symbol initializer to the output stream
|
||||
/// \param out
|
||||
/// Output string buffer
|
||||
/// \param local
|
||||
/// Element in symbol to initialize
|
||||
//=========================================================================================================
|
||||
void GlslSymbol::writeInitializer( std::stringstream &out, int element )
|
||||
{
|
||||
int elementCount = 0;
|
||||
EGlslSymbolType baseType = EgstVoid;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EgstBool:
|
||||
case EgstBool2:
|
||||
case EgstBool3:
|
||||
case EgstBool4:
|
||||
baseType = EgstBool;
|
||||
elementCount = type - EgstBool + 1;
|
||||
break;
|
||||
|
||||
case EgstInt:
|
||||
case EgstInt2:
|
||||
case EgstInt3:
|
||||
case EgstInt4:
|
||||
baseType = EgstInt;
|
||||
elementCount = type - EgstInt + 1;
|
||||
break;
|
||||
|
||||
case EgstFloat:
|
||||
case EgstFloat2:
|
||||
case EgstFloat3:
|
||||
case EgstFloat4:
|
||||
baseType = EgstFloat;
|
||||
elementCount = type - EgstFloat + 1;
|
||||
break;
|
||||
|
||||
case EgstFloat2x2:
|
||||
case EgstFloat3x3:
|
||||
case EgstFloat4x4:
|
||||
baseType = EgstFloat;
|
||||
elementCount = type - EgstFloat2x2 + 2;
|
||||
elementCount *= elementCount;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
int offset = elementCount * element;
|
||||
|
||||
if (baseType == EgstBool)
|
||||
{
|
||||
if (elementCount > 1)
|
||||
out << getTypeString(type) << "( ";
|
||||
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
if (ii != 0) out << ", ";
|
||||
writeBool( out, initializer[ ii + offset] != 0.0f);
|
||||
}
|
||||
|
||||
if (elementCount > 1)
|
||||
out << ")";
|
||||
}
|
||||
else if (baseType == EgstInt)
|
||||
{
|
||||
if (elementCount > 1)
|
||||
out << getTypeString(type) << "( ";
|
||||
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
if (ii != 0) out << ", ";
|
||||
out << (int)initializer[ ii + offset];
|
||||
}
|
||||
|
||||
if (elementCount > 1)
|
||||
out << ")";
|
||||
}
|
||||
else if (baseType == EgstFloat)
|
||||
{
|
||||
if (elementCount > 1)
|
||||
out << getTypeString(type) << "( ";
|
||||
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
if (ii != 0) out << ", ";
|
||||
out << initializer[ ii + offset];
|
||||
}
|
||||
|
||||
if (elementCount > 1)
|
||||
out << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set symbol to be initialized to a constant value
|
||||
/// \param ptr
|
||||
/// Constant union representing value to initialize symbol to
|
||||
//=========================================================================================================
|
||||
void GlslSymbol::setInitializer( const constUnion *ptr )
|
||||
{
|
||||
int elementCount = 0;
|
||||
EGlslSymbolType baseType = EgstVoid;
|
||||
int as = arraySize;
|
||||
|
||||
as = (as) ? as : 1;
|
||||
|
||||
// No support for initialization of samplers or structures presently
|
||||
assert( type < EgstSamplerGeneric);
|
||||
|
||||
initializer.clear();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EgstBool:
|
||||
case EgstBool2:
|
||||
case EgstBool3:
|
||||
case EgstBool4:
|
||||
baseType = EgstBool;
|
||||
elementCount = type - EgstBool + 1;
|
||||
break;
|
||||
|
||||
case EgstInt:
|
||||
case EgstInt2:
|
||||
case EgstInt3:
|
||||
case EgstInt4:
|
||||
baseType = EgstInt;
|
||||
elementCount = type - EgstInt + 1;
|
||||
break;
|
||||
|
||||
case EgstFloat:
|
||||
case EgstFloat2:
|
||||
case EgstFloat3:
|
||||
case EgstFloat4:
|
||||
baseType = EgstFloat;
|
||||
elementCount = type - EgstFloat + 1;
|
||||
break;
|
||||
|
||||
case EgstFloat2x2:
|
||||
case EgstFloat3x3:
|
||||
case EgstFloat4x4:
|
||||
baseType = EgstFloat;
|
||||
elementCount = type - EgstFloat2x2 + 2;
|
||||
elementCount *= elementCount; //square it
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
// Handle the all the array elements
|
||||
elementCount *= as;
|
||||
|
||||
if (baseType == EgstBool)
|
||||
{
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
initializer.push_back( ptr[ii].getBConst() ? 1.0f : 0.0f);
|
||||
}
|
||||
}
|
||||
else if (baseType == EgstInt)
|
||||
{
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
initializer.push_back( (float)ptr[ii].getIConst());
|
||||
}
|
||||
}
|
||||
else if (baseType == EgstFloat)
|
||||
{
|
||||
for (int ii = 0; ii < elementCount; ii++)
|
||||
{
|
||||
initializer.push_back( ptr[ii].getFConst());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the mangled name for the symbol
|
||||
//=========================================================================================================
|
||||
void GlslSymbol::mangleName()
|
||||
{
|
||||
std::stringstream s;
|
||||
mangle++;
|
||||
s << "_" << mangle;
|
||||
mangledName = name + s.str();
|
||||
if ( qual == EqtMutableUniform)
|
||||
mutableMangledName = "xlat_mutable_" + mangledName;
|
||||
else
|
||||
mutableMangledName = mangledName;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,230 +1,230 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of GlslSymbol
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef GLSL_SYMBOL_H
|
||||
#define GLSL_SYMBOL_H
|
||||
|
||||
#include "glslCommon.h"
|
||||
#include "glslStruct.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// GlslSymbol
|
||||
///
|
||||
/// \brief This class provides the implementation for GLSL symbols
|
||||
//=================================================================================================================================
|
||||
class GlslSymbol
|
||||
{
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
GlslSymbol( const std::string &n, const std::string &s, int id, EGlslSymbolType t, EGlslQualifier q, int as = 0 );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
virtual ~GlslSymbol();
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol is a parameter
|
||||
//=========================================================================================================
|
||||
bool getIsParameter() { return isParameter; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set whether the symbol is a parameter
|
||||
//=========================================================================================================
|
||||
void setIsParameter( bool param ) { isParameter = param; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol is a global
|
||||
//=========================================================================================================
|
||||
bool getIsGlobal() { return !isLocal(qual); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol is mutable
|
||||
//=========================================================================================================
|
||||
bool getIsMutable() { return qual == EqtMutableUniform; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get mangled name of symbol
|
||||
//=========================================================================================================
|
||||
const std::string &getName( bool local = true ) const { return ( (local ) ? mutableMangledName : mangledName ); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get original name of symbol
|
||||
//=========================================================================================================
|
||||
const std::string &getOrgName() { return name; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol has an HLSL semantic
|
||||
//=========================================================================================================
|
||||
bool hasSemantic() const { return (semantic.size() > 0); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get symbol HLSL semantic
|
||||
//=========================================================================================================
|
||||
const std::string &getSemantic() const { return semantic; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the symbol ID
|
||||
//=========================================================================================================
|
||||
int getId() { return identifier; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol is an array
|
||||
//=========================================================================================================
|
||||
bool isArray() const { return (arraySize > 0); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the symbol array size
|
||||
//=========================================================================================================
|
||||
int getArraySize() const { return arraySize; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the symbol GLSL type
|
||||
//=========================================================================================================
|
||||
EGlslSymbolType getType() const { return type; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the symbol GLSL qualifier
|
||||
//=========================================================================================================
|
||||
EGlslQualifier getQualifier() const { return qual; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Update the type of the symbol
|
||||
//=========================================================================================================
|
||||
void updateType( EGlslSymbolType t ) { assert( type == EgstSamplerGeneric); type = t; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the GLSL struct for symbol
|
||||
//=========================================================================================================
|
||||
GlslStruct* getStruct() { return structPtr; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the GLSL struct for symbol (const)
|
||||
//=========================================================================================================
|
||||
const GlslStruct* getStruct() const { return structPtr; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the GLSL struct for symbol
|
||||
//=========================================================================================================
|
||||
void setStruct( GlslStruct *s ) { structPtr = s; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol has an initializer
|
||||
//=========================================================================================================
|
||||
bool hasInitializer() const { return initializer.size() != 0; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the symbol initializer
|
||||
//=========================================================================================================
|
||||
const float* getInitializer() const { return &initializer[0]; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the size of the initializer
|
||||
//=========================================================================================================
|
||||
int initializerSize() const { return (int)initializer.size(); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Write symbol declaration to the output stream
|
||||
//=========================================================================================================
|
||||
void writeDecl( std::stringstream &out, bool local = false );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Write symbol initializer to the output stream
|
||||
//=========================================================================================================
|
||||
void writeInitializer( std::stringstream &out, int element = 0);
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set symbol to be initialized to a constant value
|
||||
//=========================================================================================================
|
||||
void setInitializer( const constUnion *ptr );
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the mangled name for the symbol
|
||||
//=========================================================================================================
|
||||
void mangleName();
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a reference to the symbol
|
||||
//=========================================================================================================
|
||||
void addRef() { refCount++; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Release a reference to the symbol
|
||||
//=========================================================================================================
|
||||
void releaseRef() { assert (refCount >= 0 ); if ( refCount > 0 ) refCount--; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the reference count for the symbol
|
||||
//=========================================================================================================
|
||||
int getRef() { return refCount; }
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Is the variable name a reserved GLSL keyword that could have passed through the lexer?
|
||||
//=========================================================================================================
|
||||
bool isReservedGlslKeyword ( const std::string &name ) const;
|
||||
|
||||
std::string name;
|
||||
std::string mangledName;
|
||||
std::string mutableMangledName;
|
||||
std::string semantic;
|
||||
int identifier;
|
||||
EGlslSymbolType type;
|
||||
EGlslQualifier qual;
|
||||
int arraySize;
|
||||
int mangle;
|
||||
GlslStruct *structPtr;
|
||||
bool isParameter;
|
||||
std::vector<float> initializer;
|
||||
int refCount;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //GLSL_SYMBOL_H
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of GlslSymbol
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef GLSL_SYMBOL_H
|
||||
#define GLSL_SYMBOL_H
|
||||
|
||||
#include "glslCommon.h"
|
||||
#include "glslStruct.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// GlslSymbol
|
||||
///
|
||||
/// \brief This class provides the implementation for GLSL symbols
|
||||
//=================================================================================================================================
|
||||
class GlslSymbol
|
||||
{
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
GlslSymbol( const std::string &n, const std::string &s, int id, EGlslSymbolType t, EGlslQualifier q, int as = 0 );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
virtual ~GlslSymbol();
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol is a parameter
|
||||
//=========================================================================================================
|
||||
bool getIsParameter() { return isParameter; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set whether the symbol is a parameter
|
||||
//=========================================================================================================
|
||||
void setIsParameter( bool param ) { isParameter = param; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol is a global
|
||||
//=========================================================================================================
|
||||
bool getIsGlobal() { return !isLocal(qual); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol is mutable
|
||||
//=========================================================================================================
|
||||
bool getIsMutable() { return qual == EqtMutableUniform; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get mangled name of symbol
|
||||
//=========================================================================================================
|
||||
const std::string &getName( bool local = true ) const { return ( (local ) ? mutableMangledName : mangledName ); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get original name of symbol
|
||||
//=========================================================================================================
|
||||
const std::string &getOrgName() { return name; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol has an HLSL semantic
|
||||
//=========================================================================================================
|
||||
bool hasSemantic() const { return (semantic.size() > 0); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get symbol HLSL semantic
|
||||
//=========================================================================================================
|
||||
const std::string &getSemantic() const { return semantic; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the symbol ID
|
||||
//=========================================================================================================
|
||||
int getId() { return identifier; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol is an array
|
||||
//=========================================================================================================
|
||||
bool isArray() const { return (arraySize > 0); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the symbol array size
|
||||
//=========================================================================================================
|
||||
int getArraySize() const { return arraySize; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the symbol GLSL type
|
||||
//=========================================================================================================
|
||||
EGlslSymbolType getType() const { return type; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the symbol GLSL qualifier
|
||||
//=========================================================================================================
|
||||
EGlslQualifier getQualifier() const { return qual; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Update the type of the symbol
|
||||
//=========================================================================================================
|
||||
void updateType( EGlslSymbolType t ) { assert( type == EgstSamplerGeneric); type = t; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the GLSL struct for symbol
|
||||
//=========================================================================================================
|
||||
GlslStruct* getStruct() { return structPtr; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the GLSL struct for symbol (const)
|
||||
//=========================================================================================================
|
||||
const GlslStruct* getStruct() const { return structPtr; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the GLSL struct for symbol
|
||||
//=========================================================================================================
|
||||
void setStruct( GlslStruct *s ) { structPtr = s; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get whether the symbol has an initializer
|
||||
//=========================================================================================================
|
||||
bool hasInitializer() const { return initializer.size() != 0; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the symbol initializer
|
||||
//=========================================================================================================
|
||||
const float* getInitializer() const { return &initializer[0]; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the size of the initializer
|
||||
//=========================================================================================================
|
||||
int initializerSize() const { return (int)initializer.size(); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Write symbol declaration to the output stream
|
||||
//=========================================================================================================
|
||||
void writeDecl( std::stringstream &out, bool local = false );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Write symbol initializer to the output stream
|
||||
//=========================================================================================================
|
||||
void writeInitializer( std::stringstream &out, int element = 0);
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set symbol to be initialized to a constant value
|
||||
//=========================================================================================================
|
||||
void setInitializer( const constUnion *ptr );
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the mangled name for the symbol
|
||||
//=========================================================================================================
|
||||
void mangleName();
|
||||
|
||||
//=========================================================================================================
|
||||
/// Add a reference to the symbol
|
||||
//=========================================================================================================
|
||||
void addRef() { refCount++; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Release a reference to the symbol
|
||||
//=========================================================================================================
|
||||
void releaseRef() { assert (refCount >= 0 ); if ( refCount > 0 ) refCount--; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the reference count for the symbol
|
||||
//=========================================================================================================
|
||||
int getRef() { return refCount; }
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Is the variable name a reserved GLSL keyword that could have passed through the lexer?
|
||||
//=========================================================================================================
|
||||
bool isReservedGlslKeyword ( const std::string &name ) const;
|
||||
|
||||
std::string name;
|
||||
std::string mangledName;
|
||||
std::string mutableMangledName;
|
||||
std::string semantic;
|
||||
int identifier;
|
||||
EGlslSymbolType type;
|
||||
EGlslQualifier qual;
|
||||
int arraySize;
|
||||
int mangle;
|
||||
GlslStruct *structPtr;
|
||||
bool isParameter;
|
||||
std::vector<float> initializer;
|
||||
int refCount;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //GLSL_SYMBOL_H
|
||||
|
||||
|
|
|
@ -1,110 +1,110 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of HlslCrossCompiler
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
#include "hlslCrossCompiler.h"
|
||||
|
||||
#include "glslOutput.h"
|
||||
#include "typeSamplers.h"
|
||||
#include "propagateMutable.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Constructor(s) / Destructor(s) Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
HlslCrossCompiler::HlslCrossCompiler(EShLanguage l, int dOptions) :
|
||||
TCompiler(l, infoSink),
|
||||
debugOptions(dOptions)
|
||||
{
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
HlslCrossCompiler::~HlslCrossCompiler()
|
||||
{
|
||||
for ( std::vector<GlslFunction*>::iterator it = functionList.begin() ; it != functionList.end(); it++)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
|
||||
for ( std::vector<GlslStruct*>::iterator it = structList.begin() ; it != structList.end(); it++)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public Methods Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Generate code from the given parse tree
|
||||
/// \param root
|
||||
/// Root node of the tree to compile
|
||||
/// \return
|
||||
/// True on succesful compilation of tree, false otherwise
|
||||
//=========================================================================================================
|
||||
bool HlslCrossCompiler::compile( TIntermNode *root )
|
||||
{
|
||||
haveValidObjectCode = true;
|
||||
|
||||
TGlslOutputTraverser glslTraverse( infoSink, functionList, structList);
|
||||
|
||||
TSamplerTraverser::TypeSamplers( root, infoSink);
|
||||
TPropagateMutable::PropagateMutable( root, infoSink);
|
||||
|
||||
root->traverse(&glslTraverse);
|
||||
|
||||
return haveValidObjectCode;
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of HlslCrossCompiler
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
#include "hlslCrossCompiler.h"
|
||||
|
||||
#include "glslOutput.h"
|
||||
#include "typeSamplers.h"
|
||||
#include "propagateMutable.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Constructor(s) / Destructor(s) Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
HlslCrossCompiler::HlslCrossCompiler(EShLanguage l, int dOptions) :
|
||||
TCompiler(l, infoSink),
|
||||
debugOptions(dOptions)
|
||||
{
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
HlslCrossCompiler::~HlslCrossCompiler()
|
||||
{
|
||||
for ( std::vector<GlslFunction*>::iterator it = functionList.begin() ; it != functionList.end(); it++)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
|
||||
for ( std::vector<GlslStruct*>::iterator it = structList.begin() ; it != structList.end(); it++)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public Methods Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Generate code from the given parse tree
|
||||
/// \param root
|
||||
/// Root node of the tree to compile
|
||||
/// \return
|
||||
/// True on succesful compilation of tree, false otherwise
|
||||
//=========================================================================================================
|
||||
bool HlslCrossCompiler::compile( TIntermNode *root )
|
||||
{
|
||||
haveValidObjectCode = true;
|
||||
|
||||
TGlslOutputTraverser glslTraverse( infoSink, functionList, structList);
|
||||
|
||||
TSamplerTraverser::TypeSamplers( root, infoSink);
|
||||
TPropagateMutable::PropagateMutable( root, infoSink);
|
||||
|
||||
root->traverse(&glslTraverse);
|
||||
|
||||
return haveValidObjectCode;
|
||||
}
|
|
@ -1,90 +1,90 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of HlslCrossCompiler
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef HLSL_CROSS_COMPILER_H
|
||||
#define HLSL_CROSS_COMPILER_H
|
||||
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/ShHandle.h"
|
||||
|
||||
#include "glslFunction.h"
|
||||
#include "glslStruct.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// HlslCrossCompiler
|
||||
///
|
||||
/// \brief This class provides the interface to initiate a compile
|
||||
//=================================================================================================================================
|
||||
class HlslCrossCompiler : public TCompiler
|
||||
{
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
HlslCrossCompiler(EShLanguage l, int dOptions);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
virtual ~HlslCrossCompiler();
|
||||
|
||||
//=========================================================================================================
|
||||
/// Generate code from the given parse tree
|
||||
//=========================================================================================================
|
||||
virtual bool compile(TIntermNode* root);
|
||||
|
||||
// Info sink
|
||||
TInfoSink infoSink;
|
||||
|
||||
// Debug options
|
||||
int debugOptions;
|
||||
|
||||
// Function list
|
||||
std::vector<GlslFunction*> functionList;
|
||||
|
||||
// Structure list
|
||||
std::vector<GlslStruct*> structList;
|
||||
};
|
||||
|
||||
#endif //HLSL_CROSS_COMPILER_H
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of HlslCrossCompiler
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef HLSL_CROSS_COMPILER_H
|
||||
#define HLSL_CROSS_COMPILER_H
|
||||
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/ShHandle.h"
|
||||
|
||||
#include "glslFunction.h"
|
||||
#include "glslStruct.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// HlslCrossCompiler
|
||||
///
|
||||
/// \brief This class provides the interface to initiate a compile
|
||||
//=================================================================================================================================
|
||||
class HlslCrossCompiler : public TCompiler
|
||||
{
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
HlslCrossCompiler(EShLanguage l, int dOptions);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
virtual ~HlslCrossCompiler();
|
||||
|
||||
//=========================================================================================================
|
||||
/// Generate code from the given parse tree
|
||||
//=========================================================================================================
|
||||
virtual bool compile(TIntermNode* root);
|
||||
|
||||
// Info sink
|
||||
TInfoSink infoSink;
|
||||
|
||||
// Debug options
|
||||
int debugOptions;
|
||||
|
||||
// Function list
|
||||
std::vector<GlslFunction*> functionList;
|
||||
|
||||
// Structure list
|
||||
std::vector<GlslStruct*> structList;
|
||||
};
|
||||
|
||||
#endif //HLSL_CROSS_COMPILER_H
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,187 +1,187 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of HlslLinker
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef HLSL_LINKER_H
|
||||
#define HLSL_LINKER_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/ShHandle.h"
|
||||
|
||||
|
||||
#include "glslFunction.h"
|
||||
|
||||
#define MAX_ATTRIB_NAME 64
|
||||
|
||||
// Variable classifiers
|
||||
enum EClassifier
|
||||
{
|
||||
EClassNone,
|
||||
EClassAttrib,
|
||||
EClassVarOut,
|
||||
EClassVarIn,
|
||||
EClassRes,
|
||||
EClassUniform
|
||||
};
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
/// HlslCrossCompiler
|
||||
///
|
||||
/// \brief This class provides the implementation of the linker that will actually initiate the generation of the final GLSL
|
||||
/// code.
|
||||
//=================================================================================================================================
|
||||
class HlslLinker : public TLinker
|
||||
{
|
||||
private:
|
||||
|
||||
// Fragment shader GLSL string
|
||||
std::stringstream fragShader;
|
||||
|
||||
// Vertex shader GLSL string
|
||||
std::stringstream vertShader;
|
||||
|
||||
// Uniform list
|
||||
std::vector<ShUniformInfo> uniforms;
|
||||
|
||||
// Helper string to store shader text
|
||||
mutable std::string bs;
|
||||
|
||||
// Table holding the list of user attribute names per semantic
|
||||
char userAttribString[EAttrSemCount][MAX_ATTRIB_NAME];
|
||||
|
||||
// For varyings, determines whether the linker attempts to use user or built-in varyings
|
||||
bool bUserVaryings;
|
||||
|
||||
// Determines whether the linker outputs a shader header to the GLSL stream
|
||||
bool bOutputShaderHeader;
|
||||
|
||||
// Shade header string to output
|
||||
std::string outputShaderHeaderString;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
HlslLinker(int dOptions);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
~HlslLinker();
|
||||
|
||||
//=========================================================================================================
|
||||
/// This function is the main function that initiates code generation for the shader.
|
||||
//=========================================================================================================
|
||||
bool link(THandleList&, const char* vertEntry, const char* fragEntry, bool comments);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Strip the semantic string of any modifiers (e.g. _centroid)
|
||||
//=========================================================================================================
|
||||
std::string stripSemanticModifier(const std::string &semantic, bool bWarn);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Determine the GLSL attribute semantic for a given HLSL semantic
|
||||
//=========================================================================================================
|
||||
EAttribSemantic parseAttributeSemantic(const std::string &semantic);
|
||||
|
||||
//=========================================================================================================
|
||||
/// If the user elects to use user attributes rather than built-ins, this function will set the user
|
||||
/// attribute name the user wishes to use for the semantic passed in.
|
||||
//=========================================================================================================
|
||||
virtual bool setUserAttribName ( EAttribSemantic eSemantic, const char *pName );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Enable the use of user-varyings rather than built-ins in the output code generation
|
||||
//=========================================================================================================
|
||||
virtual void setUseUserVaryings ( bool bUseUserVaryings ) { bUserVaryings = bUseUserVaryings; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Enable the the output of a shader header to the GLSL output stream.
|
||||
//=========================================================================================================
|
||||
virtual bool setShaderHeader ( bool bOutputShaderHeader, const char *shaderHeaderString );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Interface to retreive the output GLSL shader text
|
||||
//=========================================================================================================
|
||||
const char* getShaderText( EShLanguage lang ) const;
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the number of uniforms
|
||||
//=========================================================================================================
|
||||
int getUniformCount() const { return (int)uniforms.size(); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Return the uniform info table
|
||||
//=========================================================================================================
|
||||
const ShUniformInfo* getUniformInfo() const { return ( ( uniforms.size() ) ? &uniforms[0] : 0 ); }
|
||||
|
||||
// Info sink for storing output
|
||||
TInfoSink infoSink;
|
||||
|
||||
// Debug options
|
||||
int debugOptions;
|
||||
|
||||
protected:
|
||||
//=========================================================================================================
|
||||
/// Add the functions called by a function to the function set
|
||||
//=========================================================================================================
|
||||
bool addCalledFunctions( GlslFunction *func, std::set<GlslFunction*> &funcSet, std::vector<GlslFunction*> &funcList);
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the GLSL name, constructor type and padding for a given argument
|
||||
//=========================================================================================================
|
||||
bool getArgumentData( const std::string &name, const std::string &semantic, EGlslSymbolType type,
|
||||
EClassifier c, std::string &outName, std::string &ctor, int &pad, int semanticOffset = 0);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the GLSL name, constructor type and padding for a given symbol
|
||||
//=========================================================================================================
|
||||
bool getArgumentData( GlslSymbol* sym, EClassifier c, std::string &outName,
|
||||
std::string &ctor, int &pad);
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of HlslLinker
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef HLSL_LINKER_H
|
||||
#define HLSL_LINKER_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/ShHandle.h"
|
||||
|
||||
|
||||
#include "glslFunction.h"
|
||||
|
||||
#define MAX_ATTRIB_NAME 64
|
||||
|
||||
// Variable classifiers
|
||||
enum EClassifier
|
||||
{
|
||||
EClassNone,
|
||||
EClassAttrib,
|
||||
EClassVarOut,
|
||||
EClassVarIn,
|
||||
EClassRes,
|
||||
EClassUniform
|
||||
};
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
/// HlslCrossCompiler
|
||||
///
|
||||
/// \brief This class provides the implementation of the linker that will actually initiate the generation of the final GLSL
|
||||
/// code.
|
||||
//=================================================================================================================================
|
||||
class HlslLinker : public TLinker
|
||||
{
|
||||
private:
|
||||
|
||||
// Fragment shader GLSL string
|
||||
std::stringstream fragShader;
|
||||
|
||||
// Vertex shader GLSL string
|
||||
std::stringstream vertShader;
|
||||
|
||||
// Uniform list
|
||||
std::vector<ShUniformInfo> uniforms;
|
||||
|
||||
// Helper string to store shader text
|
||||
mutable std::string bs;
|
||||
|
||||
// Table holding the list of user attribute names per semantic
|
||||
char userAttribString[EAttrSemCount][MAX_ATTRIB_NAME];
|
||||
|
||||
// For varyings, determines whether the linker attempts to use user or built-in varyings
|
||||
bool bUserVaryings;
|
||||
|
||||
// Determines whether the linker outputs a shader header to the GLSL stream
|
||||
bool bOutputShaderHeader;
|
||||
|
||||
// Shade header string to output
|
||||
std::string outputShaderHeaderString;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
HlslLinker(int dOptions);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Destructor
|
||||
//=========================================================================================================
|
||||
~HlslLinker();
|
||||
|
||||
//=========================================================================================================
|
||||
/// This function is the main function that initiates code generation for the shader.
|
||||
//=========================================================================================================
|
||||
bool link(THandleList&, const char* vertEntry, const char* fragEntry, bool comments);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Strip the semantic string of any modifiers (e.g. _centroid)
|
||||
//=========================================================================================================
|
||||
std::string stripSemanticModifier(const std::string &semantic, bool bWarn);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Determine the GLSL attribute semantic for a given HLSL semantic
|
||||
//=========================================================================================================
|
||||
EAttribSemantic parseAttributeSemantic(const std::string &semantic);
|
||||
|
||||
//=========================================================================================================
|
||||
/// If the user elects to use user attributes rather than built-ins, this function will set the user
|
||||
/// attribute name the user wishes to use for the semantic passed in.
|
||||
//=========================================================================================================
|
||||
virtual bool setUserAttribName ( EAttribSemantic eSemantic, const char *pName );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Enable the use of user-varyings rather than built-ins in the output code generation
|
||||
//=========================================================================================================
|
||||
virtual void setUseUserVaryings ( bool bUseUserVaryings ) { bUserVaryings = bUseUserVaryings; }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Enable the the output of a shader header to the GLSL output stream.
|
||||
//=========================================================================================================
|
||||
virtual bool setShaderHeader ( bool bOutputShaderHeader, const char *shaderHeaderString );
|
||||
|
||||
//=========================================================================================================
|
||||
/// Interface to retreive the output GLSL shader text
|
||||
//=========================================================================================================
|
||||
const char* getShaderText( EShLanguage lang ) const;
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the number of uniforms
|
||||
//=========================================================================================================
|
||||
int getUniformCount() const { return (int)uniforms.size(); }
|
||||
|
||||
//=========================================================================================================
|
||||
/// Return the uniform info table
|
||||
//=========================================================================================================
|
||||
const ShUniformInfo* getUniformInfo() const { return ( ( uniforms.size() ) ? &uniforms[0] : 0 ); }
|
||||
|
||||
// Info sink for storing output
|
||||
TInfoSink infoSink;
|
||||
|
||||
// Debug options
|
||||
int debugOptions;
|
||||
|
||||
protected:
|
||||
//=========================================================================================================
|
||||
/// Add the functions called by a function to the function set
|
||||
//=========================================================================================================
|
||||
bool addCalledFunctions( GlslFunction *func, std::set<GlslFunction*> &funcSet, std::vector<GlslFunction*> &funcList);
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the GLSL name, constructor type and padding for a given argument
|
||||
//=========================================================================================================
|
||||
bool getArgumentData( const std::string &name, const std::string &semantic, EGlslSymbolType type,
|
||||
EClassifier c, std::string &outName, std::string &ctor, int &pad, int semanticOffset = 0);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Get the GLSL name, constructor type and padding for a given symbol
|
||||
//=========================================================================================================
|
||||
bool getArgumentData( GlslSymbol* sym, EClassifier c, std::string &outName,
|
||||
std::string &ctor, int &pad);
|
||||
|
||||
};
|
||||
|
||||
#endif //HLSL_LINKER_H
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,64 +1,64 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of support library to generate GLSL functions to support HLSL functions that don't map to built-ins
|
||||
//=================================================================================================================================
|
||||
#ifndef HLSL_SUPPORT_LIB_H
|
||||
#define HLSL_SUPPORT_LIB_H
|
||||
|
||||
#include <string>
|
||||
#include "../Include/intermediate.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// Initialize the library by loading the necessary functions
|
||||
//=================================================================================================================================
|
||||
void initializeHLSLSupportLibrary();
|
||||
|
||||
//=================================================================================================================================
|
||||
/// Free internal data structures
|
||||
//=================================================================================================================================
|
||||
void finalizeHLSLSupportLibrary();
|
||||
|
||||
//=================================================================================================================================
|
||||
/// Return the code string supporting the operation
|
||||
//=================================================================================================================================
|
||||
const std::string& getHLSLSupportCode( TOperator op);
|
||||
|
||||
#endif //HLSL_SUPPORT_LIB_H
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of support library to generate GLSL functions to support HLSL functions that don't map to built-ins
|
||||
//=================================================================================================================================
|
||||
#ifndef HLSL_SUPPORT_LIB_H
|
||||
#define HLSL_SUPPORT_LIB_H
|
||||
|
||||
#include <string>
|
||||
#include "../Include/intermediate.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// Initialize the library by loading the necessary functions
|
||||
//=================================================================================================================================
|
||||
void initializeHLSLSupportLibrary();
|
||||
|
||||
//=================================================================================================================================
|
||||
/// Free internal data structures
|
||||
//=================================================================================================================================
|
||||
void finalizeHLSLSupportLibrary();
|
||||
|
||||
//=================================================================================================================================
|
||||
/// Return the code string supporting the operation
|
||||
//=================================================================================================================================
|
||||
const std::string& getHLSLSupportCode( TOperator op);
|
||||
|
||||
#endif //HLSL_SUPPORT_LIB_H
|
||||
|
||||
|
|
|
@ -1,122 +1,122 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of TPropagateMutable
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
#include "propagateMutable.h"
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Private Members Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Propage the mutable uniform qualifier throughout the symbols as needed
|
||||
/// \param Node
|
||||
/// Symbol node to propogate mutables
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
void TPropagateMutable::traverseSymbol( TIntermSymbol *node, TIntermTraverser *it )
|
||||
{
|
||||
TPropagateMutable* sit = static_cast<TPropagateMutable*>(it);
|
||||
|
||||
if (sit->abort)
|
||||
return;
|
||||
|
||||
if (sit->propagating && sit->id == node->getId())
|
||||
{
|
||||
node->getTypePointer()->changeQualifier( EvqMutableUniform );
|
||||
|
||||
}
|
||||
else if (!sit->propagating && sit->fixedIds.find(node->getId()) == sit->fixedIds.end() )
|
||||
{
|
||||
if (node->getQualifier() == EvqMutableUniform)
|
||||
{
|
||||
sit->abort = true;
|
||||
sit->id = node->getId();
|
||||
sit->fixedIds.insert(sit->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public Members Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// The TProgpogateMutable class implements only the symbol travere function (this member). It goes
|
||||
/// through the symbol and propogates the mutubale qualifier through the symbol nodes. This function
|
||||
/// initiates the propogation.
|
||||
/// \param node
|
||||
/// The root node of the tree
|
||||
/// \param info
|
||||
/// Infosink to log to
|
||||
//=========================================================================================================
|
||||
void TPropagateMutable::PropagateMutable( TIntermNode *node, TInfoSink &info )
|
||||
{
|
||||
TPropagateMutable st(info);
|
||||
|
||||
do
|
||||
{
|
||||
st.abort = false;
|
||||
node->traverse( &st);
|
||||
|
||||
// If we aborted, try to type the node we aborted for
|
||||
if (st.abort)
|
||||
{
|
||||
st.propagating = true;
|
||||
st.abort = false;
|
||||
node->traverse( &st);
|
||||
st.propagating = false;
|
||||
st.abort = true;
|
||||
}
|
||||
} while (st.abort);
|
||||
|
||||
}
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of TPropagateMutable
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
#include "propagateMutable.h"
|
||||
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Private Members Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
//=========================================================================================================
|
||||
/// Propage the mutable uniform qualifier throughout the symbols as needed
|
||||
/// \param Node
|
||||
/// Symbol node to propogate mutables
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
void TPropagateMutable::traverseSymbol( TIntermSymbol *node, TIntermTraverser *it )
|
||||
{
|
||||
TPropagateMutable* sit = static_cast<TPropagateMutable*>(it);
|
||||
|
||||
if (sit->abort)
|
||||
return;
|
||||
|
||||
if (sit->propagating && sit->id == node->getId())
|
||||
{
|
||||
node->getTypePointer()->changeQualifier( EvqMutableUniform );
|
||||
|
||||
}
|
||||
else if (!sit->propagating && sit->fixedIds.find(node->getId()) == sit->fixedIds.end() )
|
||||
{
|
||||
if (node->getQualifier() == EvqMutableUniform)
|
||||
{
|
||||
sit->abort = true;
|
||||
sit->id = node->getId();
|
||||
sit->fixedIds.insert(sit->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Public Members Block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// The TProgpogateMutable class implements only the symbol travere function (this member). It goes
|
||||
/// through the symbol and propogates the mutubale qualifier through the symbol nodes. This function
|
||||
/// initiates the propogation.
|
||||
/// \param node
|
||||
/// The root node of the tree
|
||||
/// \param info
|
||||
/// Infosink to log to
|
||||
//=========================================================================================================
|
||||
void TPropagateMutable::PropagateMutable( TIntermNode *node, TInfoSink &info )
|
||||
{
|
||||
TPropagateMutable st(info);
|
||||
|
||||
do
|
||||
{
|
||||
st.abort = false;
|
||||
node->traverse( &st);
|
||||
|
||||
// If we aborted, try to type the node we aborted for
|
||||
if (st.abort)
|
||||
{
|
||||
st.propagating = true;
|
||||
st.abort = false;
|
||||
node->traverse( &st);
|
||||
st.propagating = false;
|
||||
st.abort = true;
|
||||
}
|
||||
} while (st.abort);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,96 +1,96 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of TPropagateMutable
|
||||
//=================================================================================================================================
|
||||
#ifndef PROPAGATE_MUTABLE_H
|
||||
#define PROPAGATE_MUTABLE_H
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "localintermediate.h"
|
||||
|
||||
#include "glslOutput.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// TPropagateMutable
|
||||
///
|
||||
/// \brief This class iterates over the intermediate tree and propgates mutable uniforms qualifiers as necessary
|
||||
/// to the symbols
|
||||
//=================================================================================================================================
|
||||
class TPropagateMutable : public TIntermTraverser
|
||||
{
|
||||
private:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Propage the mutable uniform qualifier throughout the symbols as needed
|
||||
//=========================================================================================================
|
||||
static void traverseSymbol(TIntermSymbol*, TIntermTraverser*);
|
||||
|
||||
// Info sink
|
||||
TInfoSink& infoSink;
|
||||
|
||||
// Whether to abort propogation
|
||||
bool abort;
|
||||
|
||||
// These are used to go into "propagating mode"
|
||||
bool propagating;
|
||||
int id;
|
||||
|
||||
// set to prevent infinite loops
|
||||
std::set<int> fixedIds;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
TPropagateMutable( TInfoSink &is) : infoSink(is), abort(false), propagating(false), id(0)
|
||||
{
|
||||
visitSymbol = traverseSymbol;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// This function initiates the propogation.
|
||||
//=========================================================================================================
|
||||
static void PropagateMutable( TIntermNode *node, TInfoSink &info);
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Definition of TPropagateMutable
|
||||
//=================================================================================================================================
|
||||
#ifndef PROPAGATE_MUTABLE_H
|
||||
#define PROPAGATE_MUTABLE_H
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "localintermediate.h"
|
||||
|
||||
#include "glslOutput.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// TPropagateMutable
|
||||
///
|
||||
/// \brief This class iterates over the intermediate tree and propgates mutable uniforms qualifiers as necessary
|
||||
/// to the symbols
|
||||
//=================================================================================================================================
|
||||
class TPropagateMutable : public TIntermTraverser
|
||||
{
|
||||
private:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Propage the mutable uniform qualifier throughout the symbols as needed
|
||||
//=========================================================================================================
|
||||
static void traverseSymbol(TIntermSymbol*, TIntermTraverser*);
|
||||
|
||||
// Info sink
|
||||
TInfoSink& infoSink;
|
||||
|
||||
// Whether to abort propogation
|
||||
bool abort;
|
||||
|
||||
// These are used to go into "propagating mode"
|
||||
bool propagating;
|
||||
int id;
|
||||
|
||||
// set to prevent infinite loops
|
||||
std::set<int> fixedIds;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
TPropagateMutable( TInfoSink &is) : infoSink(is), abort(false), propagating(false), id(0)
|
||||
{
|
||||
visitSymbol = traverseSymbol;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// This function initiates the propogation.
|
||||
//=========================================================================================================
|
||||
static void PropagateMutable( TIntermNode *node, TInfoSink &info);
|
||||
|
||||
};
|
||||
|
||||
#endif //PROPAGATE_MUTABLE_H
|
|
@ -1,468 +1,468 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of TSamplerTraverser
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
#include "typeSamplers.h"
|
||||
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse symbol node
|
||||
/// \param node
|
||||
/// Symbol node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
void TSamplerTraverser::traverseSymbol( TIntermSymbol *node, TIntermTraverser *it )
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
if (sit->abort)
|
||||
return;
|
||||
|
||||
if (sit->typing && sit->id == node->getId())
|
||||
{
|
||||
TType* type = node->getTypePointer();
|
||||
|
||||
// Technically most of these should never happen
|
||||
if ( type->isArray())
|
||||
type->setType( sit->sampType, type->getNominalSize(), type->isMatrix(), true, type->getArraySize());
|
||||
else
|
||||
type->setType( sit->sampType, type->getNominalSize(), type->isMatrix(), false);
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse binary node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Binary node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseBinary( bool preVisit, TIntermBinary *node, TIntermTraverser *it )
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
if (sit->abort)
|
||||
return false;
|
||||
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpAssign:
|
||||
//believed to be disallowed on samplers...
|
||||
break;
|
||||
|
||||
|
||||
case EOpIndexDirect:
|
||||
case EOpIndexIndirect:
|
||||
//not planning to support arrays of samplers with different types
|
||||
break;
|
||||
|
||||
case EOpIndexDirectStruct:
|
||||
//Structs in samplers not supported
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse unary node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Unary node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseUnary( bool preVisit, TIntermUnary *node, TIntermTraverser *it)
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse selection node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Selection node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseSelection( bool preVisit, TIntermSelection *node, TIntermTraverser *it)
|
||||
{
|
||||
//TODO: might need to run down this rat hole for ?: operator
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse aggregate node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Aggregate node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseAggregate( bool preVisit, TIntermAggregate *node, TIntermTraverser *it)
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
TInfoSink &infoSink = sit->infoSink;
|
||||
|
||||
if (sit->abort)
|
||||
return false;
|
||||
|
||||
if (! (sit->typing) )
|
||||
{
|
||||
switch (node->getOp())
|
||||
{
|
||||
|
||||
case EOpFunction:
|
||||
// Store the current function name to use to setup the parameters
|
||||
sit->currentFunction = node->getName().c_str();
|
||||
break;
|
||||
|
||||
case EOpParameters:
|
||||
// Store the parameters to the function in the map
|
||||
sit->functionMap[sit->currentFunction.c_str()] = &(node->getSequence());
|
||||
break;
|
||||
|
||||
case EOpFunctionCall:
|
||||
{
|
||||
// This is a bit tricky. Find the function in the map. Loop over the parameters
|
||||
// and see if the parameters have been marked as a typed sampler. If so, propagate
|
||||
// the sampler type to the caller
|
||||
if ( sit->functionMap.find ( node->getName().c_str() ) != sit->functionMap.end() )
|
||||
{
|
||||
// Get the sequence of function parameters
|
||||
TIntermSequence *funcSequence = sit->functionMap[node->getName().c_str()];
|
||||
|
||||
// Get the sequence of parameters being passed to function
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
|
||||
// Grab iterators to both sequences
|
||||
TIntermSequence::iterator it = sequence.begin();
|
||||
TIntermSequence::iterator funcIt = funcSequence->begin();
|
||||
|
||||
assert ( sequence.size() == funcSequence->size() );
|
||||
if ( sequence.size() == funcSequence->size() )
|
||||
{
|
||||
while ( it != sequence.end() )
|
||||
{
|
||||
TIntermSymbol *sym = (*it)->getAsSymbolNode();
|
||||
TIntermSymbol *funcSym = (*funcIt)->getAsSymbolNode();
|
||||
|
||||
if ( sym != NULL && funcSym != NULL)
|
||||
{
|
||||
// If the parameter is generic, and the sampler to which
|
||||
// it is being passed has been marked, propogate its sampler
|
||||
// type to the caller.
|
||||
if ( sym->getBasicType() == EbtSamplerGeneric &&
|
||||
funcSym->getBasicType() != EbtSamplerGeneric )
|
||||
{
|
||||
sit->typeSampler ( sym, funcSym->getBasicType() );
|
||||
}
|
||||
}
|
||||
it++;
|
||||
funcIt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//HLSL texture functions
|
||||
case EOpTex1D:
|
||||
case EOpTex1DProj:
|
||||
case EOpTex1DLod:
|
||||
case EOpTex1DBias:
|
||||
case EOpTex1DGrad:
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
assert( sequence.size());
|
||||
TIntermTyped *sampArg = sequence[0]->getAsTyped();
|
||||
if ( sampArg)
|
||||
{
|
||||
if (sampArg->getBasicType() == EbtSamplerGeneric)
|
||||
{
|
||||
//type the sampler
|
||||
sit->typeSampler( sampArg, EbtSampler1D);
|
||||
}
|
||||
else if (sampArg->getBasicType() != EbtSampler1D)
|
||||
{
|
||||
//We have a sampler mismatch error
|
||||
infoSink.info << "Error: " << node->getLine() << ": Sampler type mismatch, likely using a generic sampler as two types\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
// We need to continue the traverse here, because the calls could be nested
|
||||
break;
|
||||
|
||||
|
||||
case EOpTex2D:
|
||||
case EOpTex2DProj:
|
||||
case EOpTex2DLod:
|
||||
case EOpTex2DBias:
|
||||
case EOpTex2DGrad:
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
assert( sequence.size());
|
||||
TIntermTyped *sampArg = sequence[0]->getAsTyped();
|
||||
if ( sampArg)
|
||||
{
|
||||
if (sampArg->getBasicType() == EbtSamplerGeneric)
|
||||
{
|
||||
//type the sampler
|
||||
sit->typeSampler( sampArg, EbtSampler2D);
|
||||
}
|
||||
else if (sampArg->getBasicType() != EbtSampler2D)
|
||||
{
|
||||
//We have a sampler mismatch error
|
||||
infoSink.info << "Error: " << node->getLine() << ": Sampler type mismatch, likely using a generic sampler as two types\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
// We need to continue the traverse here, because the calls could be nested
|
||||
break;
|
||||
|
||||
case EOpTex3D:
|
||||
case EOpTex3DProj:
|
||||
case EOpTex3DLod:
|
||||
case EOpTex3DBias:
|
||||
case EOpTex3DGrad:
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
assert( sequence.size());
|
||||
TIntermTyped *sampArg = sequence[0]->getAsTyped();
|
||||
if ( sampArg)
|
||||
{
|
||||
if (sampArg->getBasicType() == EbtSamplerGeneric)
|
||||
{
|
||||
//type the sampler
|
||||
sit->typeSampler( sampArg, EbtSampler3D);
|
||||
}
|
||||
else if (sampArg->getBasicType() != EbtSampler3D)
|
||||
{
|
||||
//We have a sampler mismatch error
|
||||
infoSink.info << "Error: " << node->getLine() << ": Sampler type mismatch, likely using a generic sampler as two types\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
// We need to continue the traverse here, because the calls could be nested
|
||||
break;
|
||||
|
||||
case EOpTexCube:
|
||||
case EOpTexCubeProj:
|
||||
case EOpTexCubeLod:
|
||||
case EOpTexCubeBias:
|
||||
case EOpTexCubeGrad:
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
assert( sequence.size());
|
||||
TIntermTyped *sampArg = sequence[0]->getAsTyped();
|
||||
if ( sampArg)
|
||||
{
|
||||
if (sampArg->getBasicType() == EbtSamplerGeneric)
|
||||
{
|
||||
//type the sampler
|
||||
sit->typeSampler( sampArg, EbtSamplerCube);
|
||||
}
|
||||
else if (sampArg->getBasicType() != EbtSamplerCube)
|
||||
{
|
||||
//We have a sampler mismatch error
|
||||
infoSink.info << "Error: " << node->getLine() << ": Sampler type mismatch, likely using a generic sampler as two types\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
// We need to continue the traverse here, because the calls could be nested
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse loop node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Loop node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseLoop( bool preVisit, TIntermLoop *node, TIntermTraverser *it)
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse branch node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Branch node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseBranch( bool preVisit, TIntermBranch *node, TIntermTraverser *it)
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the type for the sampler
|
||||
/// \param node
|
||||
/// Sampler node to set
|
||||
/// \param samp
|
||||
/// Sampler type to set node to
|
||||
//=========================================================================================================
|
||||
void TSamplerTraverser::typeSampler( TIntermTyped *node, TBasicType samp )
|
||||
{
|
||||
TIntermSymbol *symNode = node->getAsSymbolNode();
|
||||
|
||||
if ( !symNode)
|
||||
{
|
||||
//TODO: add logic to handle sampler arrays and samplers as struct members
|
||||
|
||||
//Don't try typing this one, it is a complex expression
|
||||
TIntermBinary *biNode = node->getAsBinaryNode();
|
||||
|
||||
if ( biNode )
|
||||
{
|
||||
switch (biNode->getOp())
|
||||
{
|
||||
case EOpIndexDirect:
|
||||
case EOpIndexIndirect:
|
||||
infoSink.info << "Warning: " << node->getLine() << ": typing of sampler arrays presently unsupported\n";
|
||||
break;
|
||||
|
||||
case EOpIndexDirectStruct:
|
||||
infoSink.info << "Warning: " << node->getLine() << ": typing of samplers as struct members presently unsupported\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
infoSink.info << "Warning: " << node->getLine() << ": unexpected expression type for sampler, cannot type\n";
|
||||
}
|
||||
abort = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We really have something to type, abort this traverse and activate typing
|
||||
abort = true;
|
||||
id = symNode->getId();
|
||||
sampType = samp;
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse the entire tree, typing all samplers that need to be typed
|
||||
/// \param node
|
||||
/// Root node of the tree
|
||||
/// \param info
|
||||
/// Infosink to hold log
|
||||
//=========================================================================================================
|
||||
void TSamplerTraverser::TypeSamplers( TIntermNode *node, TInfoSink &info )
|
||||
{
|
||||
TSamplerTraverser st(info);
|
||||
|
||||
do
|
||||
{
|
||||
st.abort = false;
|
||||
node->traverse( &st);
|
||||
|
||||
// If we aborted, try to type the node we aborted for
|
||||
if (st.abort)
|
||||
{
|
||||
st.typing = true;
|
||||
st.abort = false;
|
||||
node->traverse( &st);
|
||||
st.typing = false;
|
||||
st.abort = true;
|
||||
}
|
||||
} while (st.abort);
|
||||
|
||||
}
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of TSamplerTraverser
|
||||
//=================================================================================================================================
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// Includes / defines / typedefs / static member variable initialization block
|
||||
//
|
||||
//=================================================================================================================================
|
||||
#include "typeSamplers.h"
|
||||
|
||||
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse symbol node
|
||||
/// \param node
|
||||
/// Symbol node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
void TSamplerTraverser::traverseSymbol( TIntermSymbol *node, TIntermTraverser *it )
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
if (sit->abort)
|
||||
return;
|
||||
|
||||
if (sit->typing && sit->id == node->getId())
|
||||
{
|
||||
TType* type = node->getTypePointer();
|
||||
|
||||
// Technically most of these should never happen
|
||||
if ( type->isArray())
|
||||
type->setType( sit->sampType, type->getNominalSize(), type->isMatrix(), true, type->getArraySize());
|
||||
else
|
||||
type->setType( sit->sampType, type->getNominalSize(), type->isMatrix(), false);
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse binary node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Binary node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseBinary( bool preVisit, TIntermBinary *node, TIntermTraverser *it )
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
if (sit->abort)
|
||||
return false;
|
||||
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpAssign:
|
||||
//believed to be disallowed on samplers...
|
||||
break;
|
||||
|
||||
|
||||
case EOpIndexDirect:
|
||||
case EOpIndexIndirect:
|
||||
//not planning to support arrays of samplers with different types
|
||||
break;
|
||||
|
||||
case EOpIndexDirectStruct:
|
||||
//Structs in samplers not supported
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse unary node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Unary node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseUnary( bool preVisit, TIntermUnary *node, TIntermTraverser *it)
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse selection node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Selection node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseSelection( bool preVisit, TIntermSelection *node, TIntermTraverser *it)
|
||||
{
|
||||
//TODO: might need to run down this rat hole for ?: operator
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse aggregate node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Aggregate node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseAggregate( bool preVisit, TIntermAggregate *node, TIntermTraverser *it)
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
TInfoSink &infoSink = sit->infoSink;
|
||||
|
||||
if (sit->abort)
|
||||
return false;
|
||||
|
||||
if (! (sit->typing) )
|
||||
{
|
||||
switch (node->getOp())
|
||||
{
|
||||
|
||||
case EOpFunction:
|
||||
// Store the current function name to use to setup the parameters
|
||||
sit->currentFunction = node->getName().c_str();
|
||||
break;
|
||||
|
||||
case EOpParameters:
|
||||
// Store the parameters to the function in the map
|
||||
sit->functionMap[sit->currentFunction.c_str()] = &(node->getSequence());
|
||||
break;
|
||||
|
||||
case EOpFunctionCall:
|
||||
{
|
||||
// This is a bit tricky. Find the function in the map. Loop over the parameters
|
||||
// and see if the parameters have been marked as a typed sampler. If so, propagate
|
||||
// the sampler type to the caller
|
||||
if ( sit->functionMap.find ( node->getName().c_str() ) != sit->functionMap.end() )
|
||||
{
|
||||
// Get the sequence of function parameters
|
||||
TIntermSequence *funcSequence = sit->functionMap[node->getName().c_str()];
|
||||
|
||||
// Get the sequence of parameters being passed to function
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
|
||||
// Grab iterators to both sequences
|
||||
TIntermSequence::iterator it = sequence.begin();
|
||||
TIntermSequence::iterator funcIt = funcSequence->begin();
|
||||
|
||||
assert ( sequence.size() == funcSequence->size() );
|
||||
if ( sequence.size() == funcSequence->size() )
|
||||
{
|
||||
while ( it != sequence.end() )
|
||||
{
|
||||
TIntermSymbol *sym = (*it)->getAsSymbolNode();
|
||||
TIntermSymbol *funcSym = (*funcIt)->getAsSymbolNode();
|
||||
|
||||
if ( sym != NULL && funcSym != NULL)
|
||||
{
|
||||
// If the parameter is generic, and the sampler to which
|
||||
// it is being passed has been marked, propogate its sampler
|
||||
// type to the caller.
|
||||
if ( sym->getBasicType() == EbtSamplerGeneric &&
|
||||
funcSym->getBasicType() != EbtSamplerGeneric )
|
||||
{
|
||||
sit->typeSampler ( sym, funcSym->getBasicType() );
|
||||
}
|
||||
}
|
||||
it++;
|
||||
funcIt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//HLSL texture functions
|
||||
case EOpTex1D:
|
||||
case EOpTex1DProj:
|
||||
case EOpTex1DLod:
|
||||
case EOpTex1DBias:
|
||||
case EOpTex1DGrad:
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
assert( sequence.size());
|
||||
TIntermTyped *sampArg = sequence[0]->getAsTyped();
|
||||
if ( sampArg)
|
||||
{
|
||||
if (sampArg->getBasicType() == EbtSamplerGeneric)
|
||||
{
|
||||
//type the sampler
|
||||
sit->typeSampler( sampArg, EbtSampler1D);
|
||||
}
|
||||
else if (sampArg->getBasicType() != EbtSampler1D)
|
||||
{
|
||||
//We have a sampler mismatch error
|
||||
infoSink.info << "Error: " << node->getLine() << ": Sampler type mismatch, likely using a generic sampler as two types\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
// We need to continue the traverse here, because the calls could be nested
|
||||
break;
|
||||
|
||||
|
||||
case EOpTex2D:
|
||||
case EOpTex2DProj:
|
||||
case EOpTex2DLod:
|
||||
case EOpTex2DBias:
|
||||
case EOpTex2DGrad:
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
assert( sequence.size());
|
||||
TIntermTyped *sampArg = sequence[0]->getAsTyped();
|
||||
if ( sampArg)
|
||||
{
|
||||
if (sampArg->getBasicType() == EbtSamplerGeneric)
|
||||
{
|
||||
//type the sampler
|
||||
sit->typeSampler( sampArg, EbtSampler2D);
|
||||
}
|
||||
else if (sampArg->getBasicType() != EbtSampler2D)
|
||||
{
|
||||
//We have a sampler mismatch error
|
||||
infoSink.info << "Error: " << node->getLine() << ": Sampler type mismatch, likely using a generic sampler as two types\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
// We need to continue the traverse here, because the calls could be nested
|
||||
break;
|
||||
|
||||
case EOpTex3D:
|
||||
case EOpTex3DProj:
|
||||
case EOpTex3DLod:
|
||||
case EOpTex3DBias:
|
||||
case EOpTex3DGrad:
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
assert( sequence.size());
|
||||
TIntermTyped *sampArg = sequence[0]->getAsTyped();
|
||||
if ( sampArg)
|
||||
{
|
||||
if (sampArg->getBasicType() == EbtSamplerGeneric)
|
||||
{
|
||||
//type the sampler
|
||||
sit->typeSampler( sampArg, EbtSampler3D);
|
||||
}
|
||||
else if (sampArg->getBasicType() != EbtSampler3D)
|
||||
{
|
||||
//We have a sampler mismatch error
|
||||
infoSink.info << "Error: " << node->getLine() << ": Sampler type mismatch, likely using a generic sampler as two types\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
// We need to continue the traverse here, because the calls could be nested
|
||||
break;
|
||||
|
||||
case EOpTexCube:
|
||||
case EOpTexCubeProj:
|
||||
case EOpTexCubeLod:
|
||||
case EOpTexCubeBias:
|
||||
case EOpTexCubeGrad:
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
assert( sequence.size());
|
||||
TIntermTyped *sampArg = sequence[0]->getAsTyped();
|
||||
if ( sampArg)
|
||||
{
|
||||
if (sampArg->getBasicType() == EbtSamplerGeneric)
|
||||
{
|
||||
//type the sampler
|
||||
sit->typeSampler( sampArg, EbtSamplerCube);
|
||||
}
|
||||
else if (sampArg->getBasicType() != EbtSamplerCube)
|
||||
{
|
||||
//We have a sampler mismatch error
|
||||
infoSink.info << "Error: " << node->getLine() << ": Sampler type mismatch, likely using a generic sampler as two types\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
// We need to continue the traverse here, because the calls could be nested
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse loop node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Loop node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseLoop( bool preVisit, TIntermLoop *node, TIntermTraverser *it)
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse branch node
|
||||
/// \param preVisit
|
||||
/// Used only by base class, unused here.
|
||||
/// \param node
|
||||
/// Branch node to to traverse
|
||||
/// \param it
|
||||
/// Pointer to traverser
|
||||
//=========================================================================================================
|
||||
bool TSamplerTraverser::traverseBranch( bool preVisit, TIntermBranch *node, TIntermTraverser *it)
|
||||
{
|
||||
TSamplerTraverser* sit = static_cast<TSamplerTraverser*>(it);
|
||||
|
||||
return !(sit->abort);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the type for the sampler
|
||||
/// \param node
|
||||
/// Sampler node to set
|
||||
/// \param samp
|
||||
/// Sampler type to set node to
|
||||
//=========================================================================================================
|
||||
void TSamplerTraverser::typeSampler( TIntermTyped *node, TBasicType samp )
|
||||
{
|
||||
TIntermSymbol *symNode = node->getAsSymbolNode();
|
||||
|
||||
if ( !symNode)
|
||||
{
|
||||
//TODO: add logic to handle sampler arrays and samplers as struct members
|
||||
|
||||
//Don't try typing this one, it is a complex expression
|
||||
TIntermBinary *biNode = node->getAsBinaryNode();
|
||||
|
||||
if ( biNode )
|
||||
{
|
||||
switch (biNode->getOp())
|
||||
{
|
||||
case EOpIndexDirect:
|
||||
case EOpIndexIndirect:
|
||||
infoSink.info << "Warning: " << node->getLine() << ": typing of sampler arrays presently unsupported\n";
|
||||
break;
|
||||
|
||||
case EOpIndexDirectStruct:
|
||||
infoSink.info << "Warning: " << node->getLine() << ": typing of samplers as struct members presently unsupported\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
infoSink.info << "Warning: " << node->getLine() << ": unexpected expression type for sampler, cannot type\n";
|
||||
}
|
||||
abort = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We really have something to type, abort this traverse and activate typing
|
||||
abort = true;
|
||||
id = symNode->getId();
|
||||
sampType = samp;
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse the entire tree, typing all samplers that need to be typed
|
||||
/// \param node
|
||||
/// Root node of the tree
|
||||
/// \param info
|
||||
/// Infosink to hold log
|
||||
//=========================================================================================================
|
||||
void TSamplerTraverser::TypeSamplers( TIntermNode *node, TInfoSink &info )
|
||||
{
|
||||
TSamplerTraverser st(info);
|
||||
|
||||
do
|
||||
{
|
||||
st.abort = false;
|
||||
node->traverse( &st);
|
||||
|
||||
// If we aborted, try to type the node we aborted for
|
||||
if (st.abort)
|
||||
{
|
||||
st.typing = true;
|
||||
st.abort = false;
|
||||
node->traverse( &st);
|
||||
st.typing = false;
|
||||
st.abort = true;
|
||||
}
|
||||
} while (st.abort);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,144 +1,144 @@
|
|||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of TSamplerTraverser
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef TYPE_SAMPLERS_H
|
||||
#define TYPE_SAMPLERS_H
|
||||
|
||||
#include "localintermediate.h"
|
||||
|
||||
#include "glslOutput.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// TSamplerTraverser
|
||||
///
|
||||
/// \brief This class iterates over the intermediate tree and sets untyped sampler symbols to have types based on the
|
||||
/// type of texture operation the samplers are used for
|
||||
//=================================================================================================================================
|
||||
class TSamplerTraverser : public TIntermTraverser
|
||||
{
|
||||
private:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a symbol node
|
||||
//=========================================================================================================
|
||||
static void traverseSymbol(TIntermSymbol*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a parameter symbol node
|
||||
//=========================================================================================================
|
||||
static void traverseParameterSymbol(TIntermSymbol *node, TIntermTraverser *it);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a binary node
|
||||
//=========================================================================================================
|
||||
static bool traverseBinary(bool preVisit, TIntermBinary*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a unary node
|
||||
//=========================================================================================================
|
||||
static bool traverseUnary(bool preVisit, TIntermUnary*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a selection node
|
||||
//=========================================================================================================
|
||||
static bool traverseSelection(bool preVisit, TIntermSelection*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse an aggregate node
|
||||
//=========================================================================================================
|
||||
static bool traverseAggregate(bool preVisit, TIntermAggregate*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a loop node
|
||||
//=========================================================================================================
|
||||
static bool traverseLoop(bool preVisit, TIntermLoop*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a branch node
|
||||
//=========================================================================================================
|
||||
static bool traverseBranch(bool preVisit, TIntermBranch*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the type for the sampler
|
||||
//=========================================================================================================
|
||||
void typeSampler( TIntermTyped *node, TBasicType samp);
|
||||
|
||||
// Info sink log
|
||||
TInfoSink& infoSink;
|
||||
|
||||
// Whether to abort the sampler typing
|
||||
bool abort;
|
||||
|
||||
// These are used to go into "typing mode"
|
||||
bool typing;
|
||||
int id;
|
||||
TBasicType sampType;
|
||||
|
||||
// Map of functions
|
||||
std::map<std::string,TIntermSequence* > functionMap;
|
||||
|
||||
// Current function name
|
||||
std::string currentFunction;
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
TSamplerTraverser( TInfoSink &is) : infoSink(is), abort(false), typing(false), id(0), sampType(EbtSamplerGeneric)
|
||||
{
|
||||
visitSymbol = traverseSymbol;
|
||||
//visitConstantUnion = traverseConstantUnion;
|
||||
visitBinary = traverseBinary;
|
||||
visitUnary = traverseUnary;
|
||||
visitSelection = traverseSelection;
|
||||
visitAggregate = traverseAggregate;
|
||||
visitLoop = traverseLoop;
|
||||
visitBranch = traverseBranch;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse the entire tree, typing all samplers that need to be typed
|
||||
//=========================================================================================================
|
||||
static void TypeSamplers( TIntermNode *node, TInfoSink &info);
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//=================================================================================================================================
|
||||
//
|
||||
// ATI Research, Inc.
|
||||
//
|
||||
// Implementation of TSamplerTraverser
|
||||
//=================================================================================================================================
|
||||
|
||||
#ifndef TYPE_SAMPLERS_H
|
||||
#define TYPE_SAMPLERS_H
|
||||
|
||||
#include "localintermediate.h"
|
||||
|
||||
#include "glslOutput.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/// TSamplerTraverser
|
||||
///
|
||||
/// \brief This class iterates over the intermediate tree and sets untyped sampler symbols to have types based on the
|
||||
/// type of texture operation the samplers are used for
|
||||
//=================================================================================================================================
|
||||
class TSamplerTraverser : public TIntermTraverser
|
||||
{
|
||||
private:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a symbol node
|
||||
//=========================================================================================================
|
||||
static void traverseSymbol(TIntermSymbol*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a parameter symbol node
|
||||
//=========================================================================================================
|
||||
static void traverseParameterSymbol(TIntermSymbol *node, TIntermTraverser *it);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a binary node
|
||||
//=========================================================================================================
|
||||
static bool traverseBinary(bool preVisit, TIntermBinary*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a unary node
|
||||
//=========================================================================================================
|
||||
static bool traverseUnary(bool preVisit, TIntermUnary*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a selection node
|
||||
//=========================================================================================================
|
||||
static bool traverseSelection(bool preVisit, TIntermSelection*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse an aggregate node
|
||||
//=========================================================================================================
|
||||
static bool traverseAggregate(bool preVisit, TIntermAggregate*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a loop node
|
||||
//=========================================================================================================
|
||||
static bool traverseLoop(bool preVisit, TIntermLoop*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse a branch node
|
||||
//=========================================================================================================
|
||||
static bool traverseBranch(bool preVisit, TIntermBranch*, TIntermTraverser*);
|
||||
|
||||
//=========================================================================================================
|
||||
/// Set the type for the sampler
|
||||
//=========================================================================================================
|
||||
void typeSampler( TIntermTyped *node, TBasicType samp);
|
||||
|
||||
// Info sink log
|
||||
TInfoSink& infoSink;
|
||||
|
||||
// Whether to abort the sampler typing
|
||||
bool abort;
|
||||
|
||||
// These are used to go into "typing mode"
|
||||
bool typing;
|
||||
int id;
|
||||
TBasicType sampType;
|
||||
|
||||
// Map of functions
|
||||
std::map<std::string,TIntermSequence* > functionMap;
|
||||
|
||||
// Current function name
|
||||
std::string currentFunction;
|
||||
public:
|
||||
|
||||
//=========================================================================================================
|
||||
/// Constructor
|
||||
//=========================================================================================================
|
||||
TSamplerTraverser( TInfoSink &is) : infoSink(is), abort(false), typing(false), id(0), sampType(EbtSamplerGeneric)
|
||||
{
|
||||
visitSymbol = traverseSymbol;
|
||||
//visitConstantUnion = traverseConstantUnion;
|
||||
visitBinary = traverseBinary;
|
||||
visitUnary = traverseUnary;
|
||||
visitSelection = traverseSelection;
|
||||
visitAggregate = traverseAggregate;
|
||||
visitLoop = traverseLoop;
|
||||
visitBranch = traverseBranch;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
/// Traverse the entire tree, typing all samplers that need to be typed
|
||||
//=========================================================================================================
|
||||
static void TypeSamplers( TIntermNode *node, TInfoSink &info);
|
||||
|
||||
};
|
||||
|
||||
#endif //TYPE_SAMPLERS_H
|
|
@ -1,183 +1,183 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef _BASICTYPES_INCLUDED_
|
||||
#define _BASICTYPES_INCLUDED_
|
||||
|
||||
//
|
||||
// Basic type. Arrays, vectors, etc., are orthogonal to this.
|
||||
//
|
||||
enum TBasicType
|
||||
{
|
||||
EbtVoid,
|
||||
EbtFloat,
|
||||
EbtInt,
|
||||
EbtBool,
|
||||
EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
|
||||
EbtSamplerGeneric, // untyped D3D sampler, assumes type via usage
|
||||
EbtSampler1D,
|
||||
EbtSampler2D,
|
||||
EbtSampler3D,
|
||||
EbtSamplerCube,
|
||||
EbtSampler1DShadow,
|
||||
EbtSampler2DShadow,
|
||||
EbtSamplerRect, // ARB_texture_rectangle
|
||||
EbtSamplerRectShadow, // ARB_texture_rectangle
|
||||
EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
|
||||
EbtTexture, // HLSL Texture variable (presently just a dummy)
|
||||
EbtStruct,
|
||||
EbtAddress, // should be deprecated??
|
||||
};
|
||||
|
||||
__inline bool IsSampler(TBasicType type)
|
||||
{
|
||||
return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd;
|
||||
}
|
||||
|
||||
__inline bool IsNumeric(TBasicType type)
|
||||
{
|
||||
return type > EbtVoid && type < EbtGuardSamplerBegin;
|
||||
}
|
||||
|
||||
//
|
||||
// Qualifiers and built-ins. These are mainly used to see what can be read
|
||||
// or written, and by the machine dependent translator to know which registers
|
||||
// to allocate variables in. Since built-ins tend to go to different registers
|
||||
// than varying or uniform, it makes sense they are peers, not sub-classes.
|
||||
//
|
||||
enum TQualifier
|
||||
{
|
||||
EvqTemporary, // For temporaries (within a function), read/write
|
||||
EvqGlobal, // For globals read/write
|
||||
EvqConst, // User defined constants and non-output parameters in functions
|
||||
EvqAttribute, // Readonly
|
||||
EvqVaryingIn, // readonly, fragment shaders only
|
||||
EvqVaryingOut, // vertex shaders only read/write
|
||||
EvqUniform, // Readonly, vertex and fragment
|
||||
EvqMutableUniform, //HLSL uniform value, that is not really uniform
|
||||
|
||||
// pack/unpack input and output
|
||||
EvqInput,
|
||||
EvqOutput,
|
||||
|
||||
// parameters
|
||||
EvqIn,
|
||||
EvqOut,
|
||||
EvqInOut,
|
||||
EvqConstReadOnly,
|
||||
|
||||
// built-ins written by vertex shader
|
||||
EvqPosition,
|
||||
EvqPointSize,
|
||||
EvqClipVertex,
|
||||
|
||||
// built-ins read by fragment shader
|
||||
EvqFace,
|
||||
EvqFragCoord,
|
||||
|
||||
// built-ins written by fragment shader
|
||||
EvqFragColor,
|
||||
EvqFragDepth,
|
||||
|
||||
// end of list
|
||||
EvqLast,
|
||||
};
|
||||
|
||||
//
|
||||
// This is just for debug print out, carried along with the definitions above.
|
||||
//
|
||||
__inline const char* getQualifierString(TQualifier q)
|
||||
{
|
||||
switch (q)
|
||||
{
|
||||
case EvqTemporary: return "Temporary"; break;
|
||||
case EvqGlobal: return "Global"; break;
|
||||
case EvqConst: return "const"; break;
|
||||
case EvqConstReadOnly: return "const"; break;
|
||||
case EvqAttribute: return "attribute"; break;
|
||||
case EvqVaryingIn: return "varying"; break;
|
||||
case EvqVaryingOut: return "varying"; break;
|
||||
case EvqUniform: return "uniform"; break;
|
||||
case EvqIn: return "in"; break;
|
||||
case EvqOut: return "out"; break;
|
||||
case EvqInOut: return "inout"; break;
|
||||
case EvqInput: return "input"; break;
|
||||
case EvqOutput: return "output"; break;
|
||||
case EvqPosition: return "Position"; break;
|
||||
case EvqPointSize: return "PointSize"; break;
|
||||
case EvqClipVertex: return "ClipVertex"; break;
|
||||
case EvqFace: return "Face"; break;
|
||||
case EvqFragCoord: return "FragCoord"; break;
|
||||
case EvqFragColor: return "FragColor"; break;
|
||||
case EvqFragDepth: return "FragDepth"; break;
|
||||
default: return "unknown qualifier";
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _BASICTYPES_INCLUDED_
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef _BASICTYPES_INCLUDED_
|
||||
#define _BASICTYPES_INCLUDED_
|
||||
|
||||
//
|
||||
// Basic type. Arrays, vectors, etc., are orthogonal to this.
|
||||
//
|
||||
enum TBasicType
|
||||
{
|
||||
EbtVoid,
|
||||
EbtFloat,
|
||||
EbtInt,
|
||||
EbtBool,
|
||||
EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
|
||||
EbtSamplerGeneric, // untyped D3D sampler, assumes type via usage
|
||||
EbtSampler1D,
|
||||
EbtSampler2D,
|
||||
EbtSampler3D,
|
||||
EbtSamplerCube,
|
||||
EbtSampler1DShadow,
|
||||
EbtSampler2DShadow,
|
||||
EbtSamplerRect, // ARB_texture_rectangle
|
||||
EbtSamplerRectShadow, // ARB_texture_rectangle
|
||||
EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
|
||||
EbtTexture, // HLSL Texture variable (presently just a dummy)
|
||||
EbtStruct,
|
||||
EbtAddress, // should be deprecated??
|
||||
};
|
||||
|
||||
__inline bool IsSampler(TBasicType type)
|
||||
{
|
||||
return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd;
|
||||
}
|
||||
|
||||
__inline bool IsNumeric(TBasicType type)
|
||||
{
|
||||
return type > EbtVoid && type < EbtGuardSamplerBegin;
|
||||
}
|
||||
|
||||
//
|
||||
// Qualifiers and built-ins. These are mainly used to see what can be read
|
||||
// or written, and by the machine dependent translator to know which registers
|
||||
// to allocate variables in. Since built-ins tend to go to different registers
|
||||
// than varying or uniform, it makes sense they are peers, not sub-classes.
|
||||
//
|
||||
enum TQualifier
|
||||
{
|
||||
EvqTemporary, // For temporaries (within a function), read/write
|
||||
EvqGlobal, // For globals read/write
|
||||
EvqConst, // User defined constants and non-output parameters in functions
|
||||
EvqAttribute, // Readonly
|
||||
EvqVaryingIn, // readonly, fragment shaders only
|
||||
EvqVaryingOut, // vertex shaders only read/write
|
||||
EvqUniform, // Readonly, vertex and fragment
|
||||
EvqMutableUniform, //HLSL uniform value, that is not really uniform
|
||||
|
||||
// pack/unpack input and output
|
||||
EvqInput,
|
||||
EvqOutput,
|
||||
|
||||
// parameters
|
||||
EvqIn,
|
||||
EvqOut,
|
||||
EvqInOut,
|
||||
EvqConstReadOnly,
|
||||
|
||||
// built-ins written by vertex shader
|
||||
EvqPosition,
|
||||
EvqPointSize,
|
||||
EvqClipVertex,
|
||||
|
||||
// built-ins read by fragment shader
|
||||
EvqFace,
|
||||
EvqFragCoord,
|
||||
|
||||
// built-ins written by fragment shader
|
||||
EvqFragColor,
|
||||
EvqFragDepth,
|
||||
|
||||
// end of list
|
||||
EvqLast,
|
||||
};
|
||||
|
||||
//
|
||||
// This is just for debug print out, carried along with the definitions above.
|
||||
//
|
||||
__inline const char* getQualifierString(TQualifier q)
|
||||
{
|
||||
switch (q)
|
||||
{
|
||||
case EvqTemporary: return "Temporary"; break;
|
||||
case EvqGlobal: return "Global"; break;
|
||||
case EvqConst: return "const"; break;
|
||||
case EvqConstReadOnly: return "const"; break;
|
||||
case EvqAttribute: return "attribute"; break;
|
||||
case EvqVaryingIn: return "varying"; break;
|
||||
case EvqVaryingOut: return "varying"; break;
|
||||
case EvqUniform: return "uniform"; break;
|
||||
case EvqIn: return "in"; break;
|
||||
case EvqOut: return "out"; break;
|
||||
case EvqInOut: return "inout"; break;
|
||||
case EvqInput: return "input"; break;
|
||||
case EvqOutput: return "output"; break;
|
||||
case EvqPosition: return "Position"; break;
|
||||
case EvqPointSize: return "PointSize"; break;
|
||||
case EvqClipVertex: return "ClipVertex"; break;
|
||||
case EvqFace: return "Face"; break;
|
||||
case EvqFragCoord: return "FragCoord"; break;
|
||||
case EvqFragColor: return "FragColor"; break;
|
||||
case EvqFragDepth: return "FragDepth"; break;
|
||||
default: return "unknown qualifier";
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _BASICTYPES_INCLUDED_
|
||||
|
||||
|
|
|
@ -1,253 +1,253 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _COMMON_INCLUDED_
|
||||
#define _COMMON_INCLUDED_
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <basetsd.h>
|
||||
#elif defined (solaris)
|
||||
#include <sys/int_types.h>
|
||||
#define UINT_PTR uintptr_t
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#define UINT_PTR uintptr_t
|
||||
#endif
|
||||
|
||||
/* windows only pragma */
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4786) // Don't warn about too long identifiers
|
||||
#pragma warning(disable : 4514) // unused inline method
|
||||
#pragma warning(disable : 4201) // nameless union
|
||||
#endif
|
||||
|
||||
//
|
||||
// Doing the push and pop below for warnings does not leave the warning state
|
||||
// the way it was. This seems like a defect in the compiler. We would like
|
||||
// to do this, but since it does not work correctly right now, it is turned
|
||||
// off.
|
||||
//
|
||||
//??#pragma warning(push, 3)
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
||||
//??#pragma warning(pop)
|
||||
|
||||
typedef int TSourceLoc;
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "PoolAlloc.h"
|
||||
|
||||
//
|
||||
// Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.
|
||||
//
|
||||
#define POOL_ALLOCATOR_NEW_DELETE(A) \
|
||||
void* operator new(size_t s) { return (A).allocate(s); } \
|
||||
void* operator new(size_t, void *_Where) { return (_Where); } \
|
||||
void operator delete(void*) { } \
|
||||
void operator delete(void *, void *) { } \
|
||||
void* operator new[](size_t s) { return (A).allocate(s); } \
|
||||
void* operator new[](size_t, void *_Where) { return (_Where); } \
|
||||
void operator delete[](void*) { } \
|
||||
void operator delete[](void *, void *) { }
|
||||
|
||||
#define TBaseMap std::map
|
||||
#define TBaseList std::list
|
||||
#define TBaseSet std::set
|
||||
|
||||
//
|
||||
// Pool version of string.
|
||||
//
|
||||
typedef pool_allocator<char> TStringAllocator;
|
||||
typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString;
|
||||
inline TString* NewPoolTString(const char* s)
|
||||
{
|
||||
void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
|
||||
return new(memory) TString(s);
|
||||
}
|
||||
|
||||
//
|
||||
// Pool allocator versions of vectors, lists, and maps
|
||||
//
|
||||
template <class T> class TVector : public std::vector<T, pool_allocator<T> >
|
||||
{
|
||||
public:
|
||||
typedef typename std::vector<T, pool_allocator<T> >::size_type size_type;
|
||||
TVector() : std::vector<T, pool_allocator<T> >()
|
||||
{
|
||||
}
|
||||
TVector(const pool_allocator<T>& a) : std::vector<T, pool_allocator<T> >(a)
|
||||
{
|
||||
}
|
||||
TVector(size_type i): std::vector<T, pool_allocator<T> >(i)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> class TList : public TBaseList <T, pool_allocator<T> >
|
||||
{
|
||||
public:
|
||||
typedef typename TBaseList<T, pool_allocator<T> >::size_type size_type;
|
||||
TList() : TBaseList<T, pool_allocator<T> >()
|
||||
{
|
||||
}
|
||||
TList(const pool_allocator<T>& a) : TBaseList<T, pool_allocator<T> >(a)
|
||||
{
|
||||
}
|
||||
TList(size_type i): TBaseList<T, pool_allocator<T> >(i)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// This is called TStlSet, because TSet is taken by an existing compiler class.
|
||||
template <class T, class CMP> class TStlSet : public std::set<T, CMP, pool_allocator<T> >
|
||||
{
|
||||
// No pool allocator versions of constructors in std::set.
|
||||
};
|
||||
|
||||
|
||||
template <class K, class D, class CMP = std::less<K> >
|
||||
class TMap : public TBaseMap<K, D, CMP, pool_allocator<std::pair<K, D> > >
|
||||
{
|
||||
public:
|
||||
typedef pool_allocator<std::pair <K, D> > tAllocator;
|
||||
|
||||
TMap() : TBaseMap<K, D, CMP, tAllocator >()
|
||||
{
|
||||
}
|
||||
// use correct two-stage name lookup supported in gcc 3.4 and above
|
||||
TMap(const tAllocator& a) : TBaseMap<K, D, CMP, tAllocator>(TBaseMap<K, D, CMP, tAllocator >::key_compare(), a)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Persistent string memory. Should only be used for strings that survive
|
||||
// across compiles/links.
|
||||
//
|
||||
typedef std::basic_string<char> TPersistString;
|
||||
|
||||
//
|
||||
// templatized min and max functions.
|
||||
//
|
||||
template <class T> T Min(const T a, const T b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
template <class T> T Max(const T a, const T b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
//
|
||||
// Create a TString object from an integer.
|
||||
//
|
||||
inline const TString String(const int i, const int base = 10)
|
||||
{
|
||||
char text[16]; // 32 bit ints are at most 10 digits in base 10
|
||||
|
||||
// we assume base 10 for all cases
|
||||
sprintf(text, "%d", i);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
const unsigned int SourceLocLineMask = 0xffff;
|
||||
const unsigned int SourceLocStringShift = 16;
|
||||
|
||||
__inline TPersistString FormatSourceLoc(const TSourceLoc loc)
|
||||
{
|
||||
char locText[64];
|
||||
|
||||
int string = loc >> SourceLocStringShift;
|
||||
int line = loc & SourceLocLineMask;
|
||||
|
||||
if (line)
|
||||
sprintf(locText, "%d:%d", string, line);
|
||||
else
|
||||
sprintf(locText, "%d:? ", string);
|
||||
|
||||
return TPersistString(locText);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef TMap<TString, TString> TPragmaTable;
|
||||
#else
|
||||
typedef TMap<const TString, TString> TPragmaTable;
|
||||
#endif
|
||||
typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
|
||||
|
||||
#endif // _COMMON_INCLUDED_
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _COMMON_INCLUDED_
|
||||
#define _COMMON_INCLUDED_
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <basetsd.h>
|
||||
#elif defined (solaris)
|
||||
#include <sys/int_types.h>
|
||||
#define UINT_PTR uintptr_t
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#define UINT_PTR uintptr_t
|
||||
#endif
|
||||
|
||||
/* windows only pragma */
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4786) // Don't warn about too long identifiers
|
||||
#pragma warning(disable : 4514) // unused inline method
|
||||
#pragma warning(disable : 4201) // nameless union
|
||||
#endif
|
||||
|
||||
//
|
||||
// Doing the push and pop below for warnings does not leave the warning state
|
||||
// the way it was. This seems like a defect in the compiler. We would like
|
||||
// to do this, but since it does not work correctly right now, it is turned
|
||||
// off.
|
||||
//
|
||||
//??#pragma warning(push, 3)
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
||||
//??#pragma warning(pop)
|
||||
|
||||
typedef int TSourceLoc;
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "PoolAlloc.h"
|
||||
|
||||
//
|
||||
// Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.
|
||||
//
|
||||
#define POOL_ALLOCATOR_NEW_DELETE(A) \
|
||||
void* operator new(size_t s) { return (A).allocate(s); } \
|
||||
void* operator new(size_t, void *_Where) { return (_Where); } \
|
||||
void operator delete(void*) { } \
|
||||
void operator delete(void *, void *) { } \
|
||||
void* operator new[](size_t s) { return (A).allocate(s); } \
|
||||
void* operator new[](size_t, void *_Where) { return (_Where); } \
|
||||
void operator delete[](void*) { } \
|
||||
void operator delete[](void *, void *) { }
|
||||
|
||||
#define TBaseMap std::map
|
||||
#define TBaseList std::list
|
||||
#define TBaseSet std::set
|
||||
|
||||
//
|
||||
// Pool version of string.
|
||||
//
|
||||
typedef pool_allocator<char> TStringAllocator;
|
||||
typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString;
|
||||
inline TString* NewPoolTString(const char* s)
|
||||
{
|
||||
void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
|
||||
return new(memory) TString(s);
|
||||
}
|
||||
|
||||
//
|
||||
// Pool allocator versions of vectors, lists, and maps
|
||||
//
|
||||
template <class T> class TVector : public std::vector<T, pool_allocator<T> >
|
||||
{
|
||||
public:
|
||||
typedef typename std::vector<T, pool_allocator<T> >::size_type size_type;
|
||||
TVector() : std::vector<T, pool_allocator<T> >()
|
||||
{
|
||||
}
|
||||
TVector(const pool_allocator<T>& a) : std::vector<T, pool_allocator<T> >(a)
|
||||
{
|
||||
}
|
||||
TVector(size_type i): std::vector<T, pool_allocator<T> >(i)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> class TList : public TBaseList <T, pool_allocator<T> >
|
||||
{
|
||||
public:
|
||||
typedef typename TBaseList<T, pool_allocator<T> >::size_type size_type;
|
||||
TList() : TBaseList<T, pool_allocator<T> >()
|
||||
{
|
||||
}
|
||||
TList(const pool_allocator<T>& a) : TBaseList<T, pool_allocator<T> >(a)
|
||||
{
|
||||
}
|
||||
TList(size_type i): TBaseList<T, pool_allocator<T> >(i)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// This is called TStlSet, because TSet is taken by an existing compiler class.
|
||||
template <class T, class CMP> class TStlSet : public std::set<T, CMP, pool_allocator<T> >
|
||||
{
|
||||
// No pool allocator versions of constructors in std::set.
|
||||
};
|
||||
|
||||
|
||||
template <class K, class D, class CMP = std::less<K> >
|
||||
class TMap : public TBaseMap<K, D, CMP, pool_allocator<std::pair<K, D> > >
|
||||
{
|
||||
public:
|
||||
typedef pool_allocator<std::pair <K, D> > tAllocator;
|
||||
|
||||
TMap() : TBaseMap<K, D, CMP, tAllocator >()
|
||||
{
|
||||
}
|
||||
// use correct two-stage name lookup supported in gcc 3.4 and above
|
||||
TMap(const tAllocator& a) : TBaseMap<K, D, CMP, tAllocator>(TBaseMap<K, D, CMP, tAllocator >::key_compare(), a)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Persistent string memory. Should only be used for strings that survive
|
||||
// across compiles/links.
|
||||
//
|
||||
typedef std::basic_string<char> TPersistString;
|
||||
|
||||
//
|
||||
// templatized min and max functions.
|
||||
//
|
||||
template <class T> T Min(const T a, const T b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
template <class T> T Max(const T a, const T b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
//
|
||||
// Create a TString object from an integer.
|
||||
//
|
||||
inline const TString String(const int i, const int base = 10)
|
||||
{
|
||||
char text[16]; // 32 bit ints are at most 10 digits in base 10
|
||||
|
||||
// we assume base 10 for all cases
|
||||
sprintf(text, "%d", i);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
const unsigned int SourceLocLineMask = 0xffff;
|
||||
const unsigned int SourceLocStringShift = 16;
|
||||
|
||||
__inline TPersistString FormatSourceLoc(const TSourceLoc loc)
|
||||
{
|
||||
char locText[64];
|
||||
|
||||
int string = loc >> SourceLocStringShift;
|
||||
int line = loc & SourceLocLineMask;
|
||||
|
||||
if (line)
|
||||
sprintf(locText, "%d:%d", string, line);
|
||||
else
|
||||
sprintf(locText, "%d:? ", string);
|
||||
|
||||
return TPersistString(locText);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef TMap<TString, TString> TPragmaTable;
|
||||
#else
|
||||
typedef TMap<const TString, TString> TPragmaTable;
|
||||
#endif
|
||||
typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
|
||||
|
||||
#endif // _COMMON_INCLUDED_
|
||||
|
||||
|
|
|
@ -1,397 +1,397 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _CONSTANT_UNION_INCLUDED_
|
||||
#define _CONSTANT_UNION_INCLUDED_
|
||||
|
||||
|
||||
class constUnion
|
||||
{
|
||||
public:
|
||||
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
void setIConst(int i)
|
||||
{
|
||||
iConst = i; type = EbtInt;
|
||||
}
|
||||
void setFConst(float f)
|
||||
{
|
||||
fConst = f; type = EbtFloat;
|
||||
}
|
||||
void setBConst(bool b)
|
||||
{
|
||||
bConst = b; type = EbtBool;
|
||||
}
|
||||
|
||||
int getIConst()
|
||||
{
|
||||
return iConst;
|
||||
}
|
||||
float getFConst()
|
||||
{
|
||||
return fConst;
|
||||
}
|
||||
bool getBConst()
|
||||
{
|
||||
return bConst;
|
||||
}
|
||||
int getIConst() const
|
||||
{
|
||||
return iConst;
|
||||
}
|
||||
float getFConst() const
|
||||
{
|
||||
return fConst;
|
||||
}
|
||||
bool getBConst() const
|
||||
{
|
||||
return bConst;
|
||||
}
|
||||
|
||||
bool operator==(const int i) const
|
||||
{
|
||||
if (i == iConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const float f) const
|
||||
{
|
||||
if (f == fConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const bool b) const
|
||||
{
|
||||
if (b == bConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const constUnion& constant) const
|
||||
{
|
||||
if (constant.type != type)
|
||||
return false;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt:
|
||||
if (constant.iConst == iConst)
|
||||
return true;
|
||||
|
||||
break;
|
||||
case EbtFloat:
|
||||
if (constant.fConst == fConst)
|
||||
return true;
|
||||
|
||||
break;
|
||||
case EbtBool:
|
||||
if (constant.bConst == bConst)
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator!=(const int i) const
|
||||
{
|
||||
return !operator==(i);
|
||||
}
|
||||
|
||||
bool operator!=(const float f) const
|
||||
{
|
||||
return !operator==(f);
|
||||
}
|
||||
|
||||
bool operator!=(const bool b) const
|
||||
{
|
||||
return !operator==(b);
|
||||
}
|
||||
|
||||
bool operator!=(const constUnion& constant) const
|
||||
{
|
||||
return !operator==(constant);
|
||||
}
|
||||
|
||||
bool operator>(const constUnion& constant) const
|
||||
{
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt:
|
||||
if (iConst > constant.iConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
case EbtFloat:
|
||||
if (fConst > constant.fConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
default:
|
||||
assert(false && "Default missing");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator<(const constUnion& constant) const
|
||||
{
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt:
|
||||
if (iConst < constant.iConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
case EbtFloat:
|
||||
if (fConst < constant.fConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
default:
|
||||
assert(false && "Default missing");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
constUnion operator+(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
|
||||
case EbtFloat: returnValue.setFConst(fConst + constant.fConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator-(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
|
||||
case EbtFloat: returnValue.setFConst(fConst - constant.fConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator*(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
|
||||
case EbtFloat: returnValue.setFConst(fConst * constant.fConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator%(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator>>(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator<<(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst << constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator&(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator|(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator^(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator&&(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator||(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
TBasicType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
private:
|
||||
|
||||
union
|
||||
{
|
||||
int iConst; // used for ivec, scalar ints
|
||||
bool bConst; // used for bvec, scalar bools
|
||||
float fConst; // used for vec, mat, scalar floats
|
||||
} ;
|
||||
|
||||
TBasicType type;
|
||||
};
|
||||
|
||||
#endif // _CONSTANT_UNION_INCLUDED_
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _CONSTANT_UNION_INCLUDED_
|
||||
#define _CONSTANT_UNION_INCLUDED_
|
||||
|
||||
|
||||
class constUnion
|
||||
{
|
||||
public:
|
||||
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
void setIConst(int i)
|
||||
{
|
||||
iConst = i; type = EbtInt;
|
||||
}
|
||||
void setFConst(float f)
|
||||
{
|
||||
fConst = f; type = EbtFloat;
|
||||
}
|
||||
void setBConst(bool b)
|
||||
{
|
||||
bConst = b; type = EbtBool;
|
||||
}
|
||||
|
||||
int getIConst()
|
||||
{
|
||||
return iConst;
|
||||
}
|
||||
float getFConst()
|
||||
{
|
||||
return fConst;
|
||||
}
|
||||
bool getBConst()
|
||||
{
|
||||
return bConst;
|
||||
}
|
||||
int getIConst() const
|
||||
{
|
||||
return iConst;
|
||||
}
|
||||
float getFConst() const
|
||||
{
|
||||
return fConst;
|
||||
}
|
||||
bool getBConst() const
|
||||
{
|
||||
return bConst;
|
||||
}
|
||||
|
||||
bool operator==(const int i) const
|
||||
{
|
||||
if (i == iConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const float f) const
|
||||
{
|
||||
if (f == fConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const bool b) const
|
||||
{
|
||||
if (b == bConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const constUnion& constant) const
|
||||
{
|
||||
if (constant.type != type)
|
||||
return false;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt:
|
||||
if (constant.iConst == iConst)
|
||||
return true;
|
||||
|
||||
break;
|
||||
case EbtFloat:
|
||||
if (constant.fConst == fConst)
|
||||
return true;
|
||||
|
||||
break;
|
||||
case EbtBool:
|
||||
if (constant.bConst == bConst)
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator!=(const int i) const
|
||||
{
|
||||
return !operator==(i);
|
||||
}
|
||||
|
||||
bool operator!=(const float f) const
|
||||
{
|
||||
return !operator==(f);
|
||||
}
|
||||
|
||||
bool operator!=(const bool b) const
|
||||
{
|
||||
return !operator==(b);
|
||||
}
|
||||
|
||||
bool operator!=(const constUnion& constant) const
|
||||
{
|
||||
return !operator==(constant);
|
||||
}
|
||||
|
||||
bool operator>(const constUnion& constant) const
|
||||
{
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt:
|
||||
if (iConst > constant.iConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
case EbtFloat:
|
||||
if (fConst > constant.fConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
default:
|
||||
assert(false && "Default missing");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator<(const constUnion& constant) const
|
||||
{
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt:
|
||||
if (iConst < constant.iConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
case EbtFloat:
|
||||
if (fConst < constant.fConst)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
default:
|
||||
assert(false && "Default missing");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
constUnion operator+(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
|
||||
case EbtFloat: returnValue.setFConst(fConst + constant.fConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator-(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
|
||||
case EbtFloat: returnValue.setFConst(fConst - constant.fConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator*(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
|
||||
case EbtFloat: returnValue.setFConst(fConst * constant.fConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator%(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator>>(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator<<(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst << constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator&(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator|(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator^(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator&&(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
constUnion operator||(const constUnion& constant) const
|
||||
{
|
||||
constUnion returnValue;
|
||||
assert(type == constant.type);
|
||||
switch (type)
|
||||
{
|
||||
case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
TBasicType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
private:
|
||||
|
||||
union
|
||||
{
|
||||
int iConst; // used for ivec, scalar ints
|
||||
bool bConst; // used for bvec, scalar bools
|
||||
float fConst; // used for vec, mat, scalar floats
|
||||
} ;
|
||||
|
||||
TBasicType type;
|
||||
};
|
||||
|
||||
#endif // _CONSTANT_UNION_INCLUDED_
|
||||
|
||||
|
|
|
@ -1,223 +1,223 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _INFOSINK_INCLUDED_
|
||||
#define _INFOSINK_INCLUDED_
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include <math.h>
|
||||
|
||||
//
|
||||
// TPrefixType is used to centralize how info log messages start.
|
||||
// See below.
|
||||
//
|
||||
enum TPrefixType
|
||||
{
|
||||
EPrefixNone,
|
||||
EPrefixWarning,
|
||||
EPrefixError,
|
||||
EPrefixInternalError,
|
||||
EPrefixUnimplemented,
|
||||
EPrefixNote
|
||||
};
|
||||
|
||||
enum TOutputStream
|
||||
{
|
||||
ENull = 0,
|
||||
EDebugger = 0x01,
|
||||
EStdOut = 0x02,
|
||||
EString = 0x04,
|
||||
};
|
||||
//
|
||||
// Encapsulate info logs for all objects that have them.
|
||||
//
|
||||
// The methods are a general set of tools for getting a variety of
|
||||
// messages and types inserted into the log.
|
||||
//
|
||||
class TInfoSinkBase
|
||||
{
|
||||
public:
|
||||
TInfoSinkBase() : outputStream(4)
|
||||
{
|
||||
}
|
||||
void erase()
|
||||
{
|
||||
sink.erase();
|
||||
}
|
||||
TInfoSinkBase& operator<<(const TPersistString& t)
|
||||
{
|
||||
append(t); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(char c)
|
||||
{
|
||||
append(1, c); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(const char* s)
|
||||
{
|
||||
append(s); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(int n)
|
||||
{
|
||||
append(String(n)); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(const unsigned int n)
|
||||
{
|
||||
append(String(n)); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(float n)
|
||||
{
|
||||
char buf[40];
|
||||
sprintf(buf, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ?
|
||||
"%f" : "%g", n);
|
||||
append(buf);
|
||||
return *this;
|
||||
}
|
||||
TInfoSinkBase& operator+(const TPersistString& t)
|
||||
{
|
||||
append(t); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator+(const TString& t)
|
||||
{
|
||||
append(t); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(const TString& t)
|
||||
{
|
||||
append(t); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator+(const char* s)
|
||||
{
|
||||
append(s); return *this;
|
||||
}
|
||||
const char* c_str() const
|
||||
{
|
||||
return sink.c_str();
|
||||
}
|
||||
void prefix(TPrefixType message)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case EPrefixNone: break;
|
||||
case EPrefixWarning: append("WARNING: "); break;
|
||||
case EPrefixError: append("ERROR: "); break;
|
||||
case EPrefixInternalError: append("INTERNAL ERROR: "); break;
|
||||
case EPrefixUnimplemented: append("UNIMPLEMENTED: "); break;
|
||||
case EPrefixNote: append("NOTE: "); break;
|
||||
default: append("UNKOWN ERROR: "); break;
|
||||
}
|
||||
}
|
||||
void location(TSourceLoc loc)
|
||||
{
|
||||
append(FormatSourceLoc(loc).c_str());
|
||||
append(": ");
|
||||
}
|
||||
void message(TPrefixType message, const char* s)
|
||||
{
|
||||
prefix(message);
|
||||
append(s);
|
||||
append("\n");
|
||||
}
|
||||
void message(TPrefixType message, const char* s, TSourceLoc loc)
|
||||
{
|
||||
prefix(message);
|
||||
location(loc);
|
||||
append(s);
|
||||
append("\n");
|
||||
}
|
||||
|
||||
void setOutputStream(int output = 4)
|
||||
{
|
||||
outputStream = output;
|
||||
}
|
||||
|
||||
protected:
|
||||
void append(const char *s);
|
||||
|
||||
void append(int count, char c);
|
||||
void append(const TPersistString& t);
|
||||
void append(const TString& t);
|
||||
|
||||
void checkMem(size_t growth)
|
||||
{
|
||||
if (sink.capacity() < sink.size() + growth + 2)
|
||||
sink.reserve(sink.capacity() + sink.capacity() / 2);
|
||||
}
|
||||
void appendToStream(const char* s);
|
||||
TPersistString sink;
|
||||
int outputStream;
|
||||
};
|
||||
|
||||
class TInfoSink
|
||||
{
|
||||
public:
|
||||
TInfoSinkBase info;
|
||||
TInfoSinkBase debug;
|
||||
};
|
||||
|
||||
#endif // _INFOSINK_INCLUDED_
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _INFOSINK_INCLUDED_
|
||||
#define _INFOSINK_INCLUDED_
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include <math.h>
|
||||
|
||||
//
|
||||
// TPrefixType is used to centralize how info log messages start.
|
||||
// See below.
|
||||
//
|
||||
enum TPrefixType
|
||||
{
|
||||
EPrefixNone,
|
||||
EPrefixWarning,
|
||||
EPrefixError,
|
||||
EPrefixInternalError,
|
||||
EPrefixUnimplemented,
|
||||
EPrefixNote
|
||||
};
|
||||
|
||||
enum TOutputStream
|
||||
{
|
||||
ENull = 0,
|
||||
EDebugger = 0x01,
|
||||
EStdOut = 0x02,
|
||||
EString = 0x04,
|
||||
};
|
||||
//
|
||||
// Encapsulate info logs for all objects that have them.
|
||||
//
|
||||
// The methods are a general set of tools for getting a variety of
|
||||
// messages and types inserted into the log.
|
||||
//
|
||||
class TInfoSinkBase
|
||||
{
|
||||
public:
|
||||
TInfoSinkBase() : outputStream(4)
|
||||
{
|
||||
}
|
||||
void erase()
|
||||
{
|
||||
sink.erase();
|
||||
}
|
||||
TInfoSinkBase& operator<<(const TPersistString& t)
|
||||
{
|
||||
append(t); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(char c)
|
||||
{
|
||||
append(1, c); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(const char* s)
|
||||
{
|
||||
append(s); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(int n)
|
||||
{
|
||||
append(String(n)); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(const unsigned int n)
|
||||
{
|
||||
append(String(n)); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(float n)
|
||||
{
|
||||
char buf[40];
|
||||
sprintf(buf, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ?
|
||||
"%f" : "%g", n);
|
||||
append(buf);
|
||||
return *this;
|
||||
}
|
||||
TInfoSinkBase& operator+(const TPersistString& t)
|
||||
{
|
||||
append(t); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator+(const TString& t)
|
||||
{
|
||||
append(t); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator<<(const TString& t)
|
||||
{
|
||||
append(t); return *this;
|
||||
}
|
||||
TInfoSinkBase& operator+(const char* s)
|
||||
{
|
||||
append(s); return *this;
|
||||
}
|
||||
const char* c_str() const
|
||||
{
|
||||
return sink.c_str();
|
||||
}
|
||||
void prefix(TPrefixType message)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case EPrefixNone: break;
|
||||
case EPrefixWarning: append("WARNING: "); break;
|
||||
case EPrefixError: append("ERROR: "); break;
|
||||
case EPrefixInternalError: append("INTERNAL ERROR: "); break;
|
||||
case EPrefixUnimplemented: append("UNIMPLEMENTED: "); break;
|
||||
case EPrefixNote: append("NOTE: "); break;
|
||||
default: append("UNKOWN ERROR: "); break;
|
||||
}
|
||||
}
|
||||
void location(TSourceLoc loc)
|
||||
{
|
||||
append(FormatSourceLoc(loc).c_str());
|
||||
append(": ");
|
||||
}
|
||||
void message(TPrefixType message, const char* s)
|
||||
{
|
||||
prefix(message);
|
||||
append(s);
|
||||
append("\n");
|
||||
}
|
||||
void message(TPrefixType message, const char* s, TSourceLoc loc)
|
||||
{
|
||||
prefix(message);
|
||||
location(loc);
|
||||
append(s);
|
||||
append("\n");
|
||||
}
|
||||
|
||||
void setOutputStream(int output = 4)
|
||||
{
|
||||
outputStream = output;
|
||||
}
|
||||
|
||||
protected:
|
||||
void append(const char *s);
|
||||
|
||||
void append(int count, char c);
|
||||
void append(const TPersistString& t);
|
||||
void append(const TString& t);
|
||||
|
||||
void checkMem(size_t growth)
|
||||
{
|
||||
if (sink.capacity() < sink.size() + growth + 2)
|
||||
sink.reserve(sink.capacity() + sink.capacity() / 2);
|
||||
}
|
||||
void appendToStream(const char* s);
|
||||
TPersistString sink;
|
||||
int outputStream;
|
||||
};
|
||||
|
||||
class TInfoSink
|
||||
{
|
||||
public:
|
||||
TInfoSinkBase info;
|
||||
TInfoSinkBase debug;
|
||||
};
|
||||
|
||||
#endif // _INFOSINK_INCLUDED_
|
||||
|
||||
|
|
|
@ -1,77 +1,77 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef __INITIALIZE_GLOBALS_INCLUDED_
|
||||
#define __INITIALIZE_GLOBALS_INCLUDED_
|
||||
|
||||
void InitializeGlobalPools();
|
||||
void FreeGlobalPools();
|
||||
bool InitializePoolIndex();
|
||||
void FreePoolIndex();
|
||||
|
||||
#endif // __INITIALIZE_GLOBALS_INCLUDED_
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef __INITIALIZE_GLOBALS_INCLUDED_
|
||||
#define __INITIALIZE_GLOBALS_INCLUDED_
|
||||
|
||||
void InitializeGlobalPools();
|
||||
void FreeGlobalPools();
|
||||
bool InitializePoolIndex();
|
||||
void FreePoolIndex();
|
||||
|
||||
#endif // __INITIALIZE_GLOBALS_INCLUDED_
|
||||
|
|
|
@ -1,80 +1,80 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef __INITIALIZE_PARSE_CONTEXT_INCLUDED_
|
||||
#define __INITIALIZE_PARSE_CONTEXT_INCLUDED_
|
||||
#include "osinclude.h"
|
||||
|
||||
bool InitializeParseContextIndex();
|
||||
bool InitializeGlobalParseContext();
|
||||
bool FreeParseContext();
|
||||
bool FreeParseContextIndex();
|
||||
|
||||
|
||||
#endif // __INITIALIZE_PARSE_CONTEXT_INCLUDED_
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef __INITIALIZE_PARSE_CONTEXT_INCLUDED_
|
||||
#define __INITIALIZE_PARSE_CONTEXT_INCLUDED_
|
||||
#include "osinclude.h"
|
||||
|
||||
bool InitializeParseContextIndex();
|
||||
bool InitializeGlobalParseContext();
|
||||
bool FreeParseContext();
|
||||
bool FreeParseContextIndex();
|
||||
|
||||
|
||||
#endif // __INITIALIZE_PARSE_CONTEXT_INCLUDED_
|
||||
|
|
|
@ -1,407 +1,407 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _POOLALLOC_INCLUDED_
|
||||
#define _POOLALLOC_INCLUDED_
|
||||
|
||||
#ifdef _DEBUG
|
||||
# define GUARD_BLOCKS // define to enable guard block sanity checking
|
||||
#endif
|
||||
|
||||
//
|
||||
// This header defines an allocator that can be used to efficiently
|
||||
// allocate a large number of small requests for heap memory, with the
|
||||
// intention that they are not individually deallocated, but rather
|
||||
// collectively deallocated at one time.
|
||||
//
|
||||
// This simultaneously
|
||||
//
|
||||
// * Makes each individual allocation much more efficient; the
|
||||
// typical allocation is trivial.
|
||||
// * Completely avoids the cost of doing individual deallocation.
|
||||
// * Saves the trouble of tracking down and plugging a large class of leaks.
|
||||
//
|
||||
// Individual classes can use this allocator by supplying their own
|
||||
// new and delete methods.
|
||||
//
|
||||
// STL containers can use this allocator by using the pool_allocator
|
||||
// class as the allocator (second) template argument.
|
||||
//
|
||||
|
||||
#include <stddef.h>
|
||||
#include <vector>
|
||||
|
||||
// If we are using guard blocks, we must track each indivual
|
||||
// allocation. If we aren't using guard blocks, these
|
||||
// never get instantiated, so won't have any impact.
|
||||
//
|
||||
|
||||
class TAllocation
|
||||
{
|
||||
public:
|
||||
TAllocation(size_t size, unsigned char* mem, TAllocation* prev = 0) :
|
||||
size(size), mem(mem), prevAlloc(prev)
|
||||
{
|
||||
// Allocations are bracketed:
|
||||
// [allocationHeader][initialGuardBlock][userData][finalGuardBlock]
|
||||
// This would be cleaner with if (guardBlockSize)..., but that
|
||||
// makes the compiler print warnings about 0 length memsets,
|
||||
// even with the if() protecting them.
|
||||
# ifdef GUARD_BLOCKS
|
||||
memset(preGuard(), guardBlockBeginVal, guardBlockSize);
|
||||
memset(data(), userDataFill, size);
|
||||
memset(postGuard(), guardBlockEndVal, guardBlockSize);
|
||||
# endif
|
||||
}
|
||||
|
||||
void GB_check() const
|
||||
{
|
||||
checkGuardBlock(preGuard(), guardBlockBeginVal, "before");
|
||||
checkGuardBlock(postGuard(), guardBlockEndVal, "after");
|
||||
}
|
||||
|
||||
void checkAllocList() const;
|
||||
|
||||
// Return total size needed to accomodate user buffer of 'size',
|
||||
// plus our tracking data.
|
||||
inline static size_t allocationSize(size_t size)
|
||||
{
|
||||
return size + 2 * guardBlockSize + headerSize();
|
||||
}
|
||||
|
||||
// Offset from surrounding buffer to get to user data buffer.
|
||||
inline static unsigned char* offsetAllocation(unsigned char* m)
|
||||
{
|
||||
return m + guardBlockSize + headerSize();
|
||||
}
|
||||
|
||||
private:
|
||||
void checkGuardBlock(unsigned char* blockMem, unsigned char val, char* locText) const;
|
||||
|
||||
// Find offsets to pre and post guard blocks, and user data buffer
|
||||
unsigned char* preGuard() const { return mem + headerSize(); }
|
||||
unsigned char* data() const { return preGuard() + guardBlockSize; }
|
||||
unsigned char* postGuard() const { return data() + size; }
|
||||
|
||||
size_t size; // size of the user data area
|
||||
unsigned char* mem; // beginning of our allocation (pts to header)
|
||||
TAllocation* prevAlloc; // prior allocation in the chain
|
||||
|
||||
// Support MSVC++ 6.0
|
||||
const static unsigned char guardBlockBeginVal;
|
||||
const static unsigned char guardBlockEndVal;
|
||||
const static unsigned char userDataFill;
|
||||
|
||||
const static size_t guardBlockSize;
|
||||
# ifdef GUARD_BLOCKS
|
||||
inline static size_t headerSize() { return sizeof(TAllocation); }
|
||||
# else
|
||||
inline static size_t headerSize() { return 0; }
|
||||
# endif
|
||||
};
|
||||
|
||||
//
|
||||
// There are several stacks. One is to track the pushing and popping
|
||||
// of the user, and not yet implemented. The others are simply a
|
||||
// repositories of free pages or used pages.
|
||||
//
|
||||
// Page stacks are linked together with a simple header at the beginning
|
||||
// of each allocation obtained from the underlying OS. Multi-page allocations
|
||||
// are returned to the OS. Individual page allocations are kept for future
|
||||
// re-use.
|
||||
//
|
||||
// The "page size" used is not, nor must it match, the underlying OS
|
||||
// page size. But, having it be about that size or equal to a set of
|
||||
// pages is likely most optimal.
|
||||
//
|
||||
class TPoolAllocator {
|
||||
public:
|
||||
TPoolAllocator(bool global = false, int growthIncrement = 8*1024, int allocationAlignment = 16);
|
||||
|
||||
//
|
||||
// Don't call the destructor just to free up the memory, call pop()
|
||||
//
|
||||
~TPoolAllocator();
|
||||
|
||||
//
|
||||
// Call push() to establish a new place to pop memory too. Does not
|
||||
// have to be called to get things started.
|
||||
//
|
||||
void push();
|
||||
|
||||
//
|
||||
// Call pop() to free all memory allocated since the last call to push(),
|
||||
// or if no last call to push, frees all memory since first allocation.
|
||||
//
|
||||
void pop();
|
||||
|
||||
//
|
||||
// Call popAll() to free all memory allocated.
|
||||
//
|
||||
void popAll();
|
||||
|
||||
//
|
||||
// Call allocate() to actually acquire memory. Returns 0 if no memory
|
||||
// available, otherwise a properly aligned pointer to 'numBytes' of memory.
|
||||
//
|
||||
void* allocate(size_t numBytes);
|
||||
|
||||
//
|
||||
// There is no deallocate. The point of this class is that
|
||||
// deallocation can be skipped by the user of it, as the model
|
||||
// of use is to simultaneously deallocate everything at once
|
||||
// by calling pop(), and to not have to solve memory leak problems.
|
||||
//
|
||||
|
||||
protected:
|
||||
friend struct tHeader;
|
||||
|
||||
struct tHeader
|
||||
{
|
||||
tHeader(tHeader* nextPage, size_t pageCount) :
|
||||
#ifdef GUARD_BLOCKS
|
||||
lastAllocation(0),
|
||||
#endif
|
||||
nextPage(nextPage), pageCount(pageCount)
|
||||
{
|
||||
}
|
||||
|
||||
~tHeader()
|
||||
{
|
||||
#ifdef GUARD_BLOCKS
|
||||
if (lastAllocation)
|
||||
lastAllocation->checkAllocList();
|
||||
#endif
|
||||
}
|
||||
|
||||
tHeader* nextPage;
|
||||
size_t pageCount;
|
||||
#ifdef GUARD_BLOCKS
|
||||
TAllocation* lastAllocation;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct tAllocState
|
||||
{
|
||||
size_t offset;
|
||||
tHeader* page;
|
||||
};
|
||||
typedef std::vector<tAllocState> tAllocStack;
|
||||
|
||||
// Track allocations if and only if we're using guard blocks
|
||||
void* initializeAllocation(tHeader* block, unsigned char* memory, size_t numBytes)
|
||||
{
|
||||
# ifdef GUARD_BLOCKS
|
||||
new(memory) TAllocation(numBytes, memory, block->lastAllocation);
|
||||
block->lastAllocation = reinterpret_cast<TAllocation*>(memory);
|
||||
# endif
|
||||
|
||||
// This is optimized entirely away if GUARD_BLOCKS is not defined.
|
||||
return TAllocation::offsetAllocation(memory);
|
||||
}
|
||||
|
||||
bool global; // should be true if this object is globally scoped
|
||||
size_t pageSize; // granularity of allocation from the OS
|
||||
size_t alignment; // all returned allocations will be aligned at
|
||||
// this granularity, which will be a power of 2
|
||||
size_t alignmentMask;
|
||||
size_t headerSkip; // amount of memory to skip to make room for the
|
||||
// header (basically, size of header, rounded
|
||||
// up to make it aligned
|
||||
size_t currentPageOffset; // next offset in top of inUseList to allocate from
|
||||
tHeader* freeList; // list of popped memory
|
||||
tHeader* inUseList; // list of all memory currently being used
|
||||
tAllocStack stack; // stack of where to allocate from, to partition pool
|
||||
|
||||
int numCalls; // just an interesting statistic
|
||||
size_t totalBytes; // just an interesting statistic
|
||||
private:
|
||||
TPoolAllocator& operator=(const TPoolAllocator&); // dont allow assignment operator
|
||||
TPoolAllocator(const TPoolAllocator&); // dont allow default copy constructor
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// There could potentially be many pools with pops happening at
|
||||
// different times. But a simple use is to have a global pop
|
||||
// with everyone using the same global allocator.
|
||||
//
|
||||
typedef TPoolAllocator* PoolAllocatorPointer;
|
||||
extern TPoolAllocator& GetGlobalPoolAllocator();
|
||||
#define GlobalPoolAllocator GetGlobalPoolAllocator()
|
||||
|
||||
|
||||
struct TThreadGlobalPools
|
||||
{
|
||||
TPoolAllocator* globalPoolAllocator;
|
||||
};
|
||||
|
||||
void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator);
|
||||
|
||||
//
|
||||
// This STL compatible allocator is intended to be used as the allocator
|
||||
// parameter to templatized STL containers, like vector and map.
|
||||
//
|
||||
// It will use the pools for allocation, and not
|
||||
// do any deallocation, but will still do destruction.
|
||||
//
|
||||
template<class T>
|
||||
class pool_allocator
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T *pointer;
|
||||
typedef const T *const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T value_type;
|
||||
template<class Other>
|
||||
struct rebind
|
||||
{
|
||||
typedef pool_allocator<Other> other;
|
||||
};
|
||||
pointer address(reference x) const { return &x; }
|
||||
const_pointer address(const_reference x) const { return &x; }
|
||||
|
||||
#ifdef USING_SGI_STL
|
||||
pool_allocator() { }
|
||||
#else
|
||||
pool_allocator() : allocator(GlobalPoolAllocator) { }
|
||||
pool_allocator(TPoolAllocator& a) : allocator(a) { }
|
||||
pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1300
|
||||
template<class Other>
|
||||
#ifdef USING_SGI_STL
|
||||
pool_allocator(const pool_allocator<Other>& p) /*: allocator(p.getAllocator())*/ { }
|
||||
#else
|
||||
pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
template<class Other>
|
||||
pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
|
||||
#endif
|
||||
|
||||
#ifdef USING_SGI_STL
|
||||
static pointer allocate(size_type n)
|
||||
{
|
||||
return reinterpret_cast<pointer>(getAllocator().allocate(n));
|
||||
}
|
||||
pointer allocate(size_type n, const void*)
|
||||
{
|
||||
return reinterpret_cast<pointer>(getAllocator().allocate(n));
|
||||
}
|
||||
|
||||
static void deallocate(void*, size_type) { }
|
||||
static void deallocate(pointer, size_type) { }
|
||||
#else
|
||||
pointer allocate(size_type n)
|
||||
{
|
||||
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T)));
|
||||
}
|
||||
pointer allocate(size_type n, const void*)
|
||||
{
|
||||
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T)));
|
||||
}
|
||||
|
||||
void deallocate(void*, size_type) { }
|
||||
void deallocate(pointer, size_type) { }
|
||||
#endif
|
||||
|
||||
pointer _Charalloc(size_t n)
|
||||
{
|
||||
return reinterpret_cast<pointer>(getAllocator().allocate(n));
|
||||
}
|
||||
|
||||
void construct(pointer p, const T& val) { new ((void *)p) T(val); }
|
||||
void destroy(pointer p) { p->T::~T(); }
|
||||
|
||||
bool operator==(const pool_allocator& rhs) const { return &getAllocator() == &rhs.getAllocator(); }
|
||||
bool operator!=(const pool_allocator& rhs) const { return &getAllocator() != &rhs.getAllocator(); }
|
||||
|
||||
size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); }
|
||||
size_type max_size(int size) const { return static_cast<size_type>(-1) / size; }
|
||||
|
||||
#ifdef USING_SGI_STL
|
||||
//void setAllocator(TPoolAllocator* a) { allocator = a; }
|
||||
static TPoolAllocator& getAllocator() { return GlobalPoolAllocator; }
|
||||
#else
|
||||
void setAllocator(TPoolAllocator* a) { allocator = *a; }
|
||||
TPoolAllocator& getAllocator() const { return allocator; }
|
||||
|
||||
protected:
|
||||
TPoolAllocator& allocator;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // _POOLALLOC_INCLUDED_
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _POOLALLOC_INCLUDED_
|
||||
#define _POOLALLOC_INCLUDED_
|
||||
|
||||
#ifdef _DEBUG
|
||||
# define GUARD_BLOCKS // define to enable guard block sanity checking
|
||||
#endif
|
||||
|
||||
//
|
||||
// This header defines an allocator that can be used to efficiently
|
||||
// allocate a large number of small requests for heap memory, with the
|
||||
// intention that they are not individually deallocated, but rather
|
||||
// collectively deallocated at one time.
|
||||
//
|
||||
// This simultaneously
|
||||
//
|
||||
// * Makes each individual allocation much more efficient; the
|
||||
// typical allocation is trivial.
|
||||
// * Completely avoids the cost of doing individual deallocation.
|
||||
// * Saves the trouble of tracking down and plugging a large class of leaks.
|
||||
//
|
||||
// Individual classes can use this allocator by supplying their own
|
||||
// new and delete methods.
|
||||
//
|
||||
// STL containers can use this allocator by using the pool_allocator
|
||||
// class as the allocator (second) template argument.
|
||||
//
|
||||
|
||||
#include <stddef.h>
|
||||
#include <vector>
|
||||
|
||||
// If we are using guard blocks, we must track each indivual
|
||||
// allocation. If we aren't using guard blocks, these
|
||||
// never get instantiated, so won't have any impact.
|
||||
//
|
||||
|
||||
class TAllocation
|
||||
{
|
||||
public:
|
||||
TAllocation(size_t size, unsigned char* mem, TAllocation* prev = 0) :
|
||||
size(size), mem(mem), prevAlloc(prev)
|
||||
{
|
||||
// Allocations are bracketed:
|
||||
// [allocationHeader][initialGuardBlock][userData][finalGuardBlock]
|
||||
// This would be cleaner with if (guardBlockSize)..., but that
|
||||
// makes the compiler print warnings about 0 length memsets,
|
||||
// even with the if() protecting them.
|
||||
# ifdef GUARD_BLOCKS
|
||||
memset(preGuard(), guardBlockBeginVal, guardBlockSize);
|
||||
memset(data(), userDataFill, size);
|
||||
memset(postGuard(), guardBlockEndVal, guardBlockSize);
|
||||
# endif
|
||||
}
|
||||
|
||||
void GB_check() const
|
||||
{
|
||||
checkGuardBlock(preGuard(), guardBlockBeginVal, "before");
|
||||
checkGuardBlock(postGuard(), guardBlockEndVal, "after");
|
||||
}
|
||||
|
||||
void checkAllocList() const;
|
||||
|
||||
// Return total size needed to accomodate user buffer of 'size',
|
||||
// plus our tracking data.
|
||||
inline static size_t allocationSize(size_t size)
|
||||
{
|
||||
return size + 2 * guardBlockSize + headerSize();
|
||||
}
|
||||
|
||||
// Offset from surrounding buffer to get to user data buffer.
|
||||
inline static unsigned char* offsetAllocation(unsigned char* m)
|
||||
{
|
||||
return m + guardBlockSize + headerSize();
|
||||
}
|
||||
|
||||
private:
|
||||
void checkGuardBlock(unsigned char* blockMem, unsigned char val, char* locText) const;
|
||||
|
||||
// Find offsets to pre and post guard blocks, and user data buffer
|
||||
unsigned char* preGuard() const { return mem + headerSize(); }
|
||||
unsigned char* data() const { return preGuard() + guardBlockSize; }
|
||||
unsigned char* postGuard() const { return data() + size; }
|
||||
|
||||
size_t size; // size of the user data area
|
||||
unsigned char* mem; // beginning of our allocation (pts to header)
|
||||
TAllocation* prevAlloc; // prior allocation in the chain
|
||||
|
||||
// Support MSVC++ 6.0
|
||||
const static unsigned char guardBlockBeginVal;
|
||||
const static unsigned char guardBlockEndVal;
|
||||
const static unsigned char userDataFill;
|
||||
|
||||
const static size_t guardBlockSize;
|
||||
# ifdef GUARD_BLOCKS
|
||||
inline static size_t headerSize() { return sizeof(TAllocation); }
|
||||
# else
|
||||
inline static size_t headerSize() { return 0; }
|
||||
# endif
|
||||
};
|
||||
|
||||
//
|
||||
// There are several stacks. One is to track the pushing and popping
|
||||
// of the user, and not yet implemented. The others are simply a
|
||||
// repositories of free pages or used pages.
|
||||
//
|
||||
// Page stacks are linked together with a simple header at the beginning
|
||||
// of each allocation obtained from the underlying OS. Multi-page allocations
|
||||
// are returned to the OS. Individual page allocations are kept for future
|
||||
// re-use.
|
||||
//
|
||||
// The "page size" used is not, nor must it match, the underlying OS
|
||||
// page size. But, having it be about that size or equal to a set of
|
||||
// pages is likely most optimal.
|
||||
//
|
||||
class TPoolAllocator {
|
||||
public:
|
||||
TPoolAllocator(bool global = false, int growthIncrement = 8*1024, int allocationAlignment = 16);
|
||||
|
||||
//
|
||||
// Don't call the destructor just to free up the memory, call pop()
|
||||
//
|
||||
~TPoolAllocator();
|
||||
|
||||
//
|
||||
// Call push() to establish a new place to pop memory too. Does not
|
||||
// have to be called to get things started.
|
||||
//
|
||||
void push();
|
||||
|
||||
//
|
||||
// Call pop() to free all memory allocated since the last call to push(),
|
||||
// or if no last call to push, frees all memory since first allocation.
|
||||
//
|
||||
void pop();
|
||||
|
||||
//
|
||||
// Call popAll() to free all memory allocated.
|
||||
//
|
||||
void popAll();
|
||||
|
||||
//
|
||||
// Call allocate() to actually acquire memory. Returns 0 if no memory
|
||||
// available, otherwise a properly aligned pointer to 'numBytes' of memory.
|
||||
//
|
||||
void* allocate(size_t numBytes);
|
||||
|
||||
//
|
||||
// There is no deallocate. The point of this class is that
|
||||
// deallocation can be skipped by the user of it, as the model
|
||||
// of use is to simultaneously deallocate everything at once
|
||||
// by calling pop(), and to not have to solve memory leak problems.
|
||||
//
|
||||
|
||||
protected:
|
||||
friend struct tHeader;
|
||||
|
||||
struct tHeader
|
||||
{
|
||||
tHeader(tHeader* nextPage, size_t pageCount) :
|
||||
#ifdef GUARD_BLOCKS
|
||||
lastAllocation(0),
|
||||
#endif
|
||||
nextPage(nextPage), pageCount(pageCount)
|
||||
{
|
||||
}
|
||||
|
||||
~tHeader()
|
||||
{
|
||||
#ifdef GUARD_BLOCKS
|
||||
if (lastAllocation)
|
||||
lastAllocation->checkAllocList();
|
||||
#endif
|
||||
}
|
||||
|
||||
tHeader* nextPage;
|
||||
size_t pageCount;
|
||||
#ifdef GUARD_BLOCKS
|
||||
TAllocation* lastAllocation;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct tAllocState
|
||||
{
|
||||
size_t offset;
|
||||
tHeader* page;
|
||||
};
|
||||
typedef std::vector<tAllocState> tAllocStack;
|
||||
|
||||
// Track allocations if and only if we're using guard blocks
|
||||
void* initializeAllocation(tHeader* block, unsigned char* memory, size_t numBytes)
|
||||
{
|
||||
# ifdef GUARD_BLOCKS
|
||||
new(memory) TAllocation(numBytes, memory, block->lastAllocation);
|
||||
block->lastAllocation = reinterpret_cast<TAllocation*>(memory);
|
||||
# endif
|
||||
|
||||
// This is optimized entirely away if GUARD_BLOCKS is not defined.
|
||||
return TAllocation::offsetAllocation(memory);
|
||||
}
|
||||
|
||||
bool global; // should be true if this object is globally scoped
|
||||
size_t pageSize; // granularity of allocation from the OS
|
||||
size_t alignment; // all returned allocations will be aligned at
|
||||
// this granularity, which will be a power of 2
|
||||
size_t alignmentMask;
|
||||
size_t headerSkip; // amount of memory to skip to make room for the
|
||||
// header (basically, size of header, rounded
|
||||
// up to make it aligned
|
||||
size_t currentPageOffset; // next offset in top of inUseList to allocate from
|
||||
tHeader* freeList; // list of popped memory
|
||||
tHeader* inUseList; // list of all memory currently being used
|
||||
tAllocStack stack; // stack of where to allocate from, to partition pool
|
||||
|
||||
int numCalls; // just an interesting statistic
|
||||
size_t totalBytes; // just an interesting statistic
|
||||
private:
|
||||
TPoolAllocator& operator=(const TPoolAllocator&); // dont allow assignment operator
|
||||
TPoolAllocator(const TPoolAllocator&); // dont allow default copy constructor
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// There could potentially be many pools with pops happening at
|
||||
// different times. But a simple use is to have a global pop
|
||||
// with everyone using the same global allocator.
|
||||
//
|
||||
typedef TPoolAllocator* PoolAllocatorPointer;
|
||||
extern TPoolAllocator& GetGlobalPoolAllocator();
|
||||
#define GlobalPoolAllocator GetGlobalPoolAllocator()
|
||||
|
||||
|
||||
struct TThreadGlobalPools
|
||||
{
|
||||
TPoolAllocator* globalPoolAllocator;
|
||||
};
|
||||
|
||||
void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator);
|
||||
|
||||
//
|
||||
// This STL compatible allocator is intended to be used as the allocator
|
||||
// parameter to templatized STL containers, like vector and map.
|
||||
//
|
||||
// It will use the pools for allocation, and not
|
||||
// do any deallocation, but will still do destruction.
|
||||
//
|
||||
template<class T>
|
||||
class pool_allocator
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T *pointer;
|
||||
typedef const T *const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T value_type;
|
||||
template<class Other>
|
||||
struct rebind
|
||||
{
|
||||
typedef pool_allocator<Other> other;
|
||||
};
|
||||
pointer address(reference x) const { return &x; }
|
||||
const_pointer address(const_reference x) const { return &x; }
|
||||
|
||||
#ifdef USING_SGI_STL
|
||||
pool_allocator() { }
|
||||
#else
|
||||
pool_allocator() : allocator(GlobalPoolAllocator) { }
|
||||
pool_allocator(TPoolAllocator& a) : allocator(a) { }
|
||||
pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1300
|
||||
template<class Other>
|
||||
#ifdef USING_SGI_STL
|
||||
pool_allocator(const pool_allocator<Other>& p) /*: allocator(p.getAllocator())*/ { }
|
||||
#else
|
||||
pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
template<class Other>
|
||||
pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
|
||||
#endif
|
||||
|
||||
#ifdef USING_SGI_STL
|
||||
static pointer allocate(size_type n)
|
||||
{
|
||||
return reinterpret_cast<pointer>(getAllocator().allocate(n));
|
||||
}
|
||||
pointer allocate(size_type n, const void*)
|
||||
{
|
||||
return reinterpret_cast<pointer>(getAllocator().allocate(n));
|
||||
}
|
||||
|
||||
static void deallocate(void*, size_type) { }
|
||||
static void deallocate(pointer, size_type) { }
|
||||
#else
|
||||
pointer allocate(size_type n)
|
||||
{
|
||||
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T)));
|
||||
}
|
||||
pointer allocate(size_type n, const void*)
|
||||
{
|
||||
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T)));
|
||||
}
|
||||
|
||||
void deallocate(void*, size_type) { }
|
||||
void deallocate(pointer, size_type) { }
|
||||
#endif
|
||||
|
||||
pointer _Charalloc(size_t n)
|
||||
{
|
||||
return reinterpret_cast<pointer>(getAllocator().allocate(n));
|
||||
}
|
||||
|
||||
void construct(pointer p, const T& val) { new ((void *)p) T(val); }
|
||||
void destroy(pointer p) { p->T::~T(); }
|
||||
|
||||
bool operator==(const pool_allocator& rhs) const { return &getAllocator() == &rhs.getAllocator(); }
|
||||
bool operator!=(const pool_allocator& rhs) const { return &getAllocator() != &rhs.getAllocator(); }
|
||||
|
||||
size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); }
|
||||
size_type max_size(int size) const { return static_cast<size_type>(-1) / size; }
|
||||
|
||||
#ifdef USING_SGI_STL
|
||||
//void setAllocator(TPoolAllocator* a) { allocator = a; }
|
||||
static TPoolAllocator& getAllocator() { return GlobalPoolAllocator; }
|
||||
#else
|
||||
void setAllocator(TPoolAllocator* a) { allocator = *a; }
|
||||
TPoolAllocator& getAllocator() const { return allocator; }
|
||||
|
||||
protected:
|
||||
TPoolAllocator& allocator;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // _POOLALLOC_INCLUDED_
|
||||
|
|
|
@ -1,191 +1,191 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _SHHANDLE_INCLUDED_
|
||||
#define _SHHANDLE_INCLUDED_
|
||||
|
||||
//
|
||||
// Machine independent part of the compiler private objects
|
||||
// sent as ShHandle to the driver.
|
||||
//
|
||||
// This should not be included by driver code.
|
||||
//
|
||||
|
||||
#include "../../include/hlsl2glsl.h"
|
||||
|
||||
#include "InfoSink.h"
|
||||
|
||||
class TCompiler;
|
||||
class TLinker;
|
||||
|
||||
|
||||
//
|
||||
// The base class used to back handles returned to the driver.
|
||||
//
|
||||
class TShHandleBase
|
||||
{
|
||||
public:
|
||||
TShHandleBase() {}
|
||||
virtual ~TShHandleBase() {}
|
||||
virtual TCompiler* getAsCompiler() { return 0; }
|
||||
virtual TLinker* getAsLinker() { return 0; }
|
||||
virtual const TCompiler* getAsCompiler() const { return 0; }
|
||||
virtual const TLinker* getAsLinker() const { return 0; }
|
||||
};
|
||||
|
||||
class TIntermNode;
|
||||
|
||||
//
|
||||
// The base class for the machine dependent compiler to derive from
|
||||
// for managing object code from the compile.
|
||||
//
|
||||
class TCompiler : public TShHandleBase
|
||||
{
|
||||
public:
|
||||
TCompiler(EShLanguage l, TInfoSink& sink) : infoSink(sink) , language(l), haveValidObjectCode(false)
|
||||
{ }
|
||||
virtual ~TCompiler() { }
|
||||
EShLanguage getLanguage() { return language; }
|
||||
virtual TInfoSink& getInfoSink() { return infoSink; }
|
||||
|
||||
virtual bool compile(TIntermNode* root) = 0;
|
||||
|
||||
virtual TCompiler* getAsCompiler() { return this; }
|
||||
virtual const TCompiler* getAsCompiler() const { return this; }
|
||||
virtual bool linkable() { return haveValidObjectCode; }
|
||||
|
||||
TInfoSink& infoSink;
|
||||
protected:
|
||||
EShLanguage language;
|
||||
bool haveValidObjectCode;
|
||||
};
|
||||
|
||||
//
|
||||
// Link operations are base on a list of compile results...
|
||||
//
|
||||
typedef TVector<TCompiler*> TCompilerList;
|
||||
typedef TVector<TShHandleBase*> THandleList;
|
||||
|
||||
//
|
||||
// The base class for the machine dependent linker to derive from
|
||||
// to manage the resulting executable.
|
||||
//
|
||||
|
||||
class TLinker : public TShHandleBase
|
||||
{
|
||||
public:
|
||||
TLinker(TInfoSink& iSink) :
|
||||
infoSink(iSink),
|
||||
haveReturnableObjectCode(false),
|
||||
uniformBindings(0)
|
||||
{
|
||||
}
|
||||
virtual TLinker* getAsLinker() { return this; }
|
||||
virtual const TLinker* getAsLinker() const { return this; }
|
||||
virtual ~TLinker() { }
|
||||
virtual bool link(THandleList&, const char*, const char*, bool comments) { return false; }
|
||||
virtual bool setUserAttribName ( EAttribSemantic eSemantic, const char *pName ) = 0;
|
||||
virtual void setUseUserVaryings ( bool bUseUserVaryings ) = 0;
|
||||
virtual bool setShaderHeader ( bool bOutputShaderHeader, const char *shaderHeaderString ) = 0;
|
||||
virtual ShBindingTable* getUniformBindings() const { return uniformBindings; }
|
||||
virtual const void* getObjectCode() const { return 0; } // a real compiler would be returning object code here
|
||||
virtual TInfoSink& getInfoSink()
|
||||
{
|
||||
return infoSink;
|
||||
}
|
||||
TInfoSink& infoSink;
|
||||
|
||||
virtual const char* getShaderText( EShLanguage lang) const = 0;
|
||||
virtual int getUniformCount() const = 0;
|
||||
virtual const ShUniformInfo* getUniformInfo() const = 0;
|
||||
|
||||
protected:
|
||||
bool haveReturnableObjectCode; // true when objectCode is acceptable to send to driver
|
||||
|
||||
ShBindingTable* uniformBindings; // created by the linker
|
||||
};
|
||||
|
||||
//
|
||||
// This is the interface between the machine independent code
|
||||
// and the machine dependent code.
|
||||
//
|
||||
// The machine dependent code should derive from the classes
|
||||
// above. Then Construct*() and Delete*() will create and
|
||||
// destroy the machine dependent objects, which contain the
|
||||
// above machine independent information.
|
||||
//
|
||||
TCompiler* ConstructCompiler(EShLanguage, int);
|
||||
|
||||
TShHandleBase* ConstructLinker(int);
|
||||
void DeleteLinker(TShHandleBase*);
|
||||
void DeleteCompiler(TCompiler*);
|
||||
|
||||
|
||||
#endif // _SHHANDLE_INCLUDED_
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _SHHANDLE_INCLUDED_
|
||||
#define _SHHANDLE_INCLUDED_
|
||||
|
||||
//
|
||||
// Machine independent part of the compiler private objects
|
||||
// sent as ShHandle to the driver.
|
||||
//
|
||||
// This should not be included by driver code.
|
||||
//
|
||||
|
||||
#include "../../include/hlsl2glsl.h"
|
||||
|
||||
#include "InfoSink.h"
|
||||
|
||||
class TCompiler;
|
||||
class TLinker;
|
||||
|
||||
|
||||
//
|
||||
// The base class used to back handles returned to the driver.
|
||||
//
|
||||
class TShHandleBase
|
||||
{
|
||||
public:
|
||||
TShHandleBase() {}
|
||||
virtual ~TShHandleBase() {}
|
||||
virtual TCompiler* getAsCompiler() { return 0; }
|
||||
virtual TLinker* getAsLinker() { return 0; }
|
||||
virtual const TCompiler* getAsCompiler() const { return 0; }
|
||||
virtual const TLinker* getAsLinker() const { return 0; }
|
||||
};
|
||||
|
||||
class TIntermNode;
|
||||
|
||||
//
|
||||
// The base class for the machine dependent compiler to derive from
|
||||
// for managing object code from the compile.
|
||||
//
|
||||
class TCompiler : public TShHandleBase
|
||||
{
|
||||
public:
|
||||
TCompiler(EShLanguage l, TInfoSink& sink) : infoSink(sink) , language(l), haveValidObjectCode(false)
|
||||
{ }
|
||||
virtual ~TCompiler() { }
|
||||
EShLanguage getLanguage() { return language; }
|
||||
virtual TInfoSink& getInfoSink() { return infoSink; }
|
||||
|
||||
virtual bool compile(TIntermNode* root) = 0;
|
||||
|
||||
virtual TCompiler* getAsCompiler() { return this; }
|
||||
virtual const TCompiler* getAsCompiler() const { return this; }
|
||||
virtual bool linkable() { return haveValidObjectCode; }
|
||||
|
||||
TInfoSink& infoSink;
|
||||
protected:
|
||||
EShLanguage language;
|
||||
bool haveValidObjectCode;
|
||||
};
|
||||
|
||||
//
|
||||
// Link operations are base on a list of compile results...
|
||||
//
|
||||
typedef TVector<TCompiler*> TCompilerList;
|
||||
typedef TVector<TShHandleBase*> THandleList;
|
||||
|
||||
//
|
||||
// The base class for the machine dependent linker to derive from
|
||||
// to manage the resulting executable.
|
||||
//
|
||||
|
||||
class TLinker : public TShHandleBase
|
||||
{
|
||||
public:
|
||||
TLinker(TInfoSink& iSink) :
|
||||
infoSink(iSink),
|
||||
haveReturnableObjectCode(false),
|
||||
uniformBindings(0)
|
||||
{
|
||||
}
|
||||
virtual TLinker* getAsLinker() { return this; }
|
||||
virtual const TLinker* getAsLinker() const { return this; }
|
||||
virtual ~TLinker() { }
|
||||
virtual bool link(THandleList&, const char*, const char*, bool comments) { return false; }
|
||||
virtual bool setUserAttribName ( EAttribSemantic eSemantic, const char *pName ) = 0;
|
||||
virtual void setUseUserVaryings ( bool bUseUserVaryings ) = 0;
|
||||
virtual bool setShaderHeader ( bool bOutputShaderHeader, const char *shaderHeaderString ) = 0;
|
||||
virtual ShBindingTable* getUniformBindings() const { return uniformBindings; }
|
||||
virtual const void* getObjectCode() const { return 0; } // a real compiler would be returning object code here
|
||||
virtual TInfoSink& getInfoSink()
|
||||
{
|
||||
return infoSink;
|
||||
}
|
||||
TInfoSink& infoSink;
|
||||
|
||||
virtual const char* getShaderText( EShLanguage lang) const = 0;
|
||||
virtual int getUniformCount() const = 0;
|
||||
virtual const ShUniformInfo* getUniformInfo() const = 0;
|
||||
|
||||
protected:
|
||||
bool haveReturnableObjectCode; // true when objectCode is acceptable to send to driver
|
||||
|
||||
ShBindingTable* uniformBindings; // created by the linker
|
||||
};
|
||||
|
||||
//
|
||||
// This is the interface between the machine independent code
|
||||
// and the machine dependent code.
|
||||
//
|
||||
// The machine dependent code should derive from the classes
|
||||
// above. Then Construct*() and Delete*() will create and
|
||||
// destroy the machine dependent objects, which contain the
|
||||
// above machine independent information.
|
||||
//
|
||||
TCompiler* ConstructCompiler(EShLanguage, int);
|
||||
|
||||
TShHandleBase* ConstructLinker(int);
|
||||
void DeleteLinker(TShHandleBase*);
|
||||
void DeleteCompiler(TCompiler*);
|
||||
|
||||
|
||||
#endif // _SHHANDLE_INCLUDED_
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,146 +1,146 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
#include "../Include/InfoSink.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
void TInfoSinkBase::append(const char *s)
|
||||
{
|
||||
if (outputStream & EString)
|
||||
{
|
||||
checkMem(strlen(s));
|
||||
sink.append(s);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (outputStream & EDebugger)
|
||||
OutputDebugString(s);
|
||||
#endif
|
||||
|
||||
if (outputStream & EStdOut)
|
||||
fprintf(stdout, "%s", s);
|
||||
}
|
||||
|
||||
void TInfoSinkBase::append(int count, char c)
|
||||
{
|
||||
if (outputStream & EString)
|
||||
{
|
||||
checkMem(count);
|
||||
sink.append(count, c);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (outputStream & EDebugger)
|
||||
{
|
||||
char str[2];
|
||||
str[0] = c;
|
||||
str[1] = '\0';
|
||||
OutputDebugString(str);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (outputStream & EStdOut)
|
||||
fprintf(stdout, "%c", c);
|
||||
}
|
||||
|
||||
void TInfoSinkBase::append(const TPersistString& t)
|
||||
{
|
||||
if (outputStream & EString)
|
||||
{
|
||||
checkMem(t.size());
|
||||
sink.append(t);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (outputStream & EDebugger)
|
||||
OutputDebugString(t.c_str());
|
||||
#endif
|
||||
|
||||
if (outputStream & EStdOut)
|
||||
fprintf(stdout, "%s", t.c_str());
|
||||
}
|
||||
|
||||
void TInfoSinkBase::append(const TString& t)
|
||||
{
|
||||
if (outputStream & EString)
|
||||
{
|
||||
checkMem(t.size());
|
||||
sink.append(t.c_str());
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (outputStream & EDebugger)
|
||||
OutputDebugString(t.c_str());
|
||||
#endif
|
||||
|
||||
if (outputStream & EStdOut)
|
||||
fprintf(stdout, "%s", t.c_str());
|
||||
}
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
#include "../Include/InfoSink.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
void TInfoSinkBase::append(const char *s)
|
||||
{
|
||||
if (outputStream & EString)
|
||||
{
|
||||
checkMem(strlen(s));
|
||||
sink.append(s);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (outputStream & EDebugger)
|
||||
OutputDebugString(s);
|
||||
#endif
|
||||
|
||||
if (outputStream & EStdOut)
|
||||
fprintf(stdout, "%s", s);
|
||||
}
|
||||
|
||||
void TInfoSinkBase::append(int count, char c)
|
||||
{
|
||||
if (outputStream & EString)
|
||||
{
|
||||
checkMem(count);
|
||||
sink.append(count, c);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (outputStream & EDebugger)
|
||||
{
|
||||
char str[2];
|
||||
str[0] = c;
|
||||
str[1] = '\0';
|
||||
OutputDebugString(str);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (outputStream & EStdOut)
|
||||
fprintf(stdout, "%c", c);
|
||||
}
|
||||
|
||||
void TInfoSinkBase::append(const TPersistString& t)
|
||||
{
|
||||
if (outputStream & EString)
|
||||
{
|
||||
checkMem(t.size());
|
||||
sink.append(t);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (outputStream & EDebugger)
|
||||
OutputDebugString(t.c_str());
|
||||
#endif
|
||||
|
||||
if (outputStream & EStdOut)
|
||||
fprintf(stdout, "%s", t.c_str());
|
||||
}
|
||||
|
||||
void TInfoSinkBase::append(const TString& t)
|
||||
{
|
||||
if (outputStream & EString)
|
||||
{
|
||||
checkMem(t.size());
|
||||
sink.append(t.c_str());
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (outputStream & EDebugger)
|
||||
OutputDebugString(t.c_str());
|
||||
#endif
|
||||
|
||||
if (outputStream & EStdOut)
|
||||
fprintf(stdout, "%s", t.c_str());
|
||||
}
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,100 +1,100 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef _INITIALIZE_INCLUDED_
|
||||
#define _INITIALIZE_INCLUDED_
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/ShHandle.h"
|
||||
#include "SymbolTable.h"
|
||||
|
||||
typedef TVector<TString> TBuiltInStrings;
|
||||
|
||||
class TBuiltIns
|
||||
{
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
void initialize();
|
||||
TBuiltInStrings* getBuiltInStrings()
|
||||
{
|
||||
return builtInStrings;
|
||||
}
|
||||
protected:
|
||||
|
||||
|
||||
TBuiltInStrings builtInStrings[EShLangCount];
|
||||
};
|
||||
|
||||
void IdentifyBuiltIns(EShLanguage, TSymbolTable&);
|
||||
void InitializeSupportCode( TString &support);
|
||||
char* GetPreprocessorBuiltinString();
|
||||
extern "C" int InitPreprocessor(void);
|
||||
extern "C" int FinalizePreprocessor(void);
|
||||
|
||||
#endif // _INITIALIZE_INCLUDED_
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef _INITIALIZE_INCLUDED_
|
||||
#define _INITIALIZE_INCLUDED_
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/ShHandle.h"
|
||||
#include "SymbolTable.h"
|
||||
|
||||
typedef TVector<TString> TBuiltInStrings;
|
||||
|
||||
class TBuiltIns
|
||||
{
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
void initialize();
|
||||
TBuiltInStrings* getBuiltInStrings()
|
||||
{
|
||||
return builtInStrings;
|
||||
}
|
||||
protected:
|
||||
|
||||
|
||||
TBuiltInStrings builtInStrings[EShLangCount];
|
||||
};
|
||||
|
||||
void IdentifyBuiltIns(EShLanguage, TSymbolTable&);
|
||||
void InitializeSupportCode( TString &support);
|
||||
char* GetPreprocessorBuiltinString();
|
||||
extern "C" int InitPreprocessor(void);
|
||||
extern "C" int FinalizePreprocessor(void);
|
||||
|
||||
#endif // _INITIALIZE_INCLUDED_
|
||||
|
||||
|
|
|
@ -1,297 +1,297 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "../Include/intermediate.h"
|
||||
|
||||
//
|
||||
// Traverse the intermediate representation tree, and
|
||||
// call a node type specific function for each node.
|
||||
// Done recursively through the member function Traverse().
|
||||
// Node types can be skipped if their function to call is 0,
|
||||
// but their subtree will still be traversed.
|
||||
// Nodes with children can have their whole subtree skipped
|
||||
// if preVisit is turned on and the type specific function
|
||||
// returns false.
|
||||
//
|
||||
// preVisit, postVisit, and rightToLeft control what order
|
||||
// nodes are visited in.
|
||||
//
|
||||
|
||||
//
|
||||
// Traversal functions for terminals are straighforward....
|
||||
//
|
||||
void TIntermSymbol::traverse(TIntermTraverser* it)
|
||||
{
|
||||
if (it->visitSymbol)
|
||||
it->visitSymbol(this, it);
|
||||
}
|
||||
|
||||
void TIntermConstantUnion::traverse(TIntermTraverser* it)
|
||||
{
|
||||
if (it->visitConstantUnion)
|
||||
it->visitConstantUnion(this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a binary node.
|
||||
//
|
||||
void TIntermBinary::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
//
|
||||
// visit the node before children if pre-visiting.
|
||||
//
|
||||
if (it->preVisit && it->visitBinary)
|
||||
visit = it->visitBinary(true, this, it);
|
||||
|
||||
//
|
||||
// Visit the children, in the right order.
|
||||
//
|
||||
if (visit)
|
||||
{
|
||||
++it->depth;
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (right)
|
||||
right->traverse(it);
|
||||
if (left)
|
||||
left->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (left)
|
||||
left->traverse(it);
|
||||
if (right)
|
||||
right->traverse(it);
|
||||
}
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
//
|
||||
// Visit the node after the children, if requested and the traversal
|
||||
// hasn't been cancelled yet.
|
||||
//
|
||||
if (visit && it->postVisit && it->visitBinary)
|
||||
it->visitBinary(false, this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a unary node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermUnary::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit && it->visitUnary)
|
||||
visit = it->visitUnary(true, this, it);
|
||||
|
||||
if (visit)
|
||||
{
|
||||
++it->depth;
|
||||
operand->traverse(it);
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
if (visit && it->postVisit && it->visitUnary)
|
||||
it->visitUnary(false, this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse an aggregate node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermAggregate::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit && it->visitAggregate)
|
||||
visit = it->visitAggregate(true, this, it);
|
||||
|
||||
if (visit)
|
||||
{
|
||||
++it->depth;
|
||||
|
||||
TIntermSequence::iterator sit;
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
sit = sequence.end();
|
||||
while (sit != sequence.begin())
|
||||
{
|
||||
--sit;
|
||||
(*sit)->traverse(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (sit = sequence.begin(); sit != sequence.end(); ++sit)
|
||||
(*sit)->traverse(it);
|
||||
}
|
||||
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
if (visit && it->postVisit && it->visitAggregate)
|
||||
it->visitAggregate(false, this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a selection node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermSelection::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit && it->visitSelection)
|
||||
visit = it->visitSelection(true, this, it);
|
||||
|
||||
if (visit)
|
||||
{
|
||||
++it->depth;
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (falseBlock)
|
||||
falseBlock->traverse(it);
|
||||
if (trueBlock)
|
||||
trueBlock->traverse(it);
|
||||
condition->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
condition->traverse(it);
|
||||
if (trueBlock)
|
||||
trueBlock->traverse(it);
|
||||
if (falseBlock)
|
||||
falseBlock->traverse(it);
|
||||
}
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
if (visit && it->postVisit && it->visitSelection)
|
||||
it->visitSelection(false, this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a loop node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermLoop::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit && it->visitLoop)
|
||||
visit = it->visitLoop(true, this, it);
|
||||
|
||||
if (visit)
|
||||
{
|
||||
++it->depth;
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (terminal)
|
||||
terminal->traverse(it);
|
||||
if (body)
|
||||
body->traverse(it);
|
||||
if (test)
|
||||
test->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (test)
|
||||
test->traverse(it);
|
||||
if (body)
|
||||
body->traverse(it);
|
||||
if (terminal)
|
||||
terminal->traverse(it);
|
||||
}
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
if (visit && it->postVisit && it->visitLoop)
|
||||
it->visitLoop(false, this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a branch node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermBranch::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit && it->visitBranch)
|
||||
visit = it->visitBranch(true, this, it);
|
||||
|
||||
if (visit && expression)
|
||||
{
|
||||
++it->depth;
|
||||
expression->traverse(it);
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
if (visit && it->postVisit && it->visitBranch)
|
||||
it->visitBranch(false, this, it);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "../Include/intermediate.h"
|
||||
|
||||
//
|
||||
// Traverse the intermediate representation tree, and
|
||||
// call a node type specific function for each node.
|
||||
// Done recursively through the member function Traverse().
|
||||
// Node types can be skipped if their function to call is 0,
|
||||
// but their subtree will still be traversed.
|
||||
// Nodes with children can have their whole subtree skipped
|
||||
// if preVisit is turned on and the type specific function
|
||||
// returns false.
|
||||
//
|
||||
// preVisit, postVisit, and rightToLeft control what order
|
||||
// nodes are visited in.
|
||||
//
|
||||
|
||||
//
|
||||
// Traversal functions for terminals are straighforward....
|
||||
//
|
||||
void TIntermSymbol::traverse(TIntermTraverser* it)
|
||||
{
|
||||
if (it->visitSymbol)
|
||||
it->visitSymbol(this, it);
|
||||
}
|
||||
|
||||
void TIntermConstantUnion::traverse(TIntermTraverser* it)
|
||||
{
|
||||
if (it->visitConstantUnion)
|
||||
it->visitConstantUnion(this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a binary node.
|
||||
//
|
||||
void TIntermBinary::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
//
|
||||
// visit the node before children if pre-visiting.
|
||||
//
|
||||
if (it->preVisit && it->visitBinary)
|
||||
visit = it->visitBinary(true, this, it);
|
||||
|
||||
//
|
||||
// Visit the children, in the right order.
|
||||
//
|
||||
if (visit)
|
||||
{
|
||||
++it->depth;
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (right)
|
||||
right->traverse(it);
|
||||
if (left)
|
||||
left->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (left)
|
||||
left->traverse(it);
|
||||
if (right)
|
||||
right->traverse(it);
|
||||
}
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
//
|
||||
// Visit the node after the children, if requested and the traversal
|
||||
// hasn't been cancelled yet.
|
||||
//
|
||||
if (visit && it->postVisit && it->visitBinary)
|
||||
it->visitBinary(false, this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a unary node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermUnary::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit && it->visitUnary)
|
||||
visit = it->visitUnary(true, this, it);
|
||||
|
||||
if (visit)
|
||||
{
|
||||
++it->depth;
|
||||
operand->traverse(it);
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
if (visit && it->postVisit && it->visitUnary)
|
||||
it->visitUnary(false, this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse an aggregate node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermAggregate::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit && it->visitAggregate)
|
||||
visit = it->visitAggregate(true, this, it);
|
||||
|
||||
if (visit)
|
||||
{
|
||||
++it->depth;
|
||||
|
||||
TIntermSequence::iterator sit;
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
sit = sequence.end();
|
||||
while (sit != sequence.begin())
|
||||
{
|
||||
--sit;
|
||||
(*sit)->traverse(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (sit = sequence.begin(); sit != sequence.end(); ++sit)
|
||||
(*sit)->traverse(it);
|
||||
}
|
||||
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
if (visit && it->postVisit && it->visitAggregate)
|
||||
it->visitAggregate(false, this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a selection node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermSelection::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit && it->visitSelection)
|
||||
visit = it->visitSelection(true, this, it);
|
||||
|
||||
if (visit)
|
||||
{
|
||||
++it->depth;
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (falseBlock)
|
||||
falseBlock->traverse(it);
|
||||
if (trueBlock)
|
||||
trueBlock->traverse(it);
|
||||
condition->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
condition->traverse(it);
|
||||
if (trueBlock)
|
||||
trueBlock->traverse(it);
|
||||
if (falseBlock)
|
||||
falseBlock->traverse(it);
|
||||
}
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
if (visit && it->postVisit && it->visitSelection)
|
||||
it->visitSelection(false, this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a loop node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermLoop::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit && it->visitLoop)
|
||||
visit = it->visitLoop(true, this, it);
|
||||
|
||||
if (visit)
|
||||
{
|
||||
++it->depth;
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (terminal)
|
||||
terminal->traverse(it);
|
||||
if (body)
|
||||
body->traverse(it);
|
||||
if (test)
|
||||
test->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (test)
|
||||
test->traverse(it);
|
||||
if (body)
|
||||
body->traverse(it);
|
||||
if (terminal)
|
||||
terminal->traverse(it);
|
||||
}
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
if (visit && it->postVisit && it->visitLoop)
|
||||
it->visitLoop(false, this, it);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a branch node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermBranch::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit && it->visitBranch)
|
||||
visit = it->visitBranch(true, this, it);
|
||||
|
||||
if (visit && expression)
|
||||
{
|
||||
++it->depth;
|
||||
expression->traverse(it);
|
||||
--it->depth;
|
||||
}
|
||||
|
||||
if (visit && it->postVisit && it->visitBranch)
|
||||
it->visitBranch(false, this, it);
|
||||
}
|
||||
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,129 +1,129 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef _MMAP_INCLUDED_
|
||||
#define _MMAP_INCLUDED_
|
||||
|
||||
//
|
||||
// Encapsulate memory mapped files
|
||||
//
|
||||
|
||||
class TMMap
|
||||
{
|
||||
public:
|
||||
TMMap(const char* fileName) :
|
||||
fSize(-1), // -1 is the error value returned by GetFileSize()
|
||||
fp(NULL),
|
||||
fBuff(0) // 0 is the error value returned by MapViewOfFile()
|
||||
{
|
||||
if ((fp = fopen(fileName, "r")) == NULL)
|
||||
return;
|
||||
char c = getc(fp);
|
||||
fSize = 0;
|
||||
while (c != EOF)
|
||||
{
|
||||
fSize++;
|
||||
c = getc(fp);
|
||||
}
|
||||
if (c == EOF)
|
||||
fSize++;
|
||||
rewind(fp);
|
||||
fBuff = (char*)malloc(sizeof(char) * fSize);
|
||||
int count = 0;
|
||||
c = getc(fp);
|
||||
while (c != EOF)
|
||||
{
|
||||
fBuff[count++] = c;
|
||||
c = getc(fp);
|
||||
}
|
||||
fBuff[count++] = c;
|
||||
}
|
||||
|
||||
char* getData()
|
||||
{
|
||||
return fBuff;
|
||||
}
|
||||
int getSize()
|
||||
{
|
||||
return fSize;
|
||||
}
|
||||
|
||||
~TMMap()
|
||||
{
|
||||
if (fp != NULL)
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
private:
|
||||
int fSize; // size of file to map in
|
||||
FILE *fp;
|
||||
char* fBuff; // the actual data;
|
||||
};
|
||||
|
||||
#endif // _MMAP_INCLUDED_
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef _MMAP_INCLUDED_
|
||||
#define _MMAP_INCLUDED_
|
||||
|
||||
//
|
||||
// Encapsulate memory mapped files
|
||||
//
|
||||
|
||||
class TMMap
|
||||
{
|
||||
public:
|
||||
TMMap(const char* fileName) :
|
||||
fSize(-1), // -1 is the error value returned by GetFileSize()
|
||||
fp(NULL),
|
||||
fBuff(0) // 0 is the error value returned by MapViewOfFile()
|
||||
{
|
||||
if ((fp = fopen(fileName, "r")) == NULL)
|
||||
return;
|
||||
char c = getc(fp);
|
||||
fSize = 0;
|
||||
while (c != EOF)
|
||||
{
|
||||
fSize++;
|
||||
c = getc(fp);
|
||||
}
|
||||
if (c == EOF)
|
||||
fSize++;
|
||||
rewind(fp);
|
||||
fBuff = (char*)malloc(sizeof(char) * fSize);
|
||||
int count = 0;
|
||||
c = getc(fp);
|
||||
while (c != EOF)
|
||||
{
|
||||
fBuff[count++] = c;
|
||||
c = getc(fp);
|
||||
}
|
||||
fBuff[count++] = c;
|
||||
}
|
||||
|
||||
char* getData()
|
||||
{
|
||||
return fBuff;
|
||||
}
|
||||
int getSize()
|
||||
{
|
||||
return fSize;
|
||||
}
|
||||
|
||||
~TMMap()
|
||||
{
|
||||
if (fp != NULL)
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
private:
|
||||
int fSize; // size of file to map in
|
||||
FILE *fp;
|
||||
char* fBuff; // the actual data;
|
||||
};
|
||||
|
||||
#endif // _MMAP_INCLUDED_
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,203 +1,203 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef _PARSER_HELPER_INCLUDED_
|
||||
#define _PARSER_HELPER_INCLUDED_
|
||||
|
||||
#include "../Include/ShHandle.h"
|
||||
#include "SymbolTable.h"
|
||||
#include "localintermediate.h"
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EBhRequire,
|
||||
EBhEnable,
|
||||
EBhWarn,
|
||||
EBhDisable
|
||||
} TBehavior;
|
||||
|
||||
struct TPragma
|
||||
{
|
||||
TPragma(bool o, bool d) : optimize(o), debug(d)
|
||||
{
|
||||
}
|
||||
bool optimize;
|
||||
bool debug;
|
||||
TPragmaTable pragmaTable;
|
||||
};
|
||||
|
||||
//
|
||||
// The following are extra variables needed during parsing, grouped together so
|
||||
// they can be passed to the parser without needing a global.
|
||||
//
|
||||
struct TParseContext
|
||||
{
|
||||
TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage L, TInfoSink& is) :
|
||||
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0),
|
||||
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
|
||||
inTypeParen(false), contextPragma(true, false)
|
||||
{
|
||||
}
|
||||
TIntermediate& intermediate; // to hold and build a parse tree
|
||||
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
|
||||
TInfoSink& infoSink;
|
||||
EShLanguage language; // vertex or fragment language (future: pack or unpack)
|
||||
TIntermNode* treeRoot; // root of parse tree being created
|
||||
bool recoveredFromError; // true if a parse error has occurred, but we continue to parse
|
||||
int numErrors;
|
||||
bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier
|
||||
int loopNestingLevel; // 0 if outside all loops
|
||||
bool inTypeParen; // true if in parentheses, looking only for an identifier
|
||||
const TType* currentFunctionType; // the return type of the function that's currently being parsed
|
||||
bool functionReturnsValue; // true if a non-void function has a return
|
||||
|
||||
#ifdef _WIN32
|
||||
TMap<TString, TBehavior> extensionBehavior;
|
||||
#else
|
||||
TMap<const TString, TBehavior> extensionBehavior;
|
||||
#endif
|
||||
|
||||
void initializeExtensionBehavior();
|
||||
|
||||
void C_DECL error(TSourceLoc, const char *szReason, const char *szToken,
|
||||
const char *szExtraInfoFormat, ...);
|
||||
bool reservedErrorCheck(int line, const TString& identifier);
|
||||
void recover();
|
||||
|
||||
bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line);
|
||||
bool parseMatrixFields(const TString&, int matSize, TVectorFields&, int line);
|
||||
void assignError(int line, const char* op, TString left, TString right);
|
||||
void unaryOpError(int line, char* op, TString operand);
|
||||
void binaryOpError(int line, char* op, TString left, TString right);
|
||||
bool lValueErrorCheck(int line, char* op, TIntermTyped*);
|
||||
bool constErrorCheck(TIntermTyped* node);
|
||||
bool integerErrorCheck(TIntermTyped* node, char* token);
|
||||
bool globalErrorCheck(int line, bool global, char* token);
|
||||
bool constructorErrorCheck(int line, TIntermNode*, TFunction&, TOperator, TType*);
|
||||
bool arraySizeErrorCheck(int line, TIntermTyped* expr, int& size);
|
||||
bool arrayQualifierErrorCheck(int line, TPublicType type);
|
||||
bool arrayTypeErrorCheck(int line, TPublicType type);
|
||||
bool arrayErrorCheck(int line, TString& identifier, TPublicType type, TVariable*& variable);
|
||||
bool arrayErrorCheck(int line, TString& identifier, const TTypeInfo *info, TPublicType type, TVariable*& variable);
|
||||
bool insertBuiltInArrayAtGlobalLevel();
|
||||
bool voidErrorCheck(int, const TString&, const TPublicType&);
|
||||
bool boolErrorCheck(int, const TIntermTyped*);
|
||||
bool boolErrorCheck(int, const TPublicType&);
|
||||
bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason);
|
||||
bool structQualifierErrorCheck(int line, const TPublicType& pType);
|
||||
bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type);
|
||||
bool containsSampler(TType& type);
|
||||
bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type);
|
||||
bool nonInitErrorCheck(int line, TString& identifier, const TTypeInfo *info, TPublicType& type);
|
||||
bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type);
|
||||
bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
|
||||
bool extensionErrorCheck(int line, const char*);
|
||||
const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);
|
||||
bool executeInitializer(TSourceLoc line, TString& identifier, const TTypeInfo *info, TPublicType& pType,
|
||||
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
|
||||
bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
|
||||
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
|
||||
bool areAllChildConst(TIntermAggregate* aggrNode);
|
||||
TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, TSourceLoc);
|
||||
TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type);
|
||||
TIntermTyped* constructArray(TIntermAggregate*, const TType*, TOperator, TSourceLoc);
|
||||
TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset);
|
||||
TIntermTyped* constructBuiltIn(const TType*, TOperator, TIntermNode*, TSourceLoc, bool subset);
|
||||
TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc);
|
||||
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
|
||||
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
|
||||
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
|
||||
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||
TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TSymbolTable&);
|
||||
TIntermAggregate* mergeAggregates( TIntermAggregate *left, TIntermAggregate *right);
|
||||
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
|
||||
TOperator getConstructorOp( const TType&);
|
||||
TIntermNode* promoteFunctionArguments( TIntermNode *node, const TFunction* func);
|
||||
struct TPragma contextPragma;
|
||||
TString HashErrMsg;
|
||||
bool AfterEOF;
|
||||
};
|
||||
|
||||
int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&);
|
||||
void PaReservedWord();
|
||||
int PaIdentOrType(TString& id, TParseContext&, TSymbol*&);
|
||||
int PaParseComment(int &lineno, TParseContext&);
|
||||
void setInitialState();
|
||||
|
||||
typedef TParseContext* TParseContextPointer;
|
||||
extern TParseContextPointer& GetGlobalParseContext();
|
||||
#define GlobalParseContext GetGlobalParseContext()
|
||||
|
||||
typedef struct TThreadParseContextRec
|
||||
{
|
||||
TParseContext *lpGlobalParseContext;
|
||||
} TThreadParseContext;
|
||||
|
||||
#endif // _PARSER_HELPER_INCLUDED_
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef _PARSER_HELPER_INCLUDED_
|
||||
#define _PARSER_HELPER_INCLUDED_
|
||||
|
||||
#include "../Include/ShHandle.h"
|
||||
#include "SymbolTable.h"
|
||||
#include "localintermediate.h"
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EBhRequire,
|
||||
EBhEnable,
|
||||
EBhWarn,
|
||||
EBhDisable
|
||||
} TBehavior;
|
||||
|
||||
struct TPragma
|
||||
{
|
||||
TPragma(bool o, bool d) : optimize(o), debug(d)
|
||||
{
|
||||
}
|
||||
bool optimize;
|
||||
bool debug;
|
||||
TPragmaTable pragmaTable;
|
||||
};
|
||||
|
||||
//
|
||||
// The following are extra variables needed during parsing, grouped together so
|
||||
// they can be passed to the parser without needing a global.
|
||||
//
|
||||
struct TParseContext
|
||||
{
|
||||
TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage L, TInfoSink& is) :
|
||||
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0),
|
||||
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
|
||||
inTypeParen(false), contextPragma(true, false)
|
||||
{
|
||||
}
|
||||
TIntermediate& intermediate; // to hold and build a parse tree
|
||||
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
|
||||
TInfoSink& infoSink;
|
||||
EShLanguage language; // vertex or fragment language (future: pack or unpack)
|
||||
TIntermNode* treeRoot; // root of parse tree being created
|
||||
bool recoveredFromError; // true if a parse error has occurred, but we continue to parse
|
||||
int numErrors;
|
||||
bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier
|
||||
int loopNestingLevel; // 0 if outside all loops
|
||||
bool inTypeParen; // true if in parentheses, looking only for an identifier
|
||||
const TType* currentFunctionType; // the return type of the function that's currently being parsed
|
||||
bool functionReturnsValue; // true if a non-void function has a return
|
||||
|
||||
#ifdef _WIN32
|
||||
TMap<TString, TBehavior> extensionBehavior;
|
||||
#else
|
||||
TMap<const TString, TBehavior> extensionBehavior;
|
||||
#endif
|
||||
|
||||
void initializeExtensionBehavior();
|
||||
|
||||
void C_DECL error(TSourceLoc, const char *szReason, const char *szToken,
|
||||
const char *szExtraInfoFormat, ...);
|
||||
bool reservedErrorCheck(int line, const TString& identifier);
|
||||
void recover();
|
||||
|
||||
bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line);
|
||||
bool parseMatrixFields(const TString&, int matSize, TVectorFields&, int line);
|
||||
void assignError(int line, const char* op, TString left, TString right);
|
||||
void unaryOpError(int line, char* op, TString operand);
|
||||
void binaryOpError(int line, char* op, TString left, TString right);
|
||||
bool lValueErrorCheck(int line, char* op, TIntermTyped*);
|
||||
bool constErrorCheck(TIntermTyped* node);
|
||||
bool integerErrorCheck(TIntermTyped* node, char* token);
|
||||
bool globalErrorCheck(int line, bool global, char* token);
|
||||
bool constructorErrorCheck(int line, TIntermNode*, TFunction&, TOperator, TType*);
|
||||
bool arraySizeErrorCheck(int line, TIntermTyped* expr, int& size);
|
||||
bool arrayQualifierErrorCheck(int line, TPublicType type);
|
||||
bool arrayTypeErrorCheck(int line, TPublicType type);
|
||||
bool arrayErrorCheck(int line, TString& identifier, TPublicType type, TVariable*& variable);
|
||||
bool arrayErrorCheck(int line, TString& identifier, const TTypeInfo *info, TPublicType type, TVariable*& variable);
|
||||
bool insertBuiltInArrayAtGlobalLevel();
|
||||
bool voidErrorCheck(int, const TString&, const TPublicType&);
|
||||
bool boolErrorCheck(int, const TIntermTyped*);
|
||||
bool boolErrorCheck(int, const TPublicType&);
|
||||
bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason);
|
||||
bool structQualifierErrorCheck(int line, const TPublicType& pType);
|
||||
bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type);
|
||||
bool containsSampler(TType& type);
|
||||
bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type);
|
||||
bool nonInitErrorCheck(int line, TString& identifier, const TTypeInfo *info, TPublicType& type);
|
||||
bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type);
|
||||
bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
|
||||
bool extensionErrorCheck(int line, const char*);
|
||||
const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);
|
||||
bool executeInitializer(TSourceLoc line, TString& identifier, const TTypeInfo *info, TPublicType& pType,
|
||||
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
|
||||
bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
|
||||
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
|
||||
bool areAllChildConst(TIntermAggregate* aggrNode);
|
||||
TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, TSourceLoc);
|
||||
TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type);
|
||||
TIntermTyped* constructArray(TIntermAggregate*, const TType*, TOperator, TSourceLoc);
|
||||
TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset);
|
||||
TIntermTyped* constructBuiltIn(const TType*, TOperator, TIntermNode*, TSourceLoc, bool subset);
|
||||
TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc);
|
||||
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
|
||||
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
|
||||
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
|
||||
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||
TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TSymbolTable&);
|
||||
TIntermAggregate* mergeAggregates( TIntermAggregate *left, TIntermAggregate *right);
|
||||
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
|
||||
TOperator getConstructorOp( const TType&);
|
||||
TIntermNode* promoteFunctionArguments( TIntermNode *node, const TFunction* func);
|
||||
struct TPragma contextPragma;
|
||||
TString HashErrMsg;
|
||||
bool AfterEOF;
|
||||
};
|
||||
|
||||
int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&);
|
||||
void PaReservedWord();
|
||||
int PaIdentOrType(TString& id, TParseContext&, TSymbol*&);
|
||||
int PaParseComment(int &lineno, TParseContext&);
|
||||
void setInitialState();
|
||||
|
||||
typedef TParseContext* TParseContextPointer;
|
||||
extern TParseContextPointer& GetGlobalParseContext();
|
||||
#define GlobalParseContext GetGlobalParseContext()
|
||||
|
||||
typedef struct TThreadParseContextRec
|
||||
{
|
||||
TParseContext *lpGlobalParseContext;
|
||||
} TThreadParseContext;
|
||||
|
||||
#endif // _PARSER_HELPER_INCLUDED_
|
||||
|
||||
|
|
|
@ -1,390 +1,390 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "../Include/PoolAlloc.h"
|
||||
#include "../Include/Common.h"
|
||||
|
||||
#include "../Include/InitializeGlobals.h"
|
||||
#include "osinclude.h"
|
||||
|
||||
OS_TLSIndex PoolIndex;
|
||||
|
||||
void InitializeGlobalPools()
|
||||
{
|
||||
TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
|
||||
if (globalPools)
|
||||
return;
|
||||
|
||||
TPoolAllocator *globalPoolAllocator = new TPoolAllocator(true);
|
||||
|
||||
TThreadGlobalPools* threadData = new TThreadGlobalPools();
|
||||
|
||||
threadData->globalPoolAllocator = globalPoolAllocator;
|
||||
|
||||
OS_SetTLSValue(PoolIndex, threadData);
|
||||
globalPoolAllocator->push();
|
||||
}
|
||||
|
||||
void FreeGlobalPools()
|
||||
{
|
||||
// Release the allocated memory for this thread.
|
||||
TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
|
||||
if (!globalPools)
|
||||
return;
|
||||
|
||||
GlobalPoolAllocator.popAll();
|
||||
delete &GlobalPoolAllocator;
|
||||
delete globalPools;
|
||||
}
|
||||
|
||||
bool InitializePoolIndex()
|
||||
{
|
||||
// Allocate a TLS index.
|
||||
if ((PoolIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FreePoolIndex()
|
||||
{
|
||||
// Release the TLS index.
|
||||
OS_FreeTLSIndex(PoolIndex);
|
||||
}
|
||||
|
||||
TPoolAllocator& GetGlobalPoolAllocator()
|
||||
{
|
||||
TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
|
||||
|
||||
return *threadData->globalPoolAllocator;
|
||||
}
|
||||
|
||||
void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator)
|
||||
{
|
||||
TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
|
||||
|
||||
threadData->globalPoolAllocator = poolAllocator;
|
||||
}
|
||||
|
||||
//
|
||||
// Implement the functionality of the TPoolAllocator class, which
|
||||
// is documented in PoolAlloc.h.
|
||||
//
|
||||
TPoolAllocator::TPoolAllocator(bool g, int growthIncrement, int allocationAlignment) :
|
||||
global(g),
|
||||
pageSize(growthIncrement),
|
||||
alignment(allocationAlignment),
|
||||
freeList(0),
|
||||
inUseList(0),
|
||||
numCalls(0)
|
||||
{
|
||||
//
|
||||
// Don't allow page sizes we know are smaller than all common
|
||||
// OS page sizes.
|
||||
//
|
||||
if (pageSize < 4*1024)
|
||||
pageSize = 4*1024;
|
||||
|
||||
//
|
||||
// A large currentPageOffset indicates a new page needs to
|
||||
// be obtained to allocate memory.
|
||||
//
|
||||
currentPageOffset = pageSize;
|
||||
|
||||
//
|
||||
// Adjust alignment to be at least pointer aligned and
|
||||
// power of 2.
|
||||
//
|
||||
size_t minAlign = sizeof(void*);
|
||||
alignment &= ~(minAlign - 1);
|
||||
if (alignment < minAlign)
|
||||
alignment = minAlign;
|
||||
size_t a = 1;
|
||||
while (a < alignment)
|
||||
a <<= 1;
|
||||
alignment = a;
|
||||
alignmentMask = a - 1;
|
||||
|
||||
//
|
||||
// Align header skip
|
||||
//
|
||||
headerSkip = minAlign;
|
||||
if (headerSkip < sizeof(tHeader))
|
||||
{
|
||||
headerSkip = (sizeof(tHeader) + alignmentMask) & ~alignmentMask;
|
||||
}
|
||||
}
|
||||
|
||||
TPoolAllocator::~TPoolAllocator()
|
||||
{
|
||||
if (!global)
|
||||
{
|
||||
//
|
||||
// Then we know that this object is not being
|
||||
// allocated after other, globally scoped objects
|
||||
// that depend on it. So we can delete the "in use" memory.
|
||||
//
|
||||
while (inUseList)
|
||||
{
|
||||
tHeader* next = inUseList->nextPage;
|
||||
inUseList->~tHeader();
|
||||
delete [] reinterpret_cast<char*>(inUseList);
|
||||
inUseList = next;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Always delete the free list memory - it can't be being
|
||||
// (correctly) referenced, whether the pool allocator was
|
||||
// global or not. We should not check the guard blocks
|
||||
// here, because we did it already when the block was
|
||||
// placed into the free list.
|
||||
//
|
||||
while (freeList)
|
||||
{
|
||||
tHeader* next = freeList->nextPage;
|
||||
delete [] reinterpret_cast<char*>(freeList);
|
||||
freeList = next;
|
||||
}
|
||||
}
|
||||
|
||||
// Support MSVC++ 6.0
|
||||
const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
|
||||
const unsigned char TAllocation::guardBlockEndVal = 0xfe;
|
||||
const unsigned char TAllocation::userDataFill = 0xcd;
|
||||
|
||||
#ifdef GUARD_BLOCKS
|
||||
const size_t TAllocation::guardBlockSize = 16;
|
||||
#else
|
||||
const size_t TAllocation::guardBlockSize = 0;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Check a single guard block for damage
|
||||
//
|
||||
void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, char* locText) const
|
||||
{
|
||||
for (int x = 0; x < guardBlockSize; x++)
|
||||
{
|
||||
if (blockMem[x] != val)
|
||||
{
|
||||
char assertMsg[80];
|
||||
|
||||
// We don't print the assert message. It's here just to be helpful.
|
||||
sprintf(assertMsg, "PoolAlloc: Damage %s %lu byte allocation at 0x%p\n",
|
||||
locText, size, data());
|
||||
assert(0 && "PoolAlloc: Damage in guard block");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TPoolAllocator::push()
|
||||
{
|
||||
tAllocState state = { currentPageOffset, inUseList};
|
||||
|
||||
stack.push_back(state);
|
||||
|
||||
//
|
||||
// Indicate there is no current page to allocate from.
|
||||
//
|
||||
currentPageOffset = pageSize;
|
||||
}
|
||||
|
||||
//
|
||||
// Do a mass-deallocation of all the individual allocations
|
||||
// that have occurred since the last push(), or since the
|
||||
// last pop(), or since the object's creation.
|
||||
//
|
||||
// The deallocated pages are saved for future allocations.
|
||||
//
|
||||
void TPoolAllocator::pop()
|
||||
{
|
||||
if (stack.size() < 1)
|
||||
return;
|
||||
|
||||
tHeader* page = stack.back().page;
|
||||
currentPageOffset = stack.back().offset;
|
||||
|
||||
while (inUseList != page)
|
||||
{
|
||||
// invoke destructor to free allocation list
|
||||
inUseList->~tHeader();
|
||||
|
||||
tHeader* nextInUse = inUseList->nextPage;
|
||||
if (inUseList->pageCount > 1)
|
||||
delete [] reinterpret_cast<char*>(inUseList);
|
||||
else
|
||||
{
|
||||
inUseList->nextPage = freeList;
|
||||
freeList = inUseList;
|
||||
}
|
||||
inUseList = nextInUse;
|
||||
}
|
||||
|
||||
stack.pop_back();
|
||||
}
|
||||
|
||||
//
|
||||
// Do a mass-deallocation of all the individual allocations
|
||||
// that have occurred.
|
||||
//
|
||||
void TPoolAllocator::popAll()
|
||||
{
|
||||
while (stack.size() > 0)
|
||||
pop();
|
||||
}
|
||||
|
||||
void* TPoolAllocator::allocate(size_t numBytes)
|
||||
{
|
||||
// If we are using guard blocks, all allocations are bracketed by
|
||||
// them: [guardblock][allocation][guardblock]. numBytes is how
|
||||
// much memory the caller asked for. allocationSize is the total
|
||||
// size including guard blocks. In release build,
|
||||
// guardBlockSize=0 and this all gets optimized away.
|
||||
size_t allocationSize = TAllocation::allocationSize(numBytes);
|
||||
|
||||
//
|
||||
// Just keep some interesting statistics.
|
||||
//
|
||||
++numCalls;
|
||||
totalBytes += numBytes;
|
||||
|
||||
//
|
||||
// Do the allocation, most likely case first, for efficiency.
|
||||
// This step could be moved to be inline sometime.
|
||||
//
|
||||
if (currentPageOffset + allocationSize <= pageSize)
|
||||
{
|
||||
//
|
||||
// Safe to allocate from currentPageOffset.
|
||||
//
|
||||
unsigned char* memory = reinterpret_cast<unsigned char *>(inUseList) + currentPageOffset;
|
||||
currentPageOffset += allocationSize;
|
||||
currentPageOffset = (currentPageOffset + alignmentMask) & ~alignmentMask;
|
||||
|
||||
return initializeAllocation(inUseList, memory, numBytes);
|
||||
}
|
||||
|
||||
if (allocationSize + headerSkip > pageSize)
|
||||
{
|
||||
//
|
||||
// Do a multi-page allocation. Don't mix these with the others.
|
||||
// The OS is efficient and allocating and free-ing multiple pages.
|
||||
//
|
||||
size_t numBytesToAlloc = allocationSize + headerSkip;
|
||||
tHeader* memory = reinterpret_cast<tHeader*>(::new char[numBytesToAlloc]);
|
||||
if (memory == 0)
|
||||
return 0;
|
||||
|
||||
// Use placement-new to initialize header
|
||||
new(memory) tHeader(inUseList, (numBytesToAlloc + pageSize - 1) / pageSize);
|
||||
inUseList = memory;
|
||||
|
||||
currentPageOffset = pageSize; // make next allocation come from a new page
|
||||
|
||||
// No guard blocks for multi-page allocations (yet)
|
||||
return reinterpret_cast<void*>(reinterpret_cast<UINT_PTR>(memory) + headerSkip);
|
||||
}
|
||||
|
||||
//
|
||||
// Need a simple page to allocate from.
|
||||
//
|
||||
tHeader* memory;
|
||||
if (freeList)
|
||||
{
|
||||
memory = freeList;
|
||||
freeList = freeList->nextPage;
|
||||
}
|
||||
else
|
||||
{
|
||||
memory = reinterpret_cast<tHeader*>(::new char[pageSize]);
|
||||
if (memory == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Use placement-new to initialize header
|
||||
new(memory) tHeader(inUseList, 1);
|
||||
inUseList = memory;
|
||||
|
||||
unsigned char* ret = reinterpret_cast<unsigned char *>(inUseList) + headerSkip;
|
||||
currentPageOffset = (headerSkip + allocationSize + alignmentMask) & ~alignmentMask;
|
||||
|
||||
return initializeAllocation(inUseList, ret, numBytes);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Check all allocations in a list for damage by calling check on each.
|
||||
//
|
||||
void TAllocation::checkAllocList() const
|
||||
{
|
||||
for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
|
||||
alloc->GB_check();
|
||||
}
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "../Include/PoolAlloc.h"
|
||||
#include "../Include/Common.h"
|
||||
|
||||
#include "../Include/InitializeGlobals.h"
|
||||
#include "osinclude.h"
|
||||
|
||||
OS_TLSIndex PoolIndex;
|
||||
|
||||
void InitializeGlobalPools()
|
||||
{
|
||||
TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
|
||||
if (globalPools)
|
||||
return;
|
||||
|
||||
TPoolAllocator *globalPoolAllocator = new TPoolAllocator(true);
|
||||
|
||||
TThreadGlobalPools* threadData = new TThreadGlobalPools();
|
||||
|
||||
threadData->globalPoolAllocator = globalPoolAllocator;
|
||||
|
||||
OS_SetTLSValue(PoolIndex, threadData);
|
||||
globalPoolAllocator->push();
|
||||
}
|
||||
|
||||
void FreeGlobalPools()
|
||||
{
|
||||
// Release the allocated memory for this thread.
|
||||
TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
|
||||
if (!globalPools)
|
||||
return;
|
||||
|
||||
GlobalPoolAllocator.popAll();
|
||||
delete &GlobalPoolAllocator;
|
||||
delete globalPools;
|
||||
}
|
||||
|
||||
bool InitializePoolIndex()
|
||||
{
|
||||
// Allocate a TLS index.
|
||||
if ((PoolIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FreePoolIndex()
|
||||
{
|
||||
// Release the TLS index.
|
||||
OS_FreeTLSIndex(PoolIndex);
|
||||
}
|
||||
|
||||
TPoolAllocator& GetGlobalPoolAllocator()
|
||||
{
|
||||
TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
|
||||
|
||||
return *threadData->globalPoolAllocator;
|
||||
}
|
||||
|
||||
void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator)
|
||||
{
|
||||
TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
|
||||
|
||||
threadData->globalPoolAllocator = poolAllocator;
|
||||
}
|
||||
|
||||
//
|
||||
// Implement the functionality of the TPoolAllocator class, which
|
||||
// is documented in PoolAlloc.h.
|
||||
//
|
||||
TPoolAllocator::TPoolAllocator(bool g, int growthIncrement, int allocationAlignment) :
|
||||
global(g),
|
||||
pageSize(growthIncrement),
|
||||
alignment(allocationAlignment),
|
||||
freeList(0),
|
||||
inUseList(0),
|
||||
numCalls(0)
|
||||
{
|
||||
//
|
||||
// Don't allow page sizes we know are smaller than all common
|
||||
// OS page sizes.
|
||||
//
|
||||
if (pageSize < 4*1024)
|
||||
pageSize = 4*1024;
|
||||
|
||||
//
|
||||
// A large currentPageOffset indicates a new page needs to
|
||||
// be obtained to allocate memory.
|
||||
//
|
||||
currentPageOffset = pageSize;
|
||||
|
||||
//
|
||||
// Adjust alignment to be at least pointer aligned and
|
||||
// power of 2.
|
||||
//
|
||||
size_t minAlign = sizeof(void*);
|
||||
alignment &= ~(minAlign - 1);
|
||||
if (alignment < minAlign)
|
||||
alignment = minAlign;
|
||||
size_t a = 1;
|
||||
while (a < alignment)
|
||||
a <<= 1;
|
||||
alignment = a;
|
||||
alignmentMask = a - 1;
|
||||
|
||||
//
|
||||
// Align header skip
|
||||
//
|
||||
headerSkip = minAlign;
|
||||
if (headerSkip < sizeof(tHeader))
|
||||
{
|
||||
headerSkip = (sizeof(tHeader) + alignmentMask) & ~alignmentMask;
|
||||
}
|
||||
}
|
||||
|
||||
TPoolAllocator::~TPoolAllocator()
|
||||
{
|
||||
if (!global)
|
||||
{
|
||||
//
|
||||
// Then we know that this object is not being
|
||||
// allocated after other, globally scoped objects
|
||||
// that depend on it. So we can delete the "in use" memory.
|
||||
//
|
||||
while (inUseList)
|
||||
{
|
||||
tHeader* next = inUseList->nextPage;
|
||||
inUseList->~tHeader();
|
||||
delete [] reinterpret_cast<char*>(inUseList);
|
||||
inUseList = next;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Always delete the free list memory - it can't be being
|
||||
// (correctly) referenced, whether the pool allocator was
|
||||
// global or not. We should not check the guard blocks
|
||||
// here, because we did it already when the block was
|
||||
// placed into the free list.
|
||||
//
|
||||
while (freeList)
|
||||
{
|
||||
tHeader* next = freeList->nextPage;
|
||||
delete [] reinterpret_cast<char*>(freeList);
|
||||
freeList = next;
|
||||
}
|
||||
}
|
||||
|
||||
// Support MSVC++ 6.0
|
||||
const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
|
||||
const unsigned char TAllocation::guardBlockEndVal = 0xfe;
|
||||
const unsigned char TAllocation::userDataFill = 0xcd;
|
||||
|
||||
#ifdef GUARD_BLOCKS
|
||||
const size_t TAllocation::guardBlockSize = 16;
|
||||
#else
|
||||
const size_t TAllocation::guardBlockSize = 0;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Check a single guard block for damage
|
||||
//
|
||||
void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, char* locText) const
|
||||
{
|
||||
for (int x = 0; x < guardBlockSize; x++)
|
||||
{
|
||||
if (blockMem[x] != val)
|
||||
{
|
||||
char assertMsg[80];
|
||||
|
||||
// We don't print the assert message. It's here just to be helpful.
|
||||
sprintf(assertMsg, "PoolAlloc: Damage %s %lu byte allocation at 0x%p\n",
|
||||
locText, size, data());
|
||||
assert(0 && "PoolAlloc: Damage in guard block");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TPoolAllocator::push()
|
||||
{
|
||||
tAllocState state = { currentPageOffset, inUseList};
|
||||
|
||||
stack.push_back(state);
|
||||
|
||||
//
|
||||
// Indicate there is no current page to allocate from.
|
||||
//
|
||||
currentPageOffset = pageSize;
|
||||
}
|
||||
|
||||
//
|
||||
// Do a mass-deallocation of all the individual allocations
|
||||
// that have occurred since the last push(), or since the
|
||||
// last pop(), or since the object's creation.
|
||||
//
|
||||
// The deallocated pages are saved for future allocations.
|
||||
//
|
||||
void TPoolAllocator::pop()
|
||||
{
|
||||
if (stack.size() < 1)
|
||||
return;
|
||||
|
||||
tHeader* page = stack.back().page;
|
||||
currentPageOffset = stack.back().offset;
|
||||
|
||||
while (inUseList != page)
|
||||
{
|
||||
// invoke destructor to free allocation list
|
||||
inUseList->~tHeader();
|
||||
|
||||
tHeader* nextInUse = inUseList->nextPage;
|
||||
if (inUseList->pageCount > 1)
|
||||
delete [] reinterpret_cast<char*>(inUseList);
|
||||
else
|
||||
{
|
||||
inUseList->nextPage = freeList;
|
||||
freeList = inUseList;
|
||||
}
|
||||
inUseList = nextInUse;
|
||||
}
|
||||
|
||||
stack.pop_back();
|
||||
}
|
||||
|
||||
//
|
||||
// Do a mass-deallocation of all the individual allocations
|
||||
// that have occurred.
|
||||
//
|
||||
void TPoolAllocator::popAll()
|
||||
{
|
||||
while (stack.size() > 0)
|
||||
pop();
|
||||
}
|
||||
|
||||
void* TPoolAllocator::allocate(size_t numBytes)
|
||||
{
|
||||
// If we are using guard blocks, all allocations are bracketed by
|
||||
// them: [guardblock][allocation][guardblock]. numBytes is how
|
||||
// much memory the caller asked for. allocationSize is the total
|
||||
// size including guard blocks. In release build,
|
||||
// guardBlockSize=0 and this all gets optimized away.
|
||||
size_t allocationSize = TAllocation::allocationSize(numBytes);
|
||||
|
||||
//
|
||||
// Just keep some interesting statistics.
|
||||
//
|
||||
++numCalls;
|
||||
totalBytes += numBytes;
|
||||
|
||||
//
|
||||
// Do the allocation, most likely case first, for efficiency.
|
||||
// This step could be moved to be inline sometime.
|
||||
//
|
||||
if (currentPageOffset + allocationSize <= pageSize)
|
||||
{
|
||||
//
|
||||
// Safe to allocate from currentPageOffset.
|
||||
//
|
||||
unsigned char* memory = reinterpret_cast<unsigned char *>(inUseList) + currentPageOffset;
|
||||
currentPageOffset += allocationSize;
|
||||
currentPageOffset = (currentPageOffset + alignmentMask) & ~alignmentMask;
|
||||
|
||||
return initializeAllocation(inUseList, memory, numBytes);
|
||||
}
|
||||
|
||||
if (allocationSize + headerSkip > pageSize)
|
||||
{
|
||||
//
|
||||
// Do a multi-page allocation. Don't mix these with the others.
|
||||
// The OS is efficient and allocating and free-ing multiple pages.
|
||||
//
|
||||
size_t numBytesToAlloc = allocationSize + headerSkip;
|
||||
tHeader* memory = reinterpret_cast<tHeader*>(::new char[numBytesToAlloc]);
|
||||
if (memory == 0)
|
||||
return 0;
|
||||
|
||||
// Use placement-new to initialize header
|
||||
new(memory) tHeader(inUseList, (numBytesToAlloc + pageSize - 1) / pageSize);
|
||||
inUseList = memory;
|
||||
|
||||
currentPageOffset = pageSize; // make next allocation come from a new page
|
||||
|
||||
// No guard blocks for multi-page allocations (yet)
|
||||
return reinterpret_cast<void*>(reinterpret_cast<UINT_PTR>(memory) + headerSkip);
|
||||
}
|
||||
|
||||
//
|
||||
// Need a simple page to allocate from.
|
||||
//
|
||||
tHeader* memory;
|
||||
if (freeList)
|
||||
{
|
||||
memory = freeList;
|
||||
freeList = freeList->nextPage;
|
||||
}
|
||||
else
|
||||
{
|
||||
memory = reinterpret_cast<tHeader*>(::new char[pageSize]);
|
||||
if (memory == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Use placement-new to initialize header
|
||||
new(memory) tHeader(inUseList, 1);
|
||||
inUseList = memory;
|
||||
|
||||
unsigned char* ret = reinterpret_cast<unsigned char *>(inUseList) + headerSkip;
|
||||
currentPageOffset = (headerSkip + allocationSize + alignmentMask) & ~alignmentMask;
|
||||
|
||||
return initializeAllocation(inUseList, ret, numBytes);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Check all allocations in a list for damage by calling check on each.
|
||||
//
|
||||
void TAllocation::checkAllocList() const
|
||||
{
|
||||
for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
|
||||
alloc->GB_check();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,130 +1,130 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "../Include/intermediate.h"
|
||||
|
||||
class TAliveTraverser : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
TAliveTraverser(TQualifier q) : TIntermTraverser(), found(false), qualifier(q)
|
||||
{
|
||||
visitSymbol = AliveSymbol;
|
||||
visitSelection = AliveSelection;
|
||||
rightToLeft = true;
|
||||
}
|
||||
bool wasFound()
|
||||
{
|
||||
return found;
|
||||
}
|
||||
protected:
|
||||
bool found;
|
||||
TQualifier qualifier;
|
||||
|
||||
friend void AliveSymbol(TIntermSymbol*, TIntermTraverser*);
|
||||
friend bool AliveSelection(bool, TIntermSelection*, TIntermTraverser*);
|
||||
};
|
||||
|
||||
//
|
||||
// Report whether or not a variable of the given qualifier type
|
||||
// is guaranteed written. Not always possible to determine if
|
||||
// it is written conditionally.
|
||||
//
|
||||
// ?? It does not do this well yet, this is just a place holder
|
||||
// that simply determines if it was reference at all, anywhere.
|
||||
//
|
||||
bool QualifierWritten(TIntermNode* node, TQualifier qualifier)
|
||||
{
|
||||
TAliveTraverser it(qualifier);
|
||||
|
||||
if (node)
|
||||
node->traverse(&it);
|
||||
|
||||
return it.wasFound();
|
||||
}
|
||||
|
||||
void AliveSymbol(TIntermSymbol* node, TIntermTraverser* it)
|
||||
{
|
||||
TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);
|
||||
|
||||
//
|
||||
// If it's what we're looking for, record it.
|
||||
//
|
||||
if (node->getQualifier() == lit->qualifier)
|
||||
lit->found = true;
|
||||
}
|
||||
|
||||
bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
|
||||
{
|
||||
TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);
|
||||
|
||||
if (lit->wasFound())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "../Include/intermediate.h"
|
||||
|
||||
class TAliveTraverser : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
TAliveTraverser(TQualifier q) : TIntermTraverser(), found(false), qualifier(q)
|
||||
{
|
||||
visitSymbol = AliveSymbol;
|
||||
visitSelection = AliveSelection;
|
||||
rightToLeft = true;
|
||||
}
|
||||
bool wasFound()
|
||||
{
|
||||
return found;
|
||||
}
|
||||
protected:
|
||||
bool found;
|
||||
TQualifier qualifier;
|
||||
|
||||
friend void AliveSymbol(TIntermSymbol*, TIntermTraverser*);
|
||||
friend bool AliveSelection(bool, TIntermSelection*, TIntermTraverser*);
|
||||
};
|
||||
|
||||
//
|
||||
// Report whether or not a variable of the given qualifier type
|
||||
// is guaranteed written. Not always possible to determine if
|
||||
// it is written conditionally.
|
||||
//
|
||||
// ?? It does not do this well yet, this is just a place holder
|
||||
// that simply determines if it was reference at all, anywhere.
|
||||
//
|
||||
bool QualifierWritten(TIntermNode* node, TQualifier qualifier)
|
||||
{
|
||||
TAliveTraverser it(qualifier);
|
||||
|
||||
if (node)
|
||||
node->traverse(&it);
|
||||
|
||||
return it.wasFound();
|
||||
}
|
||||
|
||||
void AliveSymbol(TIntermSymbol* node, TIntermTraverser* it)
|
||||
{
|
||||
TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);
|
||||
|
||||
//
|
||||
// If it's what we're looking for, record it.
|
||||
//
|
||||
if (node->getQualifier() == lit->qualifier)
|
||||
lit->found = true;
|
||||
}
|
||||
|
||||
bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
|
||||
{
|
||||
TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);
|
||||
|
||||
if (lit->wasFound())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
bool QualifierWritten(TIntermNode* root, TQualifier);
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
bool QualifierWritten(TIntermNode* root, TQualifier);
|
||||
|
|
|
@ -1,133 +1,133 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "../Include/intermediate.h"
|
||||
#include "RemoveTree.h"
|
||||
//
|
||||
// Code to recursively delete the intermediate tree.
|
||||
//
|
||||
|
||||
void RemoveSymbol(TIntermSymbol* node, TIntermTraverser* it)
|
||||
{
|
||||
delete node;
|
||||
}
|
||||
|
||||
bool RemoveBinary(bool /*preVisit*/ , TIntermBinary* node, TIntermTraverser*)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveUnary(bool, /*preVisit */ TIntermUnary* node, TIntermTraverser*)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveAggregate(bool /*preVisit*/ , TIntermAggregate* node, TIntermTraverser*)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveSelection(bool /*preVisit*/ , TIntermSelection* node, TIntermTraverser*)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RemoveConstantUnion(TIntermConstantUnion* node, TIntermTraverser*)
|
||||
{
|
||||
delete node;
|
||||
}
|
||||
|
||||
//
|
||||
// Entry point.
|
||||
//
|
||||
void RemoveAllTreeNodes(TIntermNode* root)
|
||||
{
|
||||
TIntermTraverser it;
|
||||
|
||||
it.visitAggregate = RemoveAggregate;
|
||||
it.visitBinary = RemoveBinary;
|
||||
it.visitConstantUnion = RemoveConstantUnion;
|
||||
it.visitSelection = RemoveSelection;
|
||||
it.visitSymbol = RemoveSymbol;
|
||||
it.visitUnary = RemoveUnary;
|
||||
|
||||
it.preVisit = false;
|
||||
it.postVisit = true;
|
||||
|
||||
root->traverse(&it);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "../Include/intermediate.h"
|
||||
#include "RemoveTree.h"
|
||||
//
|
||||
// Code to recursively delete the intermediate tree.
|
||||
//
|
||||
|
||||
void RemoveSymbol(TIntermSymbol* node, TIntermTraverser* it)
|
||||
{
|
||||
delete node;
|
||||
}
|
||||
|
||||
bool RemoveBinary(bool /*preVisit*/ , TIntermBinary* node, TIntermTraverser*)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveUnary(bool, /*preVisit */ TIntermUnary* node, TIntermTraverser*)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveAggregate(bool /*preVisit*/ , TIntermAggregate* node, TIntermTraverser*)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveSelection(bool /*preVisit*/ , TIntermSelection* node, TIntermTraverser*)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RemoveConstantUnion(TIntermConstantUnion* node, TIntermTraverser*)
|
||||
{
|
||||
delete node;
|
||||
}
|
||||
|
||||
//
|
||||
// Entry point.
|
||||
//
|
||||
void RemoveAllTreeNodes(TIntermNode* root)
|
||||
{
|
||||
TIntermTraverser it;
|
||||
|
||||
it.visitAggregate = RemoveAggregate;
|
||||
it.visitBinary = RemoveBinary;
|
||||
it.visitConstantUnion = RemoveConstantUnion;
|
||||
it.visitSelection = RemoveSelection;
|
||||
it.visitSymbol = RemoveSymbol;
|
||||
it.visitUnary = RemoveUnary;
|
||||
|
||||
it.preVisit = false;
|
||||
it.postVisit = true;
|
||||
|
||||
root->traverse(&it);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
void RemoveAllTreeNodes(TIntermNode*);
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
void RemoveAllTreeNodes(TIntermNode*);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,396 +1,396 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _SYMBOL_TABLE_INCLUDED_
|
||||
#define _SYMBOL_TABLE_INCLUDED_
|
||||
|
||||
//
|
||||
// Symbol table for parsing. Has these design characteristics:
|
||||
//
|
||||
// * Same symbol table can be used to compile many shaders, to preserve
|
||||
// effort of creating and loading with the large numbers of built-in
|
||||
// symbols.
|
||||
//
|
||||
// * Name mangling will be used to give each function a unique name
|
||||
// so that symbol table lookups are never ambiguous. This allows
|
||||
// a simpler symbol table structure.
|
||||
//
|
||||
// * Pushing and popping of scope, so symbol table will really be a stack
|
||||
// of symbol tables. Searched from the top, with new inserts going into
|
||||
// the top.
|
||||
//
|
||||
// * Constants: Compile time constant symbols will keep their values
|
||||
// in the symbol table. The parser can substitute constants at parse
|
||||
// time, including doing constant folding and constant propagation.
|
||||
//
|
||||
// * No temporaries: Temporaries made from operations (+, --, .xy, etc.)
|
||||
// are tracked in the intermediate representation, not the symbol table.
|
||||
//
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/intermediate.h"
|
||||
#include "../Include/InfoSink.h"
|
||||
|
||||
//
|
||||
// Symbol base class. (Can build functions or variables out of these...)
|
||||
//
|
||||
class TSymbol {
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
TSymbol(const TString *n) : name(n), info(0) { }
|
||||
TSymbol(const TString *n, const TTypeInfo *i) : name(n), info(i) { }
|
||||
virtual ~TSymbol() { /* don't delete name, it's from the pool */ }
|
||||
const TString& getName() const { return *name; }
|
||||
const TTypeInfo* getInfo() const { return info; }
|
||||
void setInfo( const TTypeInfo *i) { info = i; }
|
||||
virtual const TString& getMangledName() const { return getName(); }
|
||||
virtual bool isFunction() const { return false; }
|
||||
virtual bool isVariable() const { return false; }
|
||||
void setUniqueId(int id) { uniqueId = id; }
|
||||
int getUniqueId() const { return uniqueId; }
|
||||
virtual void dump(TInfoSink &infoSink) const = 0;
|
||||
TSymbol(const TSymbol&);
|
||||
virtual TSymbol* clone(TStructureMap& remapper) = 0;
|
||||
|
||||
protected:
|
||||
const TString *name;
|
||||
const TTypeInfo *info;
|
||||
unsigned int uniqueId; // For real comparing during code generation
|
||||
};
|
||||
|
||||
//
|
||||
// Variable class, meaning a symbol that's not a function.
|
||||
//
|
||||
// There could be a separate class heirarchy for Constant variables;
|
||||
// Only one of int, bool, or float, (or none) is correct for
|
||||
// any particular use, but it's easy to do this way, and doesn't
|
||||
// seem worth having separate classes, and "getConst" can't simply return
|
||||
// different values for different types polymorphically, so this is
|
||||
// just simple and pragmatic.
|
||||
//
|
||||
class TVariable : public TSymbol {
|
||||
public:
|
||||
TVariable(const TString *name, const TType& t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0), arrayInformationType(0) { }
|
||||
TVariable(const TString *name, const TTypeInfo* info, const TType& t, bool uT = false ) : TSymbol(name, info), type(t), userType(uT), unionArray(0), arrayInformationType(0) { }
|
||||
virtual ~TVariable() { }
|
||||
virtual bool isVariable() const { return true; }
|
||||
TType& getType() { return type; }
|
||||
const TType& getType() const { return type; }
|
||||
bool isUserType() const { return userType; }
|
||||
void changeQualifier(TQualifier qualifier) { type.changeQualifier(qualifier); }
|
||||
void updateArrayInformationType(TType *t) { arrayInformationType = t; }
|
||||
TType* getArrayInformationType() { return arrayInformationType; }
|
||||
|
||||
virtual void dump(TInfoSink &infoSink) const;
|
||||
|
||||
constUnion* getConstPointer()
|
||||
{
|
||||
if (!unionArray)
|
||||
unionArray = new constUnion[type.getObjectSize()];
|
||||
|
||||
return unionArray;
|
||||
}
|
||||
|
||||
constUnion* getConstPointer() const { return unionArray; }
|
||||
|
||||
void shareConstPointer( constUnion *constArray)
|
||||
{
|
||||
delete unionArray;
|
||||
unionArray = constArray;
|
||||
}
|
||||
TVariable(const TVariable&, TStructureMap& remapper); // copy constructor
|
||||
virtual TVariable* clone(TStructureMap& remapper);
|
||||
|
||||
protected:
|
||||
TType type;
|
||||
bool userType;
|
||||
// we are assuming that Pool Allocator will free the memory allocated to unionArray
|
||||
// when this object is destroyed
|
||||
constUnion *unionArray;
|
||||
TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
|
||||
};
|
||||
|
||||
//
|
||||
// The function sub-class of symbols and the parser will need to
|
||||
// share this definition of a function parameter.
|
||||
//
|
||||
struct TParameter
|
||||
{
|
||||
TString *name;
|
||||
const TTypeInfo *info;
|
||||
TType* type;
|
||||
void copyParam(const TParameter& param, TStructureMap& remapper)
|
||||
{
|
||||
name = NewPoolTString(param.name->c_str());
|
||||
info = param.info; //sharing
|
||||
type = param.type->clone(remapper);
|
||||
}
|
||||
static TString* NullSemantic;
|
||||
};
|
||||
|
||||
//
|
||||
// The function sub-class of a symbol.
|
||||
//
|
||||
class TFunction : public TSymbol
|
||||
{
|
||||
public:
|
||||
TFunction(TOperator o) :
|
||||
TSymbol(0),
|
||||
returnType(TType(EbtVoid)),
|
||||
op(o),
|
||||
defined(false) { }
|
||||
TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) :
|
||||
TSymbol(name),
|
||||
returnType(retType),
|
||||
mangledName(*name + '('),
|
||||
op(tOp),
|
||||
defined(false) { }
|
||||
TFunction(const TString *name, const TTypeInfo* info, TType& retType, TOperator tOp = EOpNull) :
|
||||
TSymbol(name, info),
|
||||
returnType(retType),
|
||||
mangledName(*name + '('),
|
||||
op(tOp),
|
||||
defined(false) { }
|
||||
virtual ~TFunction();
|
||||
virtual bool isFunction() const { return true; }
|
||||
|
||||
void addParameter(TParameter& p)
|
||||
{
|
||||
parameters.push_back(p);
|
||||
mangledName = mangledName + p.type->getMangledName();
|
||||
}
|
||||
|
||||
const TString& getMangledName() const { return mangledName; }
|
||||
const TType& getReturnType() const { return returnType; }
|
||||
void relateToOperator(TOperator o) { op = o; }
|
||||
TOperator getBuiltInOp() const { return op; }
|
||||
void setDefined() { defined = true; }
|
||||
bool isDefined() { return defined; }
|
||||
|
||||
int getParamCount() const { return static_cast<int>(parameters.size()); }
|
||||
TParameter& operator [](int i) { return parameters[i]; }
|
||||
const TParameter& operator [](int i) const { return parameters[i]; }
|
||||
|
||||
virtual void dump(TInfoSink &infoSink) const;
|
||||
TFunction(const TFunction&, TStructureMap& remapper);
|
||||
virtual TFunction* clone(TStructureMap& remapper);
|
||||
|
||||
protected:
|
||||
typedef TVector<TParameter> TParamList;
|
||||
TParamList parameters;
|
||||
TType returnType;
|
||||
TString mangledName;
|
||||
TOperator op;
|
||||
bool defined;
|
||||
};
|
||||
|
||||
|
||||
class TSymbolTableLevel
|
||||
{
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
TSymbolTableLevel() { }
|
||||
~TSymbolTableLevel();
|
||||
|
||||
bool insert(TSymbol& symbol)
|
||||
{
|
||||
//
|
||||
// returning true means symbol was added to the table
|
||||
//
|
||||
tInsertResult result;
|
||||
result = level.insert(tLevelPair(symbol.getMangledName(), &symbol));
|
||||
|
||||
return result.second;
|
||||
}
|
||||
|
||||
TSymbol* find(const TString& name) const
|
||||
{
|
||||
tLevel::const_iterator it = level.find(name);
|
||||
if (it == level.end())
|
||||
return 0;
|
||||
else
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
// vector might be best switched to a special allocator
|
||||
TSymbol* findCompatible( const TFunction *call, bool &ambiguous) const;
|
||||
|
||||
void relateToOperator(const char* name, TOperator op);
|
||||
void dump(TInfoSink &infoSink) const;
|
||||
TSymbolTableLevel* clone(TStructureMap& remapper);
|
||||
|
||||
protected:
|
||||
typedef std::map<TString, TSymbol*, std::less<TString>, pool_allocator<std::pair<const TString, TSymbol*> > > tLevel;
|
||||
typedef const tLevel::value_type tLevelPair;
|
||||
typedef std::pair<tLevel::iterator, bool> tInsertResult;
|
||||
|
||||
tLevel level;
|
||||
};
|
||||
|
||||
class TSymbolTable {
|
||||
public:
|
||||
TSymbolTable() : uniqueId(0)
|
||||
{
|
||||
//
|
||||
// The symbol table cannot be used until push() is called, but
|
||||
// the lack of an initial call to push() can be used to detect
|
||||
// that the symbol table has not been preloaded with built-ins.
|
||||
//
|
||||
}
|
||||
|
||||
TSymbolTable(TSymbolTable& symTable)
|
||||
{
|
||||
table.push_back(symTable.table[0]);
|
||||
uniqueId = symTable.uniqueId;
|
||||
}
|
||||
|
||||
~TSymbolTable()
|
||||
{
|
||||
// level 0 is always built In symbols, so we never pop that out
|
||||
while (table.size() > 1)
|
||||
pop();
|
||||
}
|
||||
|
||||
//
|
||||
// When the symbol table is initialized with the built-ins, there should
|
||||
// 'push' calls, so that built-ins are at level 0 and the shader
|
||||
// globals are at level 1.
|
||||
//
|
||||
bool isEmpty() { return table.size() == 0; }
|
||||
bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
|
||||
bool atSharedBuiltInLevel() { return table.size() == 1; }
|
||||
bool atGlobalLevel() { return table.size() <= 3; }
|
||||
void push()
|
||||
{
|
||||
table.push_back(new TSymbolTableLevel);
|
||||
}
|
||||
|
||||
void pop()
|
||||
{
|
||||
delete table[currentLevel()];
|
||||
table.pop_back();
|
||||
}
|
||||
|
||||
bool insert(TSymbol& symbol)
|
||||
{
|
||||
symbol.setUniqueId(++uniqueId);
|
||||
return table[currentLevel()]->insert(symbol);
|
||||
}
|
||||
|
||||
TSymbol* find(const TString& name, bool* builtIn = 0, bool *sameScope = 0)
|
||||
{
|
||||
int level = currentLevel();
|
||||
TSymbol* symbol;
|
||||
do
|
||||
{
|
||||
symbol = table[level]->find(name);
|
||||
--level;
|
||||
} while (symbol == 0 && level >= 0);
|
||||
level++;
|
||||
if (builtIn)
|
||||
*builtIn = level == 0;
|
||||
if (sameScope)
|
||||
*sameScope = level == currentLevel();
|
||||
return symbol;
|
||||
}
|
||||
|
||||
TSymbol* findCompatible(const TFunction* call, bool *builtIn, bool &ambiguous)
|
||||
{
|
||||
int level = currentLevel();
|
||||
TSymbol *symbol = 0;
|
||||
ambiguous = false;
|
||||
|
||||
do
|
||||
{
|
||||
symbol = table[level]->findCompatible(call, ambiguous);
|
||||
--level;
|
||||
} while ( symbol == 0 && level >= 0 && !ambiguous);
|
||||
level++;
|
||||
if (builtIn)
|
||||
*builtIn = level == 0;
|
||||
//if (sameScope)
|
||||
// *sameScope = level == currentLevel();
|
||||
return symbol;
|
||||
}
|
||||
|
||||
TSymbolTableLevel* getGlobalLevel() { assert(table.size() >= 3); return table[2]; }
|
||||
void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); }
|
||||
int getMaxSymbolId() { return uniqueId; }
|
||||
void dump(TInfoSink &infoSink) const;
|
||||
void copyTable(const TSymbolTable& copyOf);
|
||||
|
||||
protected:
|
||||
int currentLevel() const { return static_cast<int>(table.size()) - 1; }
|
||||
bool atDynamicBuiltInLevel() { return table.size() == 2; }
|
||||
|
||||
std::vector<TSymbolTableLevel*> table;
|
||||
int uniqueId; // for unique identification in code generation
|
||||
};
|
||||
|
||||
#endif // _SYMBOL_TABLE_INCLUDED_
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _SYMBOL_TABLE_INCLUDED_
|
||||
#define _SYMBOL_TABLE_INCLUDED_
|
||||
|
||||
//
|
||||
// Symbol table for parsing. Has these design characteristics:
|
||||
//
|
||||
// * Same symbol table can be used to compile many shaders, to preserve
|
||||
// effort of creating and loading with the large numbers of built-in
|
||||
// symbols.
|
||||
//
|
||||
// * Name mangling will be used to give each function a unique name
|
||||
// so that symbol table lookups are never ambiguous. This allows
|
||||
// a simpler symbol table structure.
|
||||
//
|
||||
// * Pushing and popping of scope, so symbol table will really be a stack
|
||||
// of symbol tables. Searched from the top, with new inserts going into
|
||||
// the top.
|
||||
//
|
||||
// * Constants: Compile time constant symbols will keep their values
|
||||
// in the symbol table. The parser can substitute constants at parse
|
||||
// time, including doing constant folding and constant propagation.
|
||||
//
|
||||
// * No temporaries: Temporaries made from operations (+, --, .xy, etc.)
|
||||
// are tracked in the intermediate representation, not the symbol table.
|
||||
//
|
||||
|
||||
#include "../Include/Common.h"
|
||||
#include "../Include/intermediate.h"
|
||||
#include "../Include/InfoSink.h"
|
||||
|
||||
//
|
||||
// Symbol base class. (Can build functions or variables out of these...)
|
||||
//
|
||||
class TSymbol {
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
TSymbol(const TString *n) : name(n), info(0) { }
|
||||
TSymbol(const TString *n, const TTypeInfo *i) : name(n), info(i) { }
|
||||
virtual ~TSymbol() { /* don't delete name, it's from the pool */ }
|
||||
const TString& getName() const { return *name; }
|
||||
const TTypeInfo* getInfo() const { return info; }
|
||||
void setInfo( const TTypeInfo *i) { info = i; }
|
||||
virtual const TString& getMangledName() const { return getName(); }
|
||||
virtual bool isFunction() const { return false; }
|
||||
virtual bool isVariable() const { return false; }
|
||||
void setUniqueId(int id) { uniqueId = id; }
|
||||
int getUniqueId() const { return uniqueId; }
|
||||
virtual void dump(TInfoSink &infoSink) const = 0;
|
||||
TSymbol(const TSymbol&);
|
||||
virtual TSymbol* clone(TStructureMap& remapper) = 0;
|
||||
|
||||
protected:
|
||||
const TString *name;
|
||||
const TTypeInfo *info;
|
||||
unsigned int uniqueId; // For real comparing during code generation
|
||||
};
|
||||
|
||||
//
|
||||
// Variable class, meaning a symbol that's not a function.
|
||||
//
|
||||
// There could be a separate class heirarchy for Constant variables;
|
||||
// Only one of int, bool, or float, (or none) is correct for
|
||||
// any particular use, but it's easy to do this way, and doesn't
|
||||
// seem worth having separate classes, and "getConst" can't simply return
|
||||
// different values for different types polymorphically, so this is
|
||||
// just simple and pragmatic.
|
||||
//
|
||||
class TVariable : public TSymbol {
|
||||
public:
|
||||
TVariable(const TString *name, const TType& t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0), arrayInformationType(0) { }
|
||||
TVariable(const TString *name, const TTypeInfo* info, const TType& t, bool uT = false ) : TSymbol(name, info), type(t), userType(uT), unionArray(0), arrayInformationType(0) { }
|
||||
virtual ~TVariable() { }
|
||||
virtual bool isVariable() const { return true; }
|
||||
TType& getType() { return type; }
|
||||
const TType& getType() const { return type; }
|
||||
bool isUserType() const { return userType; }
|
||||
void changeQualifier(TQualifier qualifier) { type.changeQualifier(qualifier); }
|
||||
void updateArrayInformationType(TType *t) { arrayInformationType = t; }
|
||||
TType* getArrayInformationType() { return arrayInformationType; }
|
||||
|
||||
virtual void dump(TInfoSink &infoSink) const;
|
||||
|
||||
constUnion* getConstPointer()
|
||||
{
|
||||
if (!unionArray)
|
||||
unionArray = new constUnion[type.getObjectSize()];
|
||||
|
||||
return unionArray;
|
||||
}
|
||||
|
||||
constUnion* getConstPointer() const { return unionArray; }
|
||||
|
||||
void shareConstPointer( constUnion *constArray)
|
||||
{
|
||||
delete unionArray;
|
||||
unionArray = constArray;
|
||||
}
|
||||
TVariable(const TVariable&, TStructureMap& remapper); // copy constructor
|
||||
virtual TVariable* clone(TStructureMap& remapper);
|
||||
|
||||
protected:
|
||||
TType type;
|
||||
bool userType;
|
||||
// we are assuming that Pool Allocator will free the memory allocated to unionArray
|
||||
// when this object is destroyed
|
||||
constUnion *unionArray;
|
||||
TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
|
||||
};
|
||||
|
||||
//
|
||||
// The function sub-class of symbols and the parser will need to
|
||||
// share this definition of a function parameter.
|
||||
//
|
||||
struct TParameter
|
||||
{
|
||||
TString *name;
|
||||
const TTypeInfo *info;
|
||||
TType* type;
|
||||
void copyParam(const TParameter& param, TStructureMap& remapper)
|
||||
{
|
||||
name = NewPoolTString(param.name->c_str());
|
||||
info = param.info; //sharing
|
||||
type = param.type->clone(remapper);
|
||||
}
|
||||
static TString* NullSemantic;
|
||||
};
|
||||
|
||||
//
|
||||
// The function sub-class of a symbol.
|
||||
//
|
||||
class TFunction : public TSymbol
|
||||
{
|
||||
public:
|
||||
TFunction(TOperator o) :
|
||||
TSymbol(0),
|
||||
returnType(TType(EbtVoid)),
|
||||
op(o),
|
||||
defined(false) { }
|
||||
TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) :
|
||||
TSymbol(name),
|
||||
returnType(retType),
|
||||
mangledName(*name + '('),
|
||||
op(tOp),
|
||||
defined(false) { }
|
||||
TFunction(const TString *name, const TTypeInfo* info, TType& retType, TOperator tOp = EOpNull) :
|
||||
TSymbol(name, info),
|
||||
returnType(retType),
|
||||
mangledName(*name + '('),
|
||||
op(tOp),
|
||||
defined(false) { }
|
||||
virtual ~TFunction();
|
||||
virtual bool isFunction() const { return true; }
|
||||
|
||||
void addParameter(TParameter& p)
|
||||
{
|
||||
parameters.push_back(p);
|
||||
mangledName = mangledName + p.type->getMangledName();
|
||||
}
|
||||
|
||||
const TString& getMangledName() const { return mangledName; }
|
||||
const TType& getReturnType() const { return returnType; }
|
||||
void relateToOperator(TOperator o) { op = o; }
|
||||
TOperator getBuiltInOp() const { return op; }
|
||||
void setDefined() { defined = true; }
|
||||
bool isDefined() { return defined; }
|
||||
|
||||
int getParamCount() const { return static_cast<int>(parameters.size()); }
|
||||
TParameter& operator [](int i) { return parameters[i]; }
|
||||
const TParameter& operator [](int i) const { return parameters[i]; }
|
||||
|
||||
virtual void dump(TInfoSink &infoSink) const;
|
||||
TFunction(const TFunction&, TStructureMap& remapper);
|
||||
virtual TFunction* clone(TStructureMap& remapper);
|
||||
|
||||
protected:
|
||||
typedef TVector<TParameter> TParamList;
|
||||
TParamList parameters;
|
||||
TType returnType;
|
||||
TString mangledName;
|
||||
TOperator op;
|
||||
bool defined;
|
||||
};
|
||||
|
||||
|
||||
class TSymbolTableLevel
|
||||
{
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
TSymbolTableLevel() { }
|
||||
~TSymbolTableLevel();
|
||||
|
||||
bool insert(TSymbol& symbol)
|
||||
{
|
||||
//
|
||||
// returning true means symbol was added to the table
|
||||
//
|
||||
tInsertResult result;
|
||||
result = level.insert(tLevelPair(symbol.getMangledName(), &symbol));
|
||||
|
||||
return result.second;
|
||||
}
|
||||
|
||||
TSymbol* find(const TString& name) const
|
||||
{
|
||||
tLevel::const_iterator it = level.find(name);
|
||||
if (it == level.end())
|
||||
return 0;
|
||||
else
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
// vector might be best switched to a special allocator
|
||||
TSymbol* findCompatible( const TFunction *call, bool &ambiguous) const;
|
||||
|
||||
void relateToOperator(const char* name, TOperator op);
|
||||
void dump(TInfoSink &infoSink) const;
|
||||
TSymbolTableLevel* clone(TStructureMap& remapper);
|
||||
|
||||
protected:
|
||||
typedef std::map<TString, TSymbol*, std::less<TString>, pool_allocator<std::pair<const TString, TSymbol*> > > tLevel;
|
||||
typedef const tLevel::value_type tLevelPair;
|
||||
typedef std::pair<tLevel::iterator, bool> tInsertResult;
|
||||
|
||||
tLevel level;
|
||||
};
|
||||
|
||||
class TSymbolTable {
|
||||
public:
|
||||
TSymbolTable() : uniqueId(0)
|
||||
{
|
||||
//
|
||||
// The symbol table cannot be used until push() is called, but
|
||||
// the lack of an initial call to push() can be used to detect
|
||||
// that the symbol table has not been preloaded with built-ins.
|
||||
//
|
||||
}
|
||||
|
||||
TSymbolTable(TSymbolTable& symTable)
|
||||
{
|
||||
table.push_back(symTable.table[0]);
|
||||
uniqueId = symTable.uniqueId;
|
||||
}
|
||||
|
||||
~TSymbolTable()
|
||||
{
|
||||
// level 0 is always built In symbols, so we never pop that out
|
||||
while (table.size() > 1)
|
||||
pop();
|
||||
}
|
||||
|
||||
//
|
||||
// When the symbol table is initialized with the built-ins, there should
|
||||
// 'push' calls, so that built-ins are at level 0 and the shader
|
||||
// globals are at level 1.
|
||||
//
|
||||
bool isEmpty() { return table.size() == 0; }
|
||||
bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
|
||||
bool atSharedBuiltInLevel() { return table.size() == 1; }
|
||||
bool atGlobalLevel() { return table.size() <= 3; }
|
||||
void push()
|
||||
{
|
||||
table.push_back(new TSymbolTableLevel);
|
||||
}
|
||||
|
||||
void pop()
|
||||
{
|
||||
delete table[currentLevel()];
|
||||
table.pop_back();
|
||||
}
|
||||
|
||||
bool insert(TSymbol& symbol)
|
||||
{
|
||||
symbol.setUniqueId(++uniqueId);
|
||||
return table[currentLevel()]->insert(symbol);
|
||||
}
|
||||
|
||||
TSymbol* find(const TString& name, bool* builtIn = 0, bool *sameScope = 0)
|
||||
{
|
||||
int level = currentLevel();
|
||||
TSymbol* symbol;
|
||||
do
|
||||
{
|
||||
symbol = table[level]->find(name);
|
||||
--level;
|
||||
} while (symbol == 0 && level >= 0);
|
||||
level++;
|
||||
if (builtIn)
|
||||
*builtIn = level == 0;
|
||||
if (sameScope)
|
||||
*sameScope = level == currentLevel();
|
||||
return symbol;
|
||||
}
|
||||
|
||||
TSymbol* findCompatible(const TFunction* call, bool *builtIn, bool &ambiguous)
|
||||
{
|
||||
int level = currentLevel();
|
||||
TSymbol *symbol = 0;
|
||||
ambiguous = false;
|
||||
|
||||
do
|
||||
{
|
||||
symbol = table[level]->findCompatible(call, ambiguous);
|
||||
--level;
|
||||
} while ( symbol == 0 && level >= 0 && !ambiguous);
|
||||
level++;
|
||||
if (builtIn)
|
||||
*builtIn = level == 0;
|
||||
//if (sameScope)
|
||||
// *sameScope = level == currentLevel();
|
||||
return symbol;
|
||||
}
|
||||
|
||||
TSymbolTableLevel* getGlobalLevel() { assert(table.size() >= 3); return table[2]; }
|
||||
void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); }
|
||||
int getMaxSymbolId() { return uniqueId; }
|
||||
void dump(TInfoSink &infoSink) const;
|
||||
void copyTable(const TSymbolTable& copyOf);
|
||||
|
||||
protected:
|
||||
int currentLevel() const { return static_cast<int>(table.size()) - 1; }
|
||||
bool atDynamicBuiltInLevel() { return table.size() == 2; }
|
||||
|
||||
std::vector<TSymbolTableLevel*> table;
|
||||
int uniqueId; // for unique identification in code generation
|
||||
};
|
||||
|
||||
#endif // _SYMBOL_TABLE_INCLUDED_
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,126 +1,126 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef _LOCAL_INTERMEDIATE_INCLUDED_
|
||||
#define _LOCAL_INTERMEDIATE_INCLUDED_
|
||||
|
||||
#include "../Include/intermediate.h"
|
||||
#include "../../include/hlsl2glsl.h"
|
||||
#include "SymbolTable.h"
|
||||
|
||||
struct TVectorFields
|
||||
{
|
||||
int offsets[4];
|
||||
int num;
|
||||
};
|
||||
|
||||
//
|
||||
// Set of helper functions to help parse and build the tree.
|
||||
//
|
||||
class TInfoSink;
|
||||
class TIntermediate
|
||||
{
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
|
||||
TIntermediate(TInfoSink& i) : infoSink(i)
|
||||
{
|
||||
}
|
||||
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, TSourceLoc);
|
||||
TIntermSymbol* addSymbol(int id, const TString& name, const TTypeInfo *info, const TType& type, TSourceLoc line);
|
||||
TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*);
|
||||
TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TSymbolTable&);
|
||||
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||
TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
|
||||
TIntermTyped* addUnaryMath(TOperator op, TIntermNode* child, TSourceLoc, TSymbolTable&);
|
||||
TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc);
|
||||
TIntermAggregate* makeAggregate(TIntermNode* node, TSourceLoc);
|
||||
TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc);
|
||||
TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
|
||||
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
|
||||
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
|
||||
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
|
||||
bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false);
|
||||
TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
|
||||
TIntermBranch* addBranch(TOperator, TSourceLoc);
|
||||
TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
|
||||
TIntermTyped* addSwizzle(TVectorFields&, TSourceLoc);
|
||||
bool postProcess(TIntermNode*, EShLanguage);
|
||||
void remove(TIntermNode*);
|
||||
void outputTree(TIntermNode*);
|
||||
|
||||
protected:
|
||||
TInfoSink& infoSink;
|
||||
|
||||
private:
|
||||
void operator=(TIntermediate&); // prevent assignments
|
||||
};
|
||||
|
||||
#endif // _LOCAL_INTERMEDIATE_INCLUDED_
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef _LOCAL_INTERMEDIATE_INCLUDED_
|
||||
#define _LOCAL_INTERMEDIATE_INCLUDED_
|
||||
|
||||
#include "../Include/intermediate.h"
|
||||
#include "../../include/hlsl2glsl.h"
|
||||
#include "SymbolTable.h"
|
||||
|
||||
struct TVectorFields
|
||||
{
|
||||
int offsets[4];
|
||||
int num;
|
||||
};
|
||||
|
||||
//
|
||||
// Set of helper functions to help parse and build the tree.
|
||||
//
|
||||
class TInfoSink;
|
||||
class TIntermediate
|
||||
{
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
|
||||
TIntermediate(TInfoSink& i) : infoSink(i)
|
||||
{
|
||||
}
|
||||
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, TSourceLoc);
|
||||
TIntermSymbol* addSymbol(int id, const TString& name, const TTypeInfo *info, const TType& type, TSourceLoc line);
|
||||
TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*);
|
||||
TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TSymbolTable&);
|
||||
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||
TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
|
||||
TIntermTyped* addUnaryMath(TOperator op, TIntermNode* child, TSourceLoc, TSymbolTable&);
|
||||
TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc);
|
||||
TIntermAggregate* makeAggregate(TIntermNode* node, TSourceLoc);
|
||||
TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc);
|
||||
TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
|
||||
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
|
||||
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
|
||||
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
|
||||
bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false);
|
||||
TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
|
||||
TIntermBranch* addBranch(TOperator, TSourceLoc);
|
||||
TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
|
||||
TIntermTyped* addSwizzle(TVectorFields&, TSourceLoc);
|
||||
bool postProcess(TIntermNode*, EShLanguage);
|
||||
void remove(TIntermNode*);
|
||||
void outputTree(TIntermNode*);
|
||||
|
||||
protected:
|
||||
TInfoSink& infoSink;
|
||||
|
||||
private:
|
||||
void operator=(TIntermediate&); // prevent assignments
|
||||
};
|
||||
|
||||
#endif // _LOCAL_INTERMEDIATE_INCLUDED_
|
||||
|
||||
|
|
|
@ -1,319 +1,319 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "ParseHelper.h"
|
||||
|
||||
//
|
||||
// Use this class to carry along data from node to node in
|
||||
// the traversal
|
||||
//
|
||||
class TConstTraverser : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t),
|
||||
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), matrixSize(0)
|
||||
{
|
||||
index = 0; tOp = EOpNull;
|
||||
}
|
||||
int index ;
|
||||
constUnion *unionArray;
|
||||
TOperator tOp;
|
||||
TType type;
|
||||
TOperator constructorType;
|
||||
bool singleConstantParam;
|
||||
TInfoSink& infoSink;
|
||||
TSymbolTable& symbolTable;
|
||||
bool error;
|
||||
int size; // size of the constructor ( 4 for vec4)
|
||||
bool isMatrix;
|
||||
int matrixSize; // dimension of the matrix (nominal size and not the instance size)
|
||||
};
|
||||
|
||||
//
|
||||
// The rest of the file are the traversal functions. The last one
|
||||
// is the one that starts the traversal.
|
||||
//
|
||||
// Return true from interior nodes to have the external traversal
|
||||
// continue on to children. If you process children yourself,
|
||||
// return false.
|
||||
//
|
||||
|
||||
void ParseSymbol(TIntermSymbol* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
oit->infoSink.info.message(EPrefixInternalError, "Symbol Node found in constant constructor", node->getLine());
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
bool ParseBinary(bool, /* preVisit */ TIntermBinary* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
|
||||
TQualifier qualifier = node->getType().getQualifier();
|
||||
|
||||
if (qualifier != EvqConst)
|
||||
{
|
||||
char buf[200];
|
||||
sprintf(buf, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str());
|
||||
oit->infoSink.info.message(EPrefixError, buf, node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
oit->infoSink.info.message(EPrefixInternalError, "Binary Node found in constant constructor", node->getLine());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParseUnary(bool, /* preVisit */ TIntermUnary* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
|
||||
char buf[200];
|
||||
sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());
|
||||
oit->infoSink.info.message(EPrefixError, buf, node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParseAggregate(bool, /* preVisit */ TIntermAggregate* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
|
||||
if (!node->isConstructor() && node->getOp() != EOpComma)
|
||||
{
|
||||
char buf[200];
|
||||
sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());
|
||||
oit->infoSink.info.message(EPrefixError, buf, node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node->getSequence().size() == 0)
|
||||
{
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool flag = node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion();
|
||||
if (flag)
|
||||
{
|
||||
oit->singleConstantParam = true;
|
||||
oit->constructorType = node->getOp();
|
||||
oit->size = node->getType().getObjectSize();
|
||||
|
||||
if (node->getType().isMatrix())
|
||||
{
|
||||
oit->isMatrix = true;
|
||||
oit->matrixSize = node->getType().getNominalSize();
|
||||
}
|
||||
}
|
||||
|
||||
for (TIntermSequence::iterator p = node->getSequence().begin();
|
||||
p != node->getSequence().end(); p++)
|
||||
{
|
||||
|
||||
if (node->getOp() == EOpComma)
|
||||
oit->index = 0;
|
||||
|
||||
(*p)->traverse(oit);
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
oit->singleConstantParam = false;
|
||||
oit->constructorType = EOpNull;
|
||||
oit->size = 0;
|
||||
oit->isMatrix = false;
|
||||
oit->matrixSize = 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParseSelection(bool, /* preVisit */ TIntermSelection* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
oit->infoSink.info.message(EPrefixInternalError, "Selection Node found in constant constructor", node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
constUnion* leftUnionArray = oit->unionArray;
|
||||
int instanceSize = oit->type.getObjectSize();
|
||||
|
||||
if (oit->index >= instanceSize)
|
||||
return;
|
||||
|
||||
if (!oit->singleConstantParam)
|
||||
{
|
||||
int size = node->getType().getObjectSize();
|
||||
|
||||
constUnion *rightUnionArray = node->getUnionArrayPointer();
|
||||
for (int i=0; i < size; i++)
|
||||
{
|
||||
if (oit->index >= instanceSize)
|
||||
return;
|
||||
leftUnionArray[oit->index] = rightUnionArray[i];
|
||||
|
||||
(oit->index)++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int size, totalSize, matrixSize;
|
||||
bool isMatrix = false;
|
||||
size = oit->size;
|
||||
matrixSize = oit->matrixSize;
|
||||
isMatrix = oit->isMatrix;
|
||||
totalSize = oit->index + size ;
|
||||
constUnion *rightUnionArray = node->getUnionArrayPointer();
|
||||
if (!isMatrix)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = oit->index; i < totalSize; i++)
|
||||
{
|
||||
if (i >= instanceSize)
|
||||
return;
|
||||
|
||||
leftUnionArray[i] = rightUnionArray[count];
|
||||
|
||||
(oit->index)++;
|
||||
|
||||
if (node->getType().getObjectSize() > 1)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // for matrix constructors
|
||||
int count = 0;
|
||||
int index = oit->index;
|
||||
for (int i = index; i < totalSize; i++)
|
||||
{
|
||||
if (i >= instanceSize)
|
||||
return;
|
||||
if (index - i == 0 || (i - index) % (matrixSize + 1) == 0 )
|
||||
leftUnionArray[i] = rightUnionArray[count];
|
||||
else
|
||||
leftUnionArray[i].setFConst(0.0f);
|
||||
|
||||
(oit->index)++;
|
||||
|
||||
if (node->getType().getObjectSize() > 1)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ParseLoop(bool, /* preVisit */ TIntermLoop* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
oit->infoSink.info.message(EPrefixInternalError, "Loop Node found in constant constructor", node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParseBranch(bool, /* previsit*/ TIntermBranch* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
oit->infoSink.info.message(EPrefixInternalError, "Branch Node found in constant constructor", node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// This function is the one to call externally to start the traversal.
|
||||
// Individual functions can be initialized to 0 to skip processing of that
|
||||
// type of node. It's children will still be processed.
|
||||
//
|
||||
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, TSymbolTable& symbolTable, TType t, bool singleConstantParam)
|
||||
{
|
||||
if (root == 0)
|
||||
return false;
|
||||
|
||||
TConstTraverser it(unionArray, singleConstantParam, constructorType, infoSink, symbolTable, t);
|
||||
|
||||
it.visitAggregate = ParseAggregate;
|
||||
it.visitBinary = ParseBinary;
|
||||
it.visitConstantUnion = ParseConstantUnion;
|
||||
it.visitSelection = ParseSelection;
|
||||
it.visitSymbol = ParseSymbol;
|
||||
it.visitUnary = ParseUnary;
|
||||
it.visitLoop = ParseLoop;
|
||||
it.visitBranch = ParseBranch;
|
||||
|
||||
root->traverse(&it);
|
||||
if (it.error)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "ParseHelper.h"
|
||||
|
||||
//
|
||||
// Use this class to carry along data from node to node in
|
||||
// the traversal
|
||||
//
|
||||
class TConstTraverser : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t),
|
||||
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), matrixSize(0)
|
||||
{
|
||||
index = 0; tOp = EOpNull;
|
||||
}
|
||||
int index ;
|
||||
constUnion *unionArray;
|
||||
TOperator tOp;
|
||||
TType type;
|
||||
TOperator constructorType;
|
||||
bool singleConstantParam;
|
||||
TInfoSink& infoSink;
|
||||
TSymbolTable& symbolTable;
|
||||
bool error;
|
||||
int size; // size of the constructor ( 4 for vec4)
|
||||
bool isMatrix;
|
||||
int matrixSize; // dimension of the matrix (nominal size and not the instance size)
|
||||
};
|
||||
|
||||
//
|
||||
// The rest of the file are the traversal functions. The last one
|
||||
// is the one that starts the traversal.
|
||||
//
|
||||
// Return true from interior nodes to have the external traversal
|
||||
// continue on to children. If you process children yourself,
|
||||
// return false.
|
||||
//
|
||||
|
||||
void ParseSymbol(TIntermSymbol* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
oit->infoSink.info.message(EPrefixInternalError, "Symbol Node found in constant constructor", node->getLine());
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
bool ParseBinary(bool, /* preVisit */ TIntermBinary* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
|
||||
TQualifier qualifier = node->getType().getQualifier();
|
||||
|
||||
if (qualifier != EvqConst)
|
||||
{
|
||||
char buf[200];
|
||||
sprintf(buf, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str());
|
||||
oit->infoSink.info.message(EPrefixError, buf, node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
oit->infoSink.info.message(EPrefixInternalError, "Binary Node found in constant constructor", node->getLine());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParseUnary(bool, /* preVisit */ TIntermUnary* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
|
||||
char buf[200];
|
||||
sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());
|
||||
oit->infoSink.info.message(EPrefixError, buf, node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParseAggregate(bool, /* preVisit */ TIntermAggregate* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
|
||||
if (!node->isConstructor() && node->getOp() != EOpComma)
|
||||
{
|
||||
char buf[200];
|
||||
sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());
|
||||
oit->infoSink.info.message(EPrefixError, buf, node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node->getSequence().size() == 0)
|
||||
{
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool flag = node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion();
|
||||
if (flag)
|
||||
{
|
||||
oit->singleConstantParam = true;
|
||||
oit->constructorType = node->getOp();
|
||||
oit->size = node->getType().getObjectSize();
|
||||
|
||||
if (node->getType().isMatrix())
|
||||
{
|
||||
oit->isMatrix = true;
|
||||
oit->matrixSize = node->getType().getNominalSize();
|
||||
}
|
||||
}
|
||||
|
||||
for (TIntermSequence::iterator p = node->getSequence().begin();
|
||||
p != node->getSequence().end(); p++)
|
||||
{
|
||||
|
||||
if (node->getOp() == EOpComma)
|
||||
oit->index = 0;
|
||||
|
||||
(*p)->traverse(oit);
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
oit->singleConstantParam = false;
|
||||
oit->constructorType = EOpNull;
|
||||
oit->size = 0;
|
||||
oit->isMatrix = false;
|
||||
oit->matrixSize = 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParseSelection(bool, /* preVisit */ TIntermSelection* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
oit->infoSink.info.message(EPrefixInternalError, "Selection Node found in constant constructor", node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
constUnion* leftUnionArray = oit->unionArray;
|
||||
int instanceSize = oit->type.getObjectSize();
|
||||
|
||||
if (oit->index >= instanceSize)
|
||||
return;
|
||||
|
||||
if (!oit->singleConstantParam)
|
||||
{
|
||||
int size = node->getType().getObjectSize();
|
||||
|
||||
constUnion *rightUnionArray = node->getUnionArrayPointer();
|
||||
for (int i=0; i < size; i++)
|
||||
{
|
||||
if (oit->index >= instanceSize)
|
||||
return;
|
||||
leftUnionArray[oit->index] = rightUnionArray[i];
|
||||
|
||||
(oit->index)++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int size, totalSize, matrixSize;
|
||||
bool isMatrix = false;
|
||||
size = oit->size;
|
||||
matrixSize = oit->matrixSize;
|
||||
isMatrix = oit->isMatrix;
|
||||
totalSize = oit->index + size ;
|
||||
constUnion *rightUnionArray = node->getUnionArrayPointer();
|
||||
if (!isMatrix)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = oit->index; i < totalSize; i++)
|
||||
{
|
||||
if (i >= instanceSize)
|
||||
return;
|
||||
|
||||
leftUnionArray[i] = rightUnionArray[count];
|
||||
|
||||
(oit->index)++;
|
||||
|
||||
if (node->getType().getObjectSize() > 1)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // for matrix constructors
|
||||
int count = 0;
|
||||
int index = oit->index;
|
||||
for (int i = index; i < totalSize; i++)
|
||||
{
|
||||
if (i >= instanceSize)
|
||||
return;
|
||||
if (index - i == 0 || (i - index) % (matrixSize + 1) == 0 )
|
||||
leftUnionArray[i] = rightUnionArray[count];
|
||||
else
|
||||
leftUnionArray[i].setFConst(0.0f);
|
||||
|
||||
(oit->index)++;
|
||||
|
||||
if (node->getType().getObjectSize() > 1)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ParseLoop(bool, /* preVisit */ TIntermLoop* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
oit->infoSink.info.message(EPrefixInternalError, "Loop Node found in constant constructor", node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParseBranch(bool, /* previsit*/ TIntermBranch* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
oit->infoSink.info.message(EPrefixInternalError, "Branch Node found in constant constructor", node->getLine());
|
||||
oit->error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// This function is the one to call externally to start the traversal.
|
||||
// Individual functions can be initialized to 0 to skip processing of that
|
||||
// type of node. It's children will still be processed.
|
||||
//
|
||||
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, TSymbolTable& symbolTable, TType t, bool singleConstantParam)
|
||||
{
|
||||
if (root == 0)
|
||||
return false;
|
||||
|
||||
TConstTraverser it(unionArray, singleConstantParam, constructorType, infoSink, symbolTable, t);
|
||||
|
||||
it.visitAggregate = ParseAggregate;
|
||||
it.visitBinary = ParseBinary;
|
||||
it.visitConstantUnion = ParseConstantUnion;
|
||||
it.visitSelection = ParseSelection;
|
||||
it.visitSymbol = ParseSymbol;
|
||||
it.visitUnary = ParseUnary;
|
||||
it.visitLoop = ParseLoop;
|
||||
it.visitBranch = ParseBranch;
|
||||
|
||||
root->traverse(&it);
|
||||
if (it.error)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,131 +1,131 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// atom.h
|
||||
//
|
||||
|
||||
#if !defined(__ATOM_H)
|
||||
#define __ATOM_H 1
|
||||
|
||||
typedef struct AtomTable_Rec AtomTable;
|
||||
|
||||
extern AtomTable *atable;
|
||||
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
void FreeAtomTable(AtomTable *atable);
|
||||
int AddAtom(AtomTable *atable, const char *s);
|
||||
void PrintAtomTable(AtomTable *atable);
|
||||
int LookUpAddString(AtomTable *atable, const char *s);
|
||||
const char *GetAtomString(AtomTable *atable, int atom);
|
||||
int GetReversedAtom(AtomTable *atable, int atom);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
#endif // !defined(__ATOM_H)
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// atom.h
|
||||
//
|
||||
|
||||
#if !defined(__ATOM_H)
|
||||
#define __ATOM_H 1
|
||||
|
||||
typedef struct AtomTable_Rec AtomTable;
|
||||
|
||||
extern AtomTable *atable;
|
||||
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
void FreeAtomTable(AtomTable *atable);
|
||||
int AddAtom(AtomTable *atable, const char *s);
|
||||
void PrintAtomTable(AtomTable *atable);
|
||||
int LookUpAddString(AtomTable *atable, const char *s);
|
||||
const char *GetAtomString(AtomTable *atable, int atom);
|
||||
int GetReversedAtom(AtomTable *atable, int atom);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
#endif // !defined(__ATOM_H)
|
||||
|
|
|
@ -1,167 +1,167 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// compile.h
|
||||
//
|
||||
|
||||
#if !defined(__COMPILE_H)
|
||||
#define __COMPILE_H 1
|
||||
|
||||
int InitCPPStruct(void);
|
||||
|
||||
typedef struct Options_Rec{
|
||||
const char *profileString;
|
||||
int ErrorMode;
|
||||
int Quiet;
|
||||
|
||||
// Debug The Compiler options:
|
||||
int DumpAtomTable;
|
||||
} Options;
|
||||
|
||||
struct CPPStruct_Rec {
|
||||
// Public members
|
||||
SourceLoc *pLastSourceLoc; // Set at the start of each statement by the tree walkers
|
||||
Options options; // Compile options and parameters
|
||||
|
||||
// Private members
|
||||
SourceLoc lastSourceLoc;
|
||||
|
||||
// Scanner data:
|
||||
|
||||
SourceLoc *tokenLoc; // Source location of most recent token seen by the scanner
|
||||
int mostRecentToken; // Most recent token seen by the scanner
|
||||
InputSrc *currentInput;
|
||||
int previous_token;
|
||||
int notAVersionToken; // used to make sure that #version is the first token seen in the file, if present
|
||||
|
||||
void *pC; // storing the parseContext of the compile object in cpp.
|
||||
|
||||
// Private members:
|
||||
SourceLoc ltokenLoc;
|
||||
int ifdepth; //current #if-#else-#endif nesting in the cpp.c file (pre-processor)
|
||||
int elsedepth[64]; //Keep a track of #if depth..Max allowed is 64.
|
||||
int elsetracker; //#if-#else and #endif constructs...Counter.
|
||||
const char *ErrMsg;
|
||||
int CompileError; //Indicate compile error when #error, #else,#elif mismatch.
|
||||
|
||||
//
|
||||
// Globals used to communicate between PaParseStrings() and yy_input()and
|
||||
// also across the files.(gen_glslang.cpp and scanner.c)
|
||||
//
|
||||
int PaWhichStr; // which string we're parsing
|
||||
int* PaStrLen; // array of lengths of the PaArgv strings
|
||||
int PaArgc; // count of strings in the array
|
||||
char** PaArgv; // our array of strings to parse
|
||||
unsigned int tokensBeforeEOF : 1;
|
||||
};
|
||||
|
||||
#endif // !defined(__COMPILE_H)
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// compile.h
|
||||
//
|
||||
|
||||
#if !defined(__COMPILE_H)
|
||||
#define __COMPILE_H 1
|
||||
|
||||
int InitCPPStruct(void);
|
||||
|
||||
typedef struct Options_Rec{
|
||||
const char *profileString;
|
||||
int ErrorMode;
|
||||
int Quiet;
|
||||
|
||||
// Debug The Compiler options:
|
||||
int DumpAtomTable;
|
||||
} Options;
|
||||
|
||||
struct CPPStruct_Rec {
|
||||
// Public members
|
||||
SourceLoc *pLastSourceLoc; // Set at the start of each statement by the tree walkers
|
||||
Options options; // Compile options and parameters
|
||||
|
||||
// Private members
|
||||
SourceLoc lastSourceLoc;
|
||||
|
||||
// Scanner data:
|
||||
|
||||
SourceLoc *tokenLoc; // Source location of most recent token seen by the scanner
|
||||
int mostRecentToken; // Most recent token seen by the scanner
|
||||
InputSrc *currentInput;
|
||||
int previous_token;
|
||||
int notAVersionToken; // used to make sure that #version is the first token seen in the file, if present
|
||||
|
||||
void *pC; // storing the parseContext of the compile object in cpp.
|
||||
|
||||
// Private members:
|
||||
SourceLoc ltokenLoc;
|
||||
int ifdepth; //current #if-#else-#endif nesting in the cpp.c file (pre-processor)
|
||||
int elsedepth[64]; //Keep a track of #if depth..Max allowed is 64.
|
||||
int elsetracker; //#if-#else and #endif constructs...Counter.
|
||||
const char *ErrMsg;
|
||||
int CompileError; //Indicate compile error when #error, #else,#elif mismatch.
|
||||
|
||||
//
|
||||
// Globals used to communicate between PaParseStrings() and yy_input()and
|
||||
// also across the files.(gen_glslang.cpp and scanner.c)
|
||||
//
|
||||
int PaWhichStr; // which string we're parsing
|
||||
int* PaStrLen; // array of lengths of the PaArgv strings
|
||||
int PaArgc; // count of strings in the array
|
||||
char** PaArgv; // our array of strings to parse
|
||||
unsigned int tokensBeforeEOF : 1;
|
||||
};
|
||||
|
||||
#endif // !defined(__COMPILE_H)
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,154 +1,154 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// cpp.h
|
||||
//
|
||||
|
||||
#if !defined(__CPP_H)
|
||||
#define __CPP_H 1
|
||||
|
||||
#include "parser.h"
|
||||
#include "tokens.h"
|
||||
|
||||
int InitCPP(void);
|
||||
int FinalCPP(void);
|
||||
int readCPPline(yystypepp * yylvalpp);
|
||||
int MacroExpand(int atom, yystypepp * yylvalpp);
|
||||
int ChkCorrectElseNesting(void);
|
||||
|
||||
typedef struct MacroSymbol {
|
||||
int argc;
|
||||
int *args;
|
||||
TokenStream *body;
|
||||
unsigned busy:1;
|
||||
unsigned undef:1;
|
||||
} MacroSymbol;
|
||||
|
||||
void FreeMacro(MacroSymbol *);
|
||||
int PredefineMacro(char *);
|
||||
|
||||
void CPPDebugLogMsg(const char *msg); // Prints information into debug log
|
||||
void CPPShInfoLogMsg(const char*); // Store cpp Err Msg into Sh.Info.Log
|
||||
void CPPWarningToInfoLog(const char *msg); // Prints warning messages into info log
|
||||
void HandlePragma(const char**, int numTokens); // #pragma directive container.
|
||||
void ResetTString(void); // #error Message as TString.
|
||||
void CPPErrorToInfoLog(char*); // Stick all cpp errors into Sh.Info.log .
|
||||
void StoreStr(char*); // Store the TString in Parse Context.
|
||||
void SetLineNumber(int); // Set line number.
|
||||
void SetStringNumber(int); // Set string number.
|
||||
int GetLineNumber(void); // Get the current String Number.
|
||||
int GetStringNumber(void); // Get the current String Number.
|
||||
const char* GetStrfromTStr(void); // Convert TString to String.
|
||||
void updateExtensionBehavior(const char* extName, const char* behavior);
|
||||
int FreeCPP(void);
|
||||
|
||||
#endif // !(defined(__CPP_H)
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// cpp.h
|
||||
//
|
||||
|
||||
#if !defined(__CPP_H)
|
||||
#define __CPP_H 1
|
||||
|
||||
#include "parser.h"
|
||||
#include "tokens.h"
|
||||
|
||||
int InitCPP(void);
|
||||
int FinalCPP(void);
|
||||
int readCPPline(yystypepp * yylvalpp);
|
||||
int MacroExpand(int atom, yystypepp * yylvalpp);
|
||||
int ChkCorrectElseNesting(void);
|
||||
|
||||
typedef struct MacroSymbol {
|
||||
int argc;
|
||||
int *args;
|
||||
TokenStream *body;
|
||||
unsigned busy:1;
|
||||
unsigned undef:1;
|
||||
} MacroSymbol;
|
||||
|
||||
void FreeMacro(MacroSymbol *);
|
||||
int PredefineMacro(char *);
|
||||
|
||||
void CPPDebugLogMsg(const char *msg); // Prints information into debug log
|
||||
void CPPShInfoLogMsg(const char*); // Store cpp Err Msg into Sh.Info.Log
|
||||
void CPPWarningToInfoLog(const char *msg); // Prints warning messages into info log
|
||||
void HandlePragma(const char**, int numTokens); // #pragma directive container.
|
||||
void ResetTString(void); // #error Message as TString.
|
||||
void CPPErrorToInfoLog(char*); // Stick all cpp errors into Sh.Info.log .
|
||||
void StoreStr(char*); // Store the TString in Parse Context.
|
||||
void SetLineNumber(int); // Set line number.
|
||||
void SetStringNumber(int); // Set string number.
|
||||
int GetLineNumber(void); // Get the current String Number.
|
||||
int GetStringNumber(void); // Get the current String Number.
|
||||
const char* GetStrfromTStr(void); // Convert TString to String.
|
||||
void updateExtensionBehavior(const char* extName, const char* behavior);
|
||||
int FreeCPP(void);
|
||||
|
||||
#endif // !(defined(__CPP_H)
|
||||
|
|
|
@ -1,220 +1,220 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// cppstruct.c
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
CPPStruct *cpp = NULL;
|
||||
static int refCount = 0;
|
||||
|
||||
int InitPreprocessor(void);
|
||||
int ResetPreprocessor(void);
|
||||
int FreeCPPStruct(void);
|
||||
int FinalizePreprocessor(void);
|
||||
|
||||
/*
|
||||
* InitCPPStruct() - Initilaize the CPP structure.
|
||||
*
|
||||
*/
|
||||
|
||||
int InitCPPStruct(void)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
|
||||
if (cpp == NULL)
|
||||
return 0;
|
||||
|
||||
refCount++;
|
||||
|
||||
// Initialize public members:
|
||||
cpp->pLastSourceLoc = &cpp->lastSourceLoc;
|
||||
|
||||
p = (char *) &cpp->options;
|
||||
len = sizeof(cpp->options);
|
||||
while (--len >= 0)
|
||||
p[len] = 0;
|
||||
|
||||
ResetPreprocessor();
|
||||
return 1;
|
||||
} // InitCPPStruct
|
||||
|
||||
int ResetPreprocessor(void)
|
||||
{
|
||||
// Initialize private members:
|
||||
|
||||
cpp->lastSourceLoc.file = 0;
|
||||
cpp->lastSourceLoc.line = 0;
|
||||
cpp->pC=0;
|
||||
cpp->CompileError=0;
|
||||
cpp->ifdepth=0;
|
||||
for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
|
||||
cpp->elsedepth[cpp->elsetracker]=0;
|
||||
cpp->elsetracker=0;
|
||||
cpp->tokensBeforeEOF = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Intializing the Preprocessor.
|
||||
|
||||
int InitPreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeCPPStruct();
|
||||
InitCPPStruct();
|
||||
cpp->options.Quiet = 1;
|
||||
cpp->options.profileString = "generic";
|
||||
if (!InitAtomTable(atable, 0))
|
||||
return 1;
|
||||
if (!InitScanner(cpp))
|
||||
return 1;
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
//FreeCPPStruct() - Free the CPP structure.
|
||||
|
||||
int FreeCPPStruct(void)
|
||||
{
|
||||
if (refCount)
|
||||
{
|
||||
free(cpp);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Finalizing the Preprocessor.
|
||||
|
||||
int FinalizePreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeAtomTable(atable);
|
||||
FreeCPPStruct();
|
||||
FreeScanner();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////// End of cppstruct.c //////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// cppstruct.c
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
CPPStruct *cpp = NULL;
|
||||
static int refCount = 0;
|
||||
|
||||
int InitPreprocessor(void);
|
||||
int ResetPreprocessor(void);
|
||||
int FreeCPPStruct(void);
|
||||
int FinalizePreprocessor(void);
|
||||
|
||||
/*
|
||||
* InitCPPStruct() - Initilaize the CPP structure.
|
||||
*
|
||||
*/
|
||||
|
||||
int InitCPPStruct(void)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
|
||||
if (cpp == NULL)
|
||||
return 0;
|
||||
|
||||
refCount++;
|
||||
|
||||
// Initialize public members:
|
||||
cpp->pLastSourceLoc = &cpp->lastSourceLoc;
|
||||
|
||||
p = (char *) &cpp->options;
|
||||
len = sizeof(cpp->options);
|
||||
while (--len >= 0)
|
||||
p[len] = 0;
|
||||
|
||||
ResetPreprocessor();
|
||||
return 1;
|
||||
} // InitCPPStruct
|
||||
|
||||
int ResetPreprocessor(void)
|
||||
{
|
||||
// Initialize private members:
|
||||
|
||||
cpp->lastSourceLoc.file = 0;
|
||||
cpp->lastSourceLoc.line = 0;
|
||||
cpp->pC=0;
|
||||
cpp->CompileError=0;
|
||||
cpp->ifdepth=0;
|
||||
for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
|
||||
cpp->elsedepth[cpp->elsetracker]=0;
|
||||
cpp->elsetracker=0;
|
||||
cpp->tokensBeforeEOF = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Intializing the Preprocessor.
|
||||
|
||||
int InitPreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeCPPStruct();
|
||||
InitCPPStruct();
|
||||
cpp->options.Quiet = 1;
|
||||
cpp->options.profileString = "generic";
|
||||
if (!InitAtomTable(atable, 0))
|
||||
return 1;
|
||||
if (!InitScanner(cpp))
|
||||
return 1;
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
//FreeCPPStruct() - Free the CPP structure.
|
||||
|
||||
int FreeCPPStruct(void)
|
||||
{
|
||||
if (refCount)
|
||||
{
|
||||
free(cpp);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Finalizing the Preprocessor.
|
||||
|
||||
int FinalizePreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeAtomTable(atable);
|
||||
FreeCPPStruct();
|
||||
FreeScanner();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////// End of cppstruct.c //////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,228 +1,228 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __STDC99__
|
||||
#include <stdint.h>
|
||||
#elif defined (_WIN64)
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#elif defined (_WIN32)
|
||||
typedef unsigned int uintptr_t;
|
||||
#else
|
||||
typedef unsigned long int uintptr_t;
|
||||
#endif
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
// default alignment and chunksize, if called with 0 arguments
|
||||
#define CHUNKSIZE (64*1024)
|
||||
#define ALIGN 8
|
||||
|
||||
// we need to call the `real' malloc and free, not our replacements
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
struct chunk {
|
||||
struct chunk *next;
|
||||
};
|
||||
|
||||
struct cleanup {
|
||||
struct cleanup *next;
|
||||
void (*fn)(void *);
|
||||
void *arg;
|
||||
};
|
||||
|
||||
struct MemoryPool_rec {
|
||||
struct chunk *next;
|
||||
uintptr_t free, end;
|
||||
size_t chunksize;
|
||||
uintptr_t alignmask;
|
||||
struct cleanup *cleanup;
|
||||
};
|
||||
|
||||
MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
|
||||
{
|
||||
MemoryPool *pool;
|
||||
|
||||
if (align == 0) align = ALIGN;
|
||||
if (chunksize == 0) chunksize = CHUNKSIZE;
|
||||
if (align & (align-1)) return 0;
|
||||
if (chunksize < sizeof(MemoryPool)) return 0;
|
||||
if (chunksize & (align-1)) return 0;
|
||||
if (!(pool = malloc(chunksize))) return 0;
|
||||
pool->next = 0;
|
||||
pool->chunksize = chunksize;
|
||||
pool->alignmask = (uintptr_t)(align)-1;
|
||||
pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;
|
||||
pool->end = (uintptr_t)pool + chunksize;
|
||||
pool->cleanup = 0;
|
||||
return pool;
|
||||
}
|
||||
|
||||
void mem_FreePool(MemoryPool *pool)
|
||||
{
|
||||
struct cleanup *cleanup;
|
||||
struct chunk *p, *next;
|
||||
|
||||
for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
|
||||
cleanup->fn(cleanup->arg);
|
||||
}
|
||||
for (p = (struct chunk *)pool; p; p = next) {
|
||||
next = p->next;
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
void *mem_Alloc(MemoryPool *pool, size_t size)
|
||||
{
|
||||
struct chunk *ch;
|
||||
void *rv = (void *)pool->free;
|
||||
size = (size + pool->alignmask) & ~pool->alignmask;
|
||||
if (size <= 0) size = pool->alignmask;
|
||||
pool->free += size;
|
||||
if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
|
||||
size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
|
||||
& ~pool->alignmask;
|
||||
pool->free = (uintptr_t)rv;
|
||||
if (minreq >= pool->chunksize) {
|
||||
// request size is too big for the chunksize, so allocate it as
|
||||
// a single chunk of the right size
|
||||
ch = malloc(minreq);
|
||||
if (!ch) return 0;
|
||||
} else {
|
||||
ch = malloc(pool->chunksize);
|
||||
if (!ch) return 0;
|
||||
pool->free = (uintptr_t)ch + minreq;
|
||||
pool->end = (uintptr_t)ch + pool->chunksize;
|
||||
}
|
||||
ch->next = pool->next;
|
||||
pool->next = ch;
|
||||
rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
|
||||
struct cleanup *cleanup;
|
||||
|
||||
pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
|
||||
cleanup = mem_Alloc(pool, sizeof(struct cleanup));
|
||||
if (!cleanup) return -1;
|
||||
cleanup->next = pool->cleanup;
|
||||
cleanup->fn = fn;
|
||||
cleanup->arg = arg;
|
||||
pool->cleanup = cleanup;
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __STDC99__
|
||||
#include <stdint.h>
|
||||
#elif defined (_WIN64)
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#elif defined (_WIN32)
|
||||
typedef unsigned int uintptr_t;
|
||||
#else
|
||||
typedef unsigned long int uintptr_t;
|
||||
#endif
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
// default alignment and chunksize, if called with 0 arguments
|
||||
#define CHUNKSIZE (64*1024)
|
||||
#define ALIGN 8
|
||||
|
||||
// we need to call the `real' malloc and free, not our replacements
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
struct chunk {
|
||||
struct chunk *next;
|
||||
};
|
||||
|
||||
struct cleanup {
|
||||
struct cleanup *next;
|
||||
void (*fn)(void *);
|
||||
void *arg;
|
||||
};
|
||||
|
||||
struct MemoryPool_rec {
|
||||
struct chunk *next;
|
||||
uintptr_t free, end;
|
||||
size_t chunksize;
|
||||
uintptr_t alignmask;
|
||||
struct cleanup *cleanup;
|
||||
};
|
||||
|
||||
MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
|
||||
{
|
||||
MemoryPool *pool;
|
||||
|
||||
if (align == 0) align = ALIGN;
|
||||
if (chunksize == 0) chunksize = CHUNKSIZE;
|
||||
if (align & (align-1)) return 0;
|
||||
if (chunksize < sizeof(MemoryPool)) return 0;
|
||||
if (chunksize & (align-1)) return 0;
|
||||
if (!(pool = malloc(chunksize))) return 0;
|
||||
pool->next = 0;
|
||||
pool->chunksize = chunksize;
|
||||
pool->alignmask = (uintptr_t)(align)-1;
|
||||
pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;
|
||||
pool->end = (uintptr_t)pool + chunksize;
|
||||
pool->cleanup = 0;
|
||||
return pool;
|
||||
}
|
||||
|
||||
void mem_FreePool(MemoryPool *pool)
|
||||
{
|
||||
struct cleanup *cleanup;
|
||||
struct chunk *p, *next;
|
||||
|
||||
for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
|
||||
cleanup->fn(cleanup->arg);
|
||||
}
|
||||
for (p = (struct chunk *)pool; p; p = next) {
|
||||
next = p->next;
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
void *mem_Alloc(MemoryPool *pool, size_t size)
|
||||
{
|
||||
struct chunk *ch;
|
||||
void *rv = (void *)pool->free;
|
||||
size = (size + pool->alignmask) & ~pool->alignmask;
|
||||
if (size <= 0) size = pool->alignmask;
|
||||
pool->free += size;
|
||||
if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
|
||||
size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
|
||||
& ~pool->alignmask;
|
||||
pool->free = (uintptr_t)rv;
|
||||
if (minreq >= pool->chunksize) {
|
||||
// request size is too big for the chunksize, so allocate it as
|
||||
// a single chunk of the right size
|
||||
ch = malloc(minreq);
|
||||
if (!ch) return 0;
|
||||
} else {
|
||||
ch = malloc(pool->chunksize);
|
||||
if (!ch) return 0;
|
||||
pool->free = (uintptr_t)ch + minreq;
|
||||
pool->end = (uintptr_t)ch + pool->chunksize;
|
||||
}
|
||||
ch->next = pool->next;
|
||||
pool->next = ch;
|
||||
rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
|
||||
struct cleanup *cleanup;
|
||||
|
||||
pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
|
||||
cleanup = mem_Alloc(pool, sizeof(struct cleanup));
|
||||
if (!cleanup) return -1;
|
||||
cleanup->next = pool->cleanup;
|
||||
cleanup->fn = fn;
|
||||
cleanup->arg = arg;
|
||||
pool->cleanup = cleanup;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,124 +1,124 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
#ifndef __MEMORY_H
|
||||
#define __MEMORY_H
|
||||
|
||||
typedef struct MemoryPool_rec MemoryPool;
|
||||
|
||||
extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
|
||||
extern void mem_FreePool(MemoryPool *);
|
||||
extern void *mem_Alloc(MemoryPool *p, size_t size);
|
||||
extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);
|
||||
extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);
|
||||
|
||||
#endif /* __MEMORY_H */
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
#ifndef __MEMORY_H
|
||||
#define __MEMORY_H
|
||||
|
||||
typedef struct MemoryPool_rec MemoryPool;
|
||||
|
||||
extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
|
||||
extern void mem_FreePool(MemoryPool *);
|
||||
extern void *mem_Alloc(MemoryPool *p, size_t size);
|
||||
extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);
|
||||
extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);
|
||||
|
||||
#endif /* __MEMORY_H */
|
||||
|
|
|
@ -1,161 +1,161 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
#ifndef BISON_PARSER_H
|
||||
# define BISON_PARSER_H
|
||||
|
||||
#ifndef yystypepp
|
||||
typedef struct {
|
||||
int sc_int;
|
||||
float sc_fval;
|
||||
int sc_ident;
|
||||
char symbol_name[MAX_SYMBOL_NAME_LEN+1];
|
||||
} yystypepp;
|
||||
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
# define CPP_AND_OP 257
|
||||
# define CPP_SUB_ASSIGN 259
|
||||
# define CPP_MOD_ASSIGN 260
|
||||
# define CPP_ADD_ASSIGN 261
|
||||
# define CPP_DIV_ASSIGN 262
|
||||
# define CPP_MUL_ASSIGN 263
|
||||
# define CPP_EQ_OP 264
|
||||
# define CPP_XOR_OP 265
|
||||
# define ERROR_SY 266
|
||||
# define CPP_FLOATCONSTANT 267
|
||||
# define CPP_GE_OP 268
|
||||
# define CPP_RIGHT_OP 269
|
||||
# define CPP_IDENTIFIER 270
|
||||
# define CPP_INTCONSTANT 271
|
||||
# define CPP_LE_OP 272
|
||||
# define CPP_LEFT_OP 273
|
||||
# define CPP_DEC_OP 274
|
||||
# define CPP_NE_OP 275
|
||||
# define CPP_OR_OP 276
|
||||
# define CPP_INC_OP 277
|
||||
# define CPP_STRCONSTANT 278
|
||||
# define CPP_TYPEIDENTIFIER 279
|
||||
|
||||
# define FIRST_USER_TOKEN_SY 289
|
||||
|
||||
# define CPP_RIGHT_ASSIGN 280
|
||||
# define CPP_LEFT_ASSIGN 281
|
||||
# define CPP_AND_ASSIGN 282
|
||||
# define CPP_OR_ASSIGN 283
|
||||
# define CPP_XOR_ASSIGN 284
|
||||
# define CPP_LEFT_BRACKET 285
|
||||
# define CPP_RIGHT_BRACKET 286
|
||||
# define CPP_LEFT_BRACE 287
|
||||
# define CPP_RIGHT_BRACE 288
|
||||
|
||||
#endif /* not BISON_PARSER_H */
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
#ifndef BISON_PARSER_H
|
||||
# define BISON_PARSER_H
|
||||
|
||||
#ifndef yystypepp
|
||||
typedef struct {
|
||||
int sc_int;
|
||||
float sc_fval;
|
||||
int sc_ident;
|
||||
char symbol_name[MAX_SYMBOL_NAME_LEN+1];
|
||||
} yystypepp;
|
||||
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
# define CPP_AND_OP 257
|
||||
# define CPP_SUB_ASSIGN 259
|
||||
# define CPP_MOD_ASSIGN 260
|
||||
# define CPP_ADD_ASSIGN 261
|
||||
# define CPP_DIV_ASSIGN 262
|
||||
# define CPP_MUL_ASSIGN 263
|
||||
# define CPP_EQ_OP 264
|
||||
# define CPP_XOR_OP 265
|
||||
# define ERROR_SY 266
|
||||
# define CPP_FLOATCONSTANT 267
|
||||
# define CPP_GE_OP 268
|
||||
# define CPP_RIGHT_OP 269
|
||||
# define CPP_IDENTIFIER 270
|
||||
# define CPP_INTCONSTANT 271
|
||||
# define CPP_LE_OP 272
|
||||
# define CPP_LEFT_OP 273
|
||||
# define CPP_DEC_OP 274
|
||||
# define CPP_NE_OP 275
|
||||
# define CPP_OR_OP 276
|
||||
# define CPP_INC_OP 277
|
||||
# define CPP_STRCONSTANT 278
|
||||
# define CPP_TYPEIDENTIFIER 279
|
||||
|
||||
# define FIRST_USER_TOKEN_SY 289
|
||||
|
||||
# define CPP_RIGHT_ASSIGN 280
|
||||
# define CPP_LEFT_ASSIGN 281
|
||||
# define CPP_AND_ASSIGN 282
|
||||
# define CPP_OR_ASSIGN 283
|
||||
# define CPP_XOR_ASSIGN 284
|
||||
# define CPP_LEFT_BRACKET 285
|
||||
# define CPP_RIGHT_BRACKET 286
|
||||
# define CPP_LEFT_BRACE 287
|
||||
# define CPP_RIGHT_BRACE 288
|
||||
|
||||
#endif /* not BISON_PARSER_H */
|
||||
|
|
|
@ -1,119 +1,119 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
# include "slglobals.h"
|
||||
extern CPPStruct *cpp;
|
||||
int InitCPPStruct(void);
|
||||
int InitScanner(CPPStruct *cpp);
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
int ScanFromString(char *s);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
# include "slglobals.h"
|
||||
extern CPPStruct *cpp;
|
||||
int InitCPPStruct(void);
|
||||
int InitScanner(CPPStruct *cpp);
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
int ScanFromString(char *s);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,153 +1,153 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// scanner.h
|
||||
//
|
||||
|
||||
#if !defined(__SCANNER_H)
|
||||
#define __SCANNER_H 1
|
||||
|
||||
#define MAX_SYMBOL_NAME_LEN 128
|
||||
#define MAX_STRING_LEN 512
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
// Not really atom table stuff but needed first...
|
||||
|
||||
typedef struct SourceLoc_Rec {
|
||||
unsigned short file, line;
|
||||
} SourceLoc;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
int yylex_CPP(char* buf, int maxSize);
|
||||
|
||||
typedef struct InputSrc {
|
||||
struct InputSrc *prev;
|
||||
int (*scan)(struct InputSrc *, yystypepp *);
|
||||
int (*getch)(struct InputSrc *, yystypepp *);
|
||||
void (*ungetch)(struct InputSrc *, int, yystypepp *);
|
||||
int name; /* atom */
|
||||
int line;
|
||||
} InputSrc;
|
||||
|
||||
int InitScanner(CPPStruct *cpp); // Intialise the cpp scanner.
|
||||
int ScanFromString(char *); // Start scanning the input from the string mentioned.
|
||||
int check_EOF(int); // check if we hit a EOF abruptly
|
||||
void CPPErrorToInfoLog(char *); // sticking the msg,line into the Shader's.Info.log
|
||||
void SetLineNumber(int);
|
||||
void SetStringNumber(int);
|
||||
void IncLineNumber(void);
|
||||
void DecLineNumber(void);
|
||||
int FreeScanner(void); // Free the cpp scanner
|
||||
#endif // !(defined(__SCANNER_H)
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// scanner.h
|
||||
//
|
||||
|
||||
#if !defined(__SCANNER_H)
|
||||
#define __SCANNER_H 1
|
||||
|
||||
#define MAX_SYMBOL_NAME_LEN 128
|
||||
#define MAX_STRING_LEN 512
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
// Not really atom table stuff but needed first...
|
||||
|
||||
typedef struct SourceLoc_Rec {
|
||||
unsigned short file, line;
|
||||
} SourceLoc;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
int yylex_CPP(char* buf, int maxSize);
|
||||
|
||||
typedef struct InputSrc {
|
||||
struct InputSrc *prev;
|
||||
int (*scan)(struct InputSrc *, yystypepp *);
|
||||
int (*getch)(struct InputSrc *, yystypepp *);
|
||||
void (*ungetch)(struct InputSrc *, int, yystypepp *);
|
||||
int name; /* atom */
|
||||
int line;
|
||||
} InputSrc;
|
||||
|
||||
int InitScanner(CPPStruct *cpp); // Intialise the cpp scanner.
|
||||
int ScanFromString(char *); // Start scanning the input from the string mentioned.
|
||||
int check_EOF(int); // check if we hit a EOF abruptly
|
||||
void CPPErrorToInfoLog(char *); // sticking the msg,line into the Shader's.Info.log
|
||||
void SetLineNumber(int);
|
||||
void SetStringNumber(int);
|
||||
void IncLineNumber(void);
|
||||
void DecLineNumber(void);
|
||||
int FreeScanner(void); // Free the cpp scanner
|
||||
#endif // !(defined(__SCANNER_H)
|
||||
|
||||
|
|
|
@ -1,150 +1,150 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// slglobals.h
|
||||
//
|
||||
|
||||
#if !defined(__SLGLOBALS_H)
|
||||
#define __SLGLOBALS_H 1
|
||||
|
||||
typedef struct CPPStruct_Rec CPPStruct;
|
||||
|
||||
extern CPPStruct *cpp;
|
||||
|
||||
#undef CPPC_DEBUG_THE_COMPILER
|
||||
#if defined(_DEBUG)
|
||||
#define CPPC_DEBUG_THE_COMPILER 1
|
||||
#endif
|
||||
|
||||
#undef CPPC_ENABLE_TOOLS
|
||||
#define CPPC_ENABLE_TOOLS 1
|
||||
|
||||
#include "memory.h"
|
||||
#include "atom.h"
|
||||
#include "scanner.h"
|
||||
#include "cpp.h"
|
||||
#include "tokens.h"
|
||||
#include "symbols.h"
|
||||
#include "compile.h"
|
||||
#if !defined(NO_PARSER)
|
||||
#include "parser.h"
|
||||
#endif
|
||||
|
||||
#if !defined(NULL)
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif // !(defined(__SLGLOBALS_H)
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// slglobals.h
|
||||
//
|
||||
|
||||
#if !defined(__SLGLOBALS_H)
|
||||
#define __SLGLOBALS_H 1
|
||||
|
||||
typedef struct CPPStruct_Rec CPPStruct;
|
||||
|
||||
extern CPPStruct *cpp;
|
||||
|
||||
#undef CPPC_DEBUG_THE_COMPILER
|
||||
#if defined(_DEBUG)
|
||||
#define CPPC_DEBUG_THE_COMPILER 1
|
||||
#endif
|
||||
|
||||
#undef CPPC_ENABLE_TOOLS
|
||||
#define CPPC_ENABLE_TOOLS 1
|
||||
|
||||
#include "memory.h"
|
||||
#include "atom.h"
|
||||
#include "scanner.h"
|
||||
#include "cpp.h"
|
||||
#include "tokens.h"
|
||||
#include "symbols.h"
|
||||
#include "compile.h"
|
||||
#if !defined(NO_PARSER)
|
||||
#include "parser.h"
|
||||
#endif
|
||||
|
||||
#if !defined(NULL)
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif // !(defined(__SLGLOBALS_H)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,353 +1,353 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// symbols.c
|
||||
//
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Scope *ScopeList = NULL;
|
||||
Scope *CurrentScope = NULL;
|
||||
Scope *GlobalScope = NULL;
|
||||
|
||||
static void unlinkScope(void *_scope) {
|
||||
Scope *scope = _scope;
|
||||
|
||||
if (scope->next)
|
||||
scope->next->prev = scope->prev;
|
||||
if (scope->prev)
|
||||
scope->prev->next = scope->next;
|
||||
else
|
||||
ScopeList = scope->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* NewScope()
|
||||
*
|
||||
*/
|
||||
Scope *NewScopeInPool(MemoryPool *pool)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = mem_Alloc(pool, sizeof(Scope));
|
||||
lScope->pool = pool;
|
||||
lScope->parent = NULL;
|
||||
lScope->funScope = NULL;
|
||||
lScope->symbols = NULL;
|
||||
|
||||
lScope->level = 0;
|
||||
|
||||
lScope->programs = NULL;
|
||||
if ((lScope->next = ScopeList))
|
||||
ScopeList->prev = lScope;
|
||||
lScope->prev = 0;
|
||||
ScopeList = lScope;
|
||||
mem_AddCleanup(pool, unlinkScope, lScope);
|
||||
return lScope;
|
||||
} // NewScope
|
||||
|
||||
/*
|
||||
* PushScope()
|
||||
*
|
||||
*/
|
||||
|
||||
void PushScope(Scope *fScope)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
if (CurrentScope) {
|
||||
fScope->level = CurrentScope->level + 1;
|
||||
if (fScope->level == 1) {
|
||||
if (!GlobalScope) {
|
||||
/* HACK - CTD -- if GlobalScope==NULL and level==1, we're
|
||||
* defining a function in the superglobal scope. Things
|
||||
* will break if we leave the level as 1, so we arbitrarily
|
||||
* set it to 2 */
|
||||
fScope->level = 2;
|
||||
}
|
||||
}
|
||||
if (fScope->level >= 2) {
|
||||
lScope = fScope;
|
||||
while (lScope->level > 2)
|
||||
lScope = lScope->next;
|
||||
fScope->funScope = lScope;
|
||||
}
|
||||
} else {
|
||||
fScope->level = 0;
|
||||
}
|
||||
fScope->parent = CurrentScope;
|
||||
CurrentScope = fScope;
|
||||
} // PushScope
|
||||
|
||||
/*
|
||||
* PopScope()
|
||||
*
|
||||
*/
|
||||
|
||||
Scope *PopScope(void)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = CurrentScope;
|
||||
if (CurrentScope)
|
||||
CurrentScope = CurrentScope->parent;
|
||||
return lScope;
|
||||
} // PopScope
|
||||
|
||||
/*
|
||||
* NewSymbol() - Allocate a new symbol node;
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
char *pch;
|
||||
int ii;
|
||||
|
||||
lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));
|
||||
lSymb->left = NULL;
|
||||
lSymb->right = NULL;
|
||||
lSymb->next = NULL;
|
||||
lSymb->name = name;
|
||||
lSymb->loc = *loc;
|
||||
lSymb->kind = kind;
|
||||
|
||||
// Clear union area:
|
||||
|
||||
pch = (char *) &lSymb->details;
|
||||
for (ii = 0; ii < sizeof(lSymb->details); ii++)
|
||||
*pch++ = 0;
|
||||
return lSymb;
|
||||
} // NewSymbol
|
||||
|
||||
/*
|
||||
* lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
|
||||
* are generated in order. We'll fix this later (by reversing the bit pattern).
|
||||
*/
|
||||
|
||||
static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int lrev, frev;
|
||||
|
||||
lSymb = *fSymbols;
|
||||
if (lSymb) {
|
||||
frev = GetReversedAtom(atable, fSymb->name);
|
||||
while (lSymb) {
|
||||
lrev = GetReversedAtom(atable, lSymb->name);
|
||||
if (lrev == frev) {
|
||||
CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");
|
||||
break;
|
||||
} else {
|
||||
if (lrev > frev) {
|
||||
if (lSymb->left) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb->left = fSymb;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (lSymb->right) {
|
||||
lSymb = lSymb->right;
|
||||
} else {
|
||||
lSymb->right = fSymb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*fSymbols = fSymb;
|
||||
}
|
||||
} // lAddToTree
|
||||
|
||||
|
||||
/*
|
||||
* AddSymbol() - Add a variable, type, or function name to a scope.
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = NewSymbol(loc, fScope, atom, kind);
|
||||
lAddToTree(&fScope->symbols, lSymb);
|
||||
return lSymb;
|
||||
} // AddSymbol
|
||||
|
||||
|
||||
/*********************************************************************************************/
|
||||
/************************************ Symbol Semantic Functions ******************************/
|
||||
/*********************************************************************************************/
|
||||
|
||||
/*
|
||||
* LookUpLocalSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int rname, ratom;
|
||||
|
||||
ratom = GetReversedAtom(atable, atom);
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = fScope->symbols;
|
||||
while (lSymb) {
|
||||
rname = GetReversedAtom(atable, lSymb->name);
|
||||
if (rname == ratom) {
|
||||
return lSymb;
|
||||
} else {
|
||||
if (rname > ratom) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb = lSymb->right;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} // LookUpLocalSymbol
|
||||
|
||||
/*
|
||||
* LookUpSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
while (fScope) {
|
||||
lSymb = LookUpLocalSymbol(fScope, atom);
|
||||
if (lSymb)
|
||||
return lSymb;
|
||||
fScope = fScope->parent;
|
||||
}
|
||||
return NULL;
|
||||
} // LookUpSymbol
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// symbols.c
|
||||
//
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Scope *ScopeList = NULL;
|
||||
Scope *CurrentScope = NULL;
|
||||
Scope *GlobalScope = NULL;
|
||||
|
||||
static void unlinkScope(void *_scope) {
|
||||
Scope *scope = _scope;
|
||||
|
||||
if (scope->next)
|
||||
scope->next->prev = scope->prev;
|
||||
if (scope->prev)
|
||||
scope->prev->next = scope->next;
|
||||
else
|
||||
ScopeList = scope->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* NewScope()
|
||||
*
|
||||
*/
|
||||
Scope *NewScopeInPool(MemoryPool *pool)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = mem_Alloc(pool, sizeof(Scope));
|
||||
lScope->pool = pool;
|
||||
lScope->parent = NULL;
|
||||
lScope->funScope = NULL;
|
||||
lScope->symbols = NULL;
|
||||
|
||||
lScope->level = 0;
|
||||
|
||||
lScope->programs = NULL;
|
||||
if ((lScope->next = ScopeList))
|
||||
ScopeList->prev = lScope;
|
||||
lScope->prev = 0;
|
||||
ScopeList = lScope;
|
||||
mem_AddCleanup(pool, unlinkScope, lScope);
|
||||
return lScope;
|
||||
} // NewScope
|
||||
|
||||
/*
|
||||
* PushScope()
|
||||
*
|
||||
*/
|
||||
|
||||
void PushScope(Scope *fScope)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
if (CurrentScope) {
|
||||
fScope->level = CurrentScope->level + 1;
|
||||
if (fScope->level == 1) {
|
||||
if (!GlobalScope) {
|
||||
/* HACK - CTD -- if GlobalScope==NULL and level==1, we're
|
||||
* defining a function in the superglobal scope. Things
|
||||
* will break if we leave the level as 1, so we arbitrarily
|
||||
* set it to 2 */
|
||||
fScope->level = 2;
|
||||
}
|
||||
}
|
||||
if (fScope->level >= 2) {
|
||||
lScope = fScope;
|
||||
while (lScope->level > 2)
|
||||
lScope = lScope->next;
|
||||
fScope->funScope = lScope;
|
||||
}
|
||||
} else {
|
||||
fScope->level = 0;
|
||||
}
|
||||
fScope->parent = CurrentScope;
|
||||
CurrentScope = fScope;
|
||||
} // PushScope
|
||||
|
||||
/*
|
||||
* PopScope()
|
||||
*
|
||||
*/
|
||||
|
||||
Scope *PopScope(void)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = CurrentScope;
|
||||
if (CurrentScope)
|
||||
CurrentScope = CurrentScope->parent;
|
||||
return lScope;
|
||||
} // PopScope
|
||||
|
||||
/*
|
||||
* NewSymbol() - Allocate a new symbol node;
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
char *pch;
|
||||
int ii;
|
||||
|
||||
lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));
|
||||
lSymb->left = NULL;
|
||||
lSymb->right = NULL;
|
||||
lSymb->next = NULL;
|
||||
lSymb->name = name;
|
||||
lSymb->loc = *loc;
|
||||
lSymb->kind = kind;
|
||||
|
||||
// Clear union area:
|
||||
|
||||
pch = (char *) &lSymb->details;
|
||||
for (ii = 0; ii < sizeof(lSymb->details); ii++)
|
||||
*pch++ = 0;
|
||||
return lSymb;
|
||||
} // NewSymbol
|
||||
|
||||
/*
|
||||
* lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
|
||||
* are generated in order. We'll fix this later (by reversing the bit pattern).
|
||||
*/
|
||||
|
||||
static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int lrev, frev;
|
||||
|
||||
lSymb = *fSymbols;
|
||||
if (lSymb) {
|
||||
frev = GetReversedAtom(atable, fSymb->name);
|
||||
while (lSymb) {
|
||||
lrev = GetReversedAtom(atable, lSymb->name);
|
||||
if (lrev == frev) {
|
||||
CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");
|
||||
break;
|
||||
} else {
|
||||
if (lrev > frev) {
|
||||
if (lSymb->left) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb->left = fSymb;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (lSymb->right) {
|
||||
lSymb = lSymb->right;
|
||||
} else {
|
||||
lSymb->right = fSymb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*fSymbols = fSymb;
|
||||
}
|
||||
} // lAddToTree
|
||||
|
||||
|
||||
/*
|
||||
* AddSymbol() - Add a variable, type, or function name to a scope.
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = NewSymbol(loc, fScope, atom, kind);
|
||||
lAddToTree(&fScope->symbols, lSymb);
|
||||
return lSymb;
|
||||
} // AddSymbol
|
||||
|
||||
|
||||
/*********************************************************************************************/
|
||||
/************************************ Symbol Semantic Functions ******************************/
|
||||
/*********************************************************************************************/
|
||||
|
||||
/*
|
||||
* LookUpLocalSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int rname, ratom;
|
||||
|
||||
ratom = GetReversedAtom(atable, atom);
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = fScope->symbols;
|
||||
while (lSymb) {
|
||||
rname = GetReversedAtom(atable, lSymb->name);
|
||||
if (rname == ratom) {
|
||||
return lSymb;
|
||||
} else {
|
||||
if (rname > ratom) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb = lSymb->right;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} // LookUpLocalSymbol
|
||||
|
||||
/*
|
||||
* LookUpSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
while (fScope) {
|
||||
lSymb = LookUpLocalSymbol(fScope, atom);
|
||||
if (lSymb)
|
||||
return lSymb;
|
||||
fScope = fScope->parent;
|
||||
}
|
||||
return NULL;
|
||||
} // LookUpSymbol
|
||||
|
||||
|
|
|
@ -1,180 +1,180 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// symbols.h
|
||||
//
|
||||
|
||||
#if !defined(__SYMBOLS_H)
|
||||
#define __SYMBOLS_H 1
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
typedef enum symbolkind {
|
||||
MACRO_S
|
||||
} symbolkind;
|
||||
|
||||
// Typedefs for things defined here in "symbols.h":
|
||||
|
||||
typedef struct Scope_Rec Scope;
|
||||
typedef struct Symbol_Rec Symbol;
|
||||
|
||||
typedef struct SymbolList_Rec {
|
||||
struct SymbolList_Rec *next;
|
||||
Symbol *symb;
|
||||
} SymbolList;
|
||||
|
||||
struct Scope_Rec {
|
||||
Scope *next, *prev; // doubly-linked list of all scopes
|
||||
Scope *parent;
|
||||
Scope *funScope; // Points to base scope of enclosing function
|
||||
MemoryPool *pool; // pool used for allocation in this scope
|
||||
Symbol *symbols;
|
||||
|
||||
int level; // 0 = super globals, 1 = globals, etc.
|
||||
|
||||
// Only used at global scope (level 1):
|
||||
SymbolList *programs; // List of programs for this compilation.
|
||||
};
|
||||
|
||||
|
||||
// Symbol table is a simple binary tree.
|
||||
|
||||
#include "cpp.h" // to get MacroSymbol def
|
||||
|
||||
struct Symbol_Rec {
|
||||
Symbol *left, *right;
|
||||
Symbol *next;
|
||||
int name; // Name atom
|
||||
SourceLoc loc;
|
||||
symbolkind kind;
|
||||
union {
|
||||
MacroSymbol mac;
|
||||
} details;
|
||||
};
|
||||
|
||||
extern Scope *CurrentScope;
|
||||
extern Scope *GlobalScope;
|
||||
extern Scope *ScopeList;
|
||||
|
||||
Scope *NewScopeInPool(MemoryPool *);
|
||||
#define NewScope() NewScopeInPool(CurrentScope->pool)
|
||||
void PushScope(Scope *fScope);
|
||||
Scope *PopScope(void);
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom);
|
||||
void CPPErrorToInfoLog(char *);
|
||||
|
||||
|
||||
#endif // !defined(__SYMBOLS_H)
|
||||
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// symbols.h
|
||||
//
|
||||
|
||||
#if !defined(__SYMBOLS_H)
|
||||
#define __SYMBOLS_H 1
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
typedef enum symbolkind {
|
||||
MACRO_S
|
||||
} symbolkind;
|
||||
|
||||
// Typedefs for things defined here in "symbols.h":
|
||||
|
||||
typedef struct Scope_Rec Scope;
|
||||
typedef struct Symbol_Rec Symbol;
|
||||
|
||||
typedef struct SymbolList_Rec {
|
||||
struct SymbolList_Rec *next;
|
||||
Symbol *symb;
|
||||
} SymbolList;
|
||||
|
||||
struct Scope_Rec {
|
||||
Scope *next, *prev; // doubly-linked list of all scopes
|
||||
Scope *parent;
|
||||
Scope *funScope; // Points to base scope of enclosing function
|
||||
MemoryPool *pool; // pool used for allocation in this scope
|
||||
Symbol *symbols;
|
||||
|
||||
int level; // 0 = super globals, 1 = globals, etc.
|
||||
|
||||
// Only used at global scope (level 1):
|
||||
SymbolList *programs; // List of programs for this compilation.
|
||||
};
|
||||
|
||||
|
||||
// Symbol table is a simple binary tree.
|
||||
|
||||
#include "cpp.h" // to get MacroSymbol def
|
||||
|
||||
struct Symbol_Rec {
|
||||
Symbol *left, *right;
|
||||
Symbol *next;
|
||||
int name; // Name atom
|
||||
SourceLoc loc;
|
||||
symbolkind kind;
|
||||
union {
|
||||
MacroSymbol mac;
|
||||
} details;
|
||||
};
|
||||
|
||||
extern Scope *CurrentScope;
|
||||
extern Scope *GlobalScope;
|
||||
extern Scope *ScopeList;
|
||||
|
||||
Scope *NewScopeInPool(MemoryPool *);
|
||||
#define NewScope() NewScopeInPool(CurrentScope->pool)
|
||||
void PushScope(Scope *fScope);
|
||||
Scope *PopScope(void);
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom);
|
||||
void CPPErrorToInfoLog(char *);
|
||||
|
||||
|
||||
#endif // !defined(__SYMBOLS_H)
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,157 +1,157 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// tokens.h
|
||||
//
|
||||
|
||||
#if !defined(__TOKENS_H)
|
||||
#define __TOKENS_H 1
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#define EOF_SY (-1)
|
||||
|
||||
typedef struct TokenBlock_Rec TokenBlockStruct;
|
||||
|
||||
typedef struct TokenStream_Rec {
|
||||
struct TokenStream_Rec *next;
|
||||
char *name;
|
||||
TokenBlockStruct *head;
|
||||
TokenBlockStruct *current;
|
||||
} TokenStream;
|
||||
|
||||
struct TokenBlock_Rec {
|
||||
TokenBlockStruct *next;
|
||||
int current;
|
||||
int count;
|
||||
int max;
|
||||
unsigned char *data;
|
||||
};
|
||||
|
||||
extern TokenStream stdlib_cpp_stream;
|
||||
|
||||
|
||||
TokenStream *NewTokenStream(const char *name, MemoryPool *pool);
|
||||
void DeleteTokenStream(TokenStream *pTok);
|
||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
|
||||
void RewindTokenStream(TokenStream *pTok);
|
||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
|
||||
int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
|
||||
void UngetToken(int, yystypepp * yylvalpp);
|
||||
|
||||
#if defined(CPPC_ENABLE_TOOLS)
|
||||
|
||||
void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
|
||||
|
||||
#endif // defined(CPPC_ENABLE_TOOLS)
|
||||
|
||||
#endif // !defined(__TOKENS_H)
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// tokens.h
|
||||
//
|
||||
|
||||
#if !defined(__TOKENS_H)
|
||||
#define __TOKENS_H 1
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#define EOF_SY (-1)
|
||||
|
||||
typedef struct TokenBlock_Rec TokenBlockStruct;
|
||||
|
||||
typedef struct TokenStream_Rec {
|
||||
struct TokenStream_Rec *next;
|
||||
char *name;
|
||||
TokenBlockStruct *head;
|
||||
TokenBlockStruct *current;
|
||||
} TokenStream;
|
||||
|
||||
struct TokenBlock_Rec {
|
||||
TokenBlockStruct *next;
|
||||
int current;
|
||||
int count;
|
||||
int max;
|
||||
unsigned char *data;
|
||||
};
|
||||
|
||||
extern TokenStream stdlib_cpp_stream;
|
||||
|
||||
|
||||
TokenStream *NewTokenStream(const char *name, MemoryPool *pool);
|
||||
void DeleteTokenStream(TokenStream *pTok);
|
||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
|
||||
void RewindTokenStream(TokenStream *pTok);
|
||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
|
||||
int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
|
||||
void UngetToken(int, yystypepp * yylvalpp);
|
||||
|
||||
#if defined(CPPC_ENABLE_TOOLS)
|
||||
|
||||
void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
|
||||
|
||||
#endif // defined(CPPC_ENABLE_TOOLS)
|
||||
|
||||
#endif // !defined(__TOKENS_H)
|
||||
|
|
|
@ -1 +1 @@
|
|||
// This is a NULL file and is meant to be empty
|
||||
// This is a NULL file and is meant to be empty
|
||||
|
|
|
@ -1,112 +1,112 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef __OSINCLUDE_H
|
||||
#define __OSINCLUDE_H
|
||||
|
||||
//
|
||||
// This file contains any Linux specific functions.
|
||||
//
|
||||
|
||||
#if !(defined(linux))
|
||||
#error Trying to include a Linux specific file in a non-Linux build.
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include "Include/InitializeGlobals.h"
|
||||
#include "Include/PoolAlloc.h"
|
||||
|
||||
#define _vsnprintf vsnprintf
|
||||
|
||||
|
||||
void DetachThreadLinux(void *);
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
typedef unsigned int OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
|
||||
|
||||
OS_TLSIndex OS_AllocTLSIndex();
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
||||
|
||||
|
||||
inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||
{
|
||||
//
|
||||
// This function should return 0 if nIndex is invalid.
|
||||
//
|
||||
assert(nIndex != OS_INVALID_TLS_INDEX);
|
||||
return pthread_getspecific(nIndex);
|
||||
}
|
||||
|
||||
#endif // __OSINCLUDE_H
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef __OSINCLUDE_H
|
||||
#define __OSINCLUDE_H
|
||||
|
||||
//
|
||||
// This file contains any Linux specific functions.
|
||||
//
|
||||
|
||||
#if !(defined(linux))
|
||||
#error Trying to include a Linux specific file in a non-Linux build.
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include "Include/InitializeGlobals.h"
|
||||
#include "Include/PoolAlloc.h"
|
||||
|
||||
#define _vsnprintf vsnprintf
|
||||
|
||||
|
||||
void DetachThreadLinux(void *);
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
typedef unsigned int OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
|
||||
|
||||
OS_TLSIndex OS_AllocTLSIndex();
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
||||
|
||||
|
||||
inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||
{
|
||||
//
|
||||
// This function should return 0 if nIndex is invalid.
|
||||
//
|
||||
assert(nIndex != OS_INVALID_TLS_INDEX);
|
||||
return pthread_getspecific(nIndex);
|
||||
}
|
||||
|
||||
#endif // __OSINCLUDE_H
|
||||
|
|
|
@ -1,175 +1,175 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
// This file contains the Linux specific functions
|
||||
//
|
||||
#include "osinclude.h"
|
||||
#include "InitializeDll.h"
|
||||
|
||||
#if !(defined(linux))
|
||||
#error Trying to build a Linux specific file in a non-Linux build.
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Thread cleanup
|
||||
//
|
||||
|
||||
//
|
||||
// Wrapper for Linux call to DetachThread. This is required as pthread_cleanup_push() expects
|
||||
// the cleanup routine to return void.
|
||||
//
|
||||
void DetachThreadLinux(void *)
|
||||
{
|
||||
DetachThread();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Registers cleanup handler, sets cancel type and state, and excecutes the thread specific
|
||||
// cleanup handler. This function will be called in the Standalone.cpp for regression
|
||||
// testing. When OpenGL applications are run with the driver code, Linux OS does the
|
||||
// thread cleanup.
|
||||
//
|
||||
void OS_CleanupThreadData(void)
|
||||
{
|
||||
int old_cancel_state, old_cancel_type;
|
||||
void *cleanupArg = NULL;
|
||||
|
||||
//
|
||||
// Set thread cancel state and push cleanup handler.
|
||||
//
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancel_state);
|
||||
pthread_cleanup_push(DetachThreadLinux, (void *) cleanupArg);
|
||||
|
||||
//
|
||||
// Put the thread in deferred cancellation mode.
|
||||
//
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &old_cancel_type);
|
||||
|
||||
//
|
||||
// Pop cleanup handler and execute it prior to unregistering the cleanup handler.
|
||||
//
|
||||
pthread_cleanup_pop(1);
|
||||
|
||||
//
|
||||
// Restore the thread's previous cancellation mode.
|
||||
//
|
||||
pthread_setcanceltype(old_cancel_state, NULL);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
OS_TLSIndex OS_AllocTLSIndex()
|
||||
{
|
||||
pthread_key_t pPoolIndex;
|
||||
|
||||
//
|
||||
// Create global pool key.
|
||||
//
|
||||
if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
|
||||
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return pPoolIndex;
|
||||
}
|
||||
|
||||
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
|
||||
{
|
||||
if (nIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pthread_setspecific(nIndex, lpvValue) == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
||||
{
|
||||
if (nIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Delete the global pool key.
|
||||
//
|
||||
if (pthread_key_delete(nIndex) == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
// This file contains the Linux specific functions
|
||||
//
|
||||
#include "osinclude.h"
|
||||
#include "InitializeDll.h"
|
||||
|
||||
#if !(defined(linux))
|
||||
#error Trying to build a Linux specific file in a non-Linux build.
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Thread cleanup
|
||||
//
|
||||
|
||||
//
|
||||
// Wrapper for Linux call to DetachThread. This is required as pthread_cleanup_push() expects
|
||||
// the cleanup routine to return void.
|
||||
//
|
||||
void DetachThreadLinux(void *)
|
||||
{
|
||||
DetachThread();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Registers cleanup handler, sets cancel type and state, and excecutes the thread specific
|
||||
// cleanup handler. This function will be called in the Standalone.cpp for regression
|
||||
// testing. When OpenGL applications are run with the driver code, Linux OS does the
|
||||
// thread cleanup.
|
||||
//
|
||||
void OS_CleanupThreadData(void)
|
||||
{
|
||||
int old_cancel_state, old_cancel_type;
|
||||
void *cleanupArg = NULL;
|
||||
|
||||
//
|
||||
// Set thread cancel state and push cleanup handler.
|
||||
//
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancel_state);
|
||||
pthread_cleanup_push(DetachThreadLinux, (void *) cleanupArg);
|
||||
|
||||
//
|
||||
// Put the thread in deferred cancellation mode.
|
||||
//
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &old_cancel_type);
|
||||
|
||||
//
|
||||
// Pop cleanup handler and execute it prior to unregistering the cleanup handler.
|
||||
//
|
||||
pthread_cleanup_pop(1);
|
||||
|
||||
//
|
||||
// Restore the thread's previous cancellation mode.
|
||||
//
|
||||
pthread_setcanceltype(old_cancel_state, NULL);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
OS_TLSIndex OS_AllocTLSIndex()
|
||||
{
|
||||
pthread_key_t pPoolIndex;
|
||||
|
||||
//
|
||||
// Create global pool key.
|
||||
//
|
||||
if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
|
||||
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return pPoolIndex;
|
||||
}
|
||||
|
||||
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
|
||||
{
|
||||
if (nIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pthread_setspecific(nIndex, lpvValue) == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
||||
{
|
||||
if (nIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Delete the global pool key.
|
||||
//
|
||||
if (pthread_key_delete(nIndex) == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,65 +1,65 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef __OSINCLUDE_H
|
||||
#define __OSINCLUDE_H
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define min(X,Y) ((X) < (Y) ? X : Y)
|
||||
#define _vsnprintf vsnprintf
|
||||
#define _stricmp stricmp
|
||||
|
||||
//
|
||||
// string manipulation
|
||||
//
|
||||
int stricmp(const char *str1, const char *str2);
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
#define OS_INVALID_TLS_INDEX 0
|
||||
|
||||
typedef pthread_key_t OS_TLSIndex;
|
||||
|
||||
OS_TLSIndex OS_AllocTLSIndex();
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
||||
inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||
{
|
||||
return pthread_getspecific(nIndex);
|
||||
}
|
||||
|
||||
#endif // __OSINCLUDE_H
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef __OSINCLUDE_H
|
||||
#define __OSINCLUDE_H
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define min(X,Y) ((X) < (Y) ? X : Y)
|
||||
#define _vsnprintf vsnprintf
|
||||
#define _stricmp stricmp
|
||||
|
||||
//
|
||||
// string manipulation
|
||||
//
|
||||
int stricmp(const char *str1, const char *str2);
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
#define OS_INVALID_TLS_INDEX 0
|
||||
|
||||
typedef pthread_key_t OS_TLSIndex;
|
||||
|
||||
OS_TLSIndex OS_AllocTLSIndex();
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
||||
inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||
{
|
||||
return pthread_getspecific(nIndex);
|
||||
}
|
||||
|
||||
#endif // __OSINCLUDE_H
|
||||
|
|
|
@ -1,109 +1,109 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "osinclude.h"
|
||||
|
||||
//
|
||||
// string manipulation
|
||||
//
|
||||
static void StrToLower(char *str)
|
||||
{
|
||||
int i, length;
|
||||
|
||||
length = strlen(str);
|
||||
|
||||
for(i = 0;i < length;i++)
|
||||
str[i] = tolower(str[i]);
|
||||
}
|
||||
|
||||
int stricmp(const char *str1, const char *str2)
|
||||
{
|
||||
char *str1Copy, *str2Copy;
|
||||
int retVal;
|
||||
|
||||
str1Copy = new char[strlen(str1) + 1];
|
||||
str2Copy = new char[strlen(str2) + 1];
|
||||
|
||||
strcpy(str1Copy, str1);
|
||||
strcpy(str2Copy, str2);
|
||||
|
||||
StrToLower(str1Copy);
|
||||
StrToLower(str2Copy);
|
||||
|
||||
retVal = strcmp(str1Copy, str2Copy);
|
||||
|
||||
delete str1Copy;
|
||||
delete str2Copy;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
OS_TLSIndex OS_AllocTLSIndex()
|
||||
{
|
||||
OS_TLSIndex key;
|
||||
if (pthread_key_create(&key, NULL) != 0)
|
||||
{
|
||||
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
|
||||
{
|
||||
if (pthread_setspecific(nIndex, lpvValue) != 0)
|
||||
{
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Key");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
||||
{
|
||||
if (pthread_key_delete(nIndex) != 0)
|
||||
{
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "osinclude.h"
|
||||
|
||||
//
|
||||
// string manipulation
|
||||
//
|
||||
static void StrToLower(char *str)
|
||||
{
|
||||
int i, length;
|
||||
|
||||
length = strlen(str);
|
||||
|
||||
for(i = 0;i < length;i++)
|
||||
str[i] = tolower(str[i]);
|
||||
}
|
||||
|
||||
int stricmp(const char *str1, const char *str2)
|
||||
{
|
||||
char *str1Copy, *str2Copy;
|
||||
int retVal;
|
||||
|
||||
str1Copy = new char[strlen(str1) + 1];
|
||||
str2Copy = new char[strlen(str2) + 1];
|
||||
|
||||
strcpy(str1Copy, str1);
|
||||
strcpy(str2Copy, str2);
|
||||
|
||||
StrToLower(str1Copy);
|
||||
StrToLower(str2Copy);
|
||||
|
||||
retVal = strcmp(str1Copy, str2Copy);
|
||||
|
||||
delete str1Copy;
|
||||
delete str2Copy;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
OS_TLSIndex OS_AllocTLSIndex()
|
||||
{
|
||||
OS_TLSIndex key;
|
||||
if (pthread_key_create(&key, NULL) != 0)
|
||||
{
|
||||
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
|
||||
{
|
||||
if (pthread_setspecific(nIndex, lpvValue) != 0)
|
||||
{
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Key");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
||||
{
|
||||
if (pthread_key_delete(nIndex) != 0)
|
||||
{
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,104 +1,104 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#include "InitializeDll.h"
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
switch (fdwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
|
||||
if (!InitProcess())
|
||||
return FALSE;
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
|
||||
if (!InitThread())
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
|
||||
if (!DetachThread())
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
|
||||
DetachProcess();
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0 && "DllMain(): Reason for calling DLL Main is unknown");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#include "InitializeDll.h"
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
switch (fdwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
|
||||
if (!InitProcess())
|
||||
return FALSE;
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
|
||||
if (!InitThread())
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
|
||||
if (!DetachThread())
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
|
||||
DetachProcess();
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0 && "DllMain(): Reason for calling DLL Main is unknown");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1,104 +1,104 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef __OSINCLUDE_H
|
||||
#define __OSINCLUDE_H
|
||||
|
||||
//
|
||||
// This file contains contains the window's specific datatypes and
|
||||
// declares any windows specific functions.
|
||||
//
|
||||
|
||||
#if !(defined(_WIN32) || defined(_WIN64))
|
||||
#error Trying to include a windows specific file in a non windows build.
|
||||
#endif
|
||||
|
||||
#define STRICT
|
||||
#define VC_EXTRALEAN 1
|
||||
#include <windows.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
typedef DWORD OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES)
|
||||
|
||||
OS_TLSIndex OS_AllocTLSIndex();
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
||||
|
||||
inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||
{
|
||||
assert(nIndex != OS_INVALID_TLS_INDEX);
|
||||
return TlsGetValue(nIndex);
|
||||
}
|
||||
|
||||
#endif // __OSINCLUDE_H
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef __OSINCLUDE_H
|
||||
#define __OSINCLUDE_H
|
||||
|
||||
//
|
||||
// This file contains contains the window's specific datatypes and
|
||||
// declares any windows specific functions.
|
||||
//
|
||||
|
||||
#if !(defined(_WIN32) || defined(_WIN64))
|
||||
#error Trying to include a windows specific file in a non windows build.
|
||||
#endif
|
||||
|
||||
#define STRICT
|
||||
#define VC_EXTRALEAN 1
|
||||
#include <windows.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
typedef DWORD OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES)
|
||||
|
||||
OS_TLSIndex OS_AllocTLSIndex();
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
||||
|
||||
inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||
{
|
||||
assert(nIndex != OS_INVALID_TLS_INDEX);
|
||||
return TlsGetValue(nIndex);
|
||||
}
|
||||
|
||||
#endif // __OSINCLUDE_H
|
||||
|
|
|
@ -1,120 +1,120 @@
|
|||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#include "osinclude.h"
|
||||
//
|
||||
// This file contains contains the window's specific functions
|
||||
//
|
||||
|
||||
#if !(defined(_WIN32) || defined(_WIN64))
|
||||
#error Trying to build a windows specific file in a non windows build.
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
OS_TLSIndex OS_AllocTLSIndex()
|
||||
{
|
||||
DWORD dwIndex = TlsAlloc();
|
||||
if (dwIndex == TLS_OUT_OF_INDEXES) {
|
||||
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
|
||||
return OS_INVALID_TLS_INDEX;
|
||||
}
|
||||
|
||||
return dwIndex;
|
||||
}
|
||||
|
||||
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
|
||||
{
|
||||
if (nIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TlsSetValue(nIndex, lpvValue))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
||||
{
|
||||
if (nIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TlsFree(nIndex))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
//Copyright (C) 2005-2006 ATI Research, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of ATI Research, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
|
||||
#include "osinclude.h"
|
||||
//
|
||||
// This file contains contains the window's specific functions
|
||||
//
|
||||
|
||||
#if !(defined(_WIN32) || defined(_WIN64))
|
||||
#error Trying to build a windows specific file in a non windows build.
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
OS_TLSIndex OS_AllocTLSIndex()
|
||||
{
|
||||
DWORD dwIndex = TlsAlloc();
|
||||
if (dwIndex == TLS_OUT_OF_INDEXES) {
|
||||
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
|
||||
return OS_INVALID_TLS_INDEX;
|
||||
}
|
||||
|
||||
return dwIndex;
|
||||
}
|
||||
|
||||
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
|
||||
{
|
||||
if (nIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TlsSetValue(nIndex, lpvValue))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
||||
{
|
||||
if (nIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TlsFree(nIndex))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче