This commit is contained in:
romkazvo
2023-08-07 19:29:24 +08:00
commit 34d6c5d489
4832 changed files with 1389451 additions and 0 deletions

View File

@@ -0,0 +1,274 @@
/*
*
* 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<49>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 _cg_h
#define _cg_h
#ifndef CG_DEPRECATED_API
// Set up for either Win32 import/export/lib.
#ifndef CGDLL_API
#ifdef WIN32
#ifdef CGDLL_EXPORTS
#define CGDLL_API __declspec(dllexport)
#elif defined (CG_LIB)
#define CGDLL_API
#else
#define CGDLL_API __declspec(dllimport)
#endif
#else
#define CGDLL_API
#endif
#endif
/*************************************************************************/
/*** CG Run-Time Library API ***/
/*************************************************************************/
/*************************************************************************/
/*** Data types and enumerants ***/
/*************************************************************************/
typedef int CGbool;
#define CG_FALSE ((CGbool)0)
#define CG_TRUE ((CGbool)1)
typedef struct _CGcontext *CGcontext;
typedef struct _CGprogram *CGprogram;
typedef struct _CGparameter *CGparameter;
typedef enum
{
CG_UNKNOWN_TYPE,
CG_STRUCT,
CG_ARRAY,
CG_TYPE_START_ENUM = 1024,
# define CG_DATATYPE_MACRO(name, compiler_name, enum_name, ncols, nrows) \
enum_name ,
#include "cg_datatypes.h"
} CGtype;
typedef enum
{
# define CG_BINDLOCATION_MACRO(name,enum_name,compiler_name,\
enum_int,addressable,param_type) \
enum_name = enum_int,
#include "cg_bindlocations.h"
CG_UNDEFINED,
} CGresource;
typedef enum
{
CG_PROFILE_START = 6144,
CG_PROFILE_UNKNOWN,
# define CG_PROFILE_MACRO(name, compiler_id, compiler_id_caps, compiler_opt,int_id,vertex_profile) \
CG_PROFILE_##compiler_id_caps = int_id,
#include "cg_profiles.h"
CG_PROFILE_MAX,
} CGprofile;
typedef enum
{
# define CG_ERROR_MACRO(code, enum_name, new_enum_name, message) \
new_enum_name = code,
# include "cg_errors.h"
} CGerror;
typedef enum
{
CG_UNKNOWN = 4096,
CG_IN,
CG_OUT,
CG_INOUT,
CG_MIXED,
CG_VARYING,
CG_UNIFORM,
CG_CONSTANT,
CG_PROGRAM_SOURCE,
CG_PROGRAM_ENTRY,
CG_COMPILED_PROGRAM,
CG_PROGRAM_PROFILE,
CG_GLOBAL,
CG_PROGRAM,
CG_DEFAULT,
CG_ERROR,
CG_SOURCE,
CG_OBJECT,
} CGenum;
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*CGerrorCallbackFunc)(void);
/*************************************************************************/
/*** Functions ***/
/*************************************************************************/
/*** Context functions ***/
CGDLL_API CGcontext cgCreateContext(void);
CGDLL_API void cgDestroyContext(CGcontext ctx);
CGDLL_API CGbool cgIsContext(CGcontext ctx);
CGDLL_API const char *cgGetLastListing(CGcontext ctx);
/*** Program functions ***/
CGDLL_API CGprogram cgCreateProgram(CGcontext ctx,
CGenum program_type,
const char *program,
CGprofile profile,
const char *entry,
const char **args);
CGDLL_API CGprogram cgCreateProgramFromFile(CGcontext ctx,
CGenum program_type,
const char *program_file,
CGprofile profile,
const char *entry,
const char **args);
CGDLL_API CGprogram cgCopyProgram(CGprogram program);
CGDLL_API void cgDestroyProgram(CGprogram program);
CGDLL_API CGprogram cgGetFirstProgram(CGcontext ctx);
CGDLL_API CGprogram cgGetNextProgram(CGprogram current);
CGDLL_API CGcontext cgGetProgramContext(CGprogram prog);
CGDLL_API CGbool cgIsProgram(CGprogram program);
CGDLL_API void cgCompileProgram(CGprogram program);
CGDLL_API CGbool cgIsProgramCompiled(CGprogram program);
CGDLL_API const char *cgGetProgramString(CGprogram prog, CGenum pname);
CGDLL_API CGprofile cgGetProgramProfile(CGprogram prog);
/*** Parameter functions ***/
CGDLL_API CGparameter cgGetNamedParameter(CGprogram prog, const char *name);
CGDLL_API CGparameter cgGetFirstParameter(CGprogram prog, CGenum name_space);
CGDLL_API CGparameter cgGetNextParameter(CGparameter current);
CGDLL_API CGparameter cgGetFirstLeafParameter(CGprogram prog, CGenum name_space);
CGDLL_API CGparameter cgGetNextLeafParameter(CGparameter current);
CGDLL_API CGparameter cgGetFirstStructParameter(CGparameter param);
CGDLL_API CGparameter cgGetFirstDependentParameter(CGparameter param);
CGDLL_API CGparameter cgGetArrayParameter(CGparameter aparam, int index);
CGDLL_API int cgGetArrayDimension(CGparameter param);
CGDLL_API int cgGetArraySize(CGparameter param, int dimension);
CGDLL_API CGprogram cgGetParameterProgram(CGparameter prog);
CGDLL_API CGbool cgIsParameter(CGparameter param);
CGDLL_API const char *cgGetParameterName(CGparameter param);
CGDLL_API CGtype cgGetParameterType(CGparameter param);
CGDLL_API const char *cgGetParameterSemantic(CGparameter param);
CGDLL_API CGresource cgGetParameterResource(CGparameter param);
CGDLL_API CGresource cgGetParameterBaseResource(CGparameter param);
CGDLL_API unsigned long cgGetParameterResourceIndex(CGparameter param);
CGDLL_API CGenum cgGetParameterVariability(CGparameter param);
CGDLL_API CGenum cgGetParameterDirection(CGparameter param);
CGDLL_API CGbool cgIsParameterReferenced(CGparameter param);
CGDLL_API const double *cgGetParameterValues(CGparameter param,
CGenum value_type,
int *nvalues);
CGDLL_API int cgGetParameterOrdinalNumber(CGparameter param);
/*** Type Functions ***/
CGDLL_API const char *cgGetTypeString(CGtype type);
CGDLL_API CGtype cgGetType(const char *type_string);
/*** Resource Functions ***/
CGDLL_API const char *cgGetResourceString(CGresource resource);
CGDLL_API CGresource cgGetResource(const char *resource_string);
/*** Profile Functions ***/
CGDLL_API const char *cgGetProfileString(CGprofile profile);
CGDLL_API CGprofile cgGetProfile(const char *profile_string);
/*** Error Functions ***/
CGDLL_API CGerror cgGetError(void);
CGDLL_API const char *cgGetErrorString(CGerror error);
CGDLL_API void cgSetErrorCallback(CGerrorCallbackFunc func);
CGDLL_API CGerrorCallbackFunc cgGetErrorCallback(void);
#ifdef __cplusplus
}
#endif
#else
#define cgCreateContext cgGL_DEPRECATEDAPI_CreateContext
#define cgGetNextProgram cgGL_DEPRECATEDAPI_GetNextProgram
#define cgGetLastListing cgGL_DEPRECATEDAPI_GetLastListing
#define cgGetProgramProfile cgGL_DEPRECATEDAPI_ProgramProfile
# include "cg_deprecated_api.h"
#endif
#endif

View File

@@ -0,0 +1,200 @@
/*
*
* 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<49>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.
*
*/
/*********************************************************************NVMH2****
File: cgContextManager.h
Copyright (C) 1999, 2000 NVIDIA Corporation
This file is provided without support, instruction, or implied warranty of any
kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is
not liable under any circumstances for any damages or loss whatsoever arising
from the use or inability to use this file or items derived from it.
Comments:
cgContextManager - a class for loading various cg programs,
******************************************************************************/
#ifndef __NV_CG_MANAGER_H
#define __NV_CG_MANAGER_H
#if WIN32
#pragma warning (disable:4786) // identifier was truncated to '255' characters in the browser information
#include <windows.h>
#include <d3d8.h>
#include <d3dx8.h>
#include <Cg/cgTemplates.h>
#include <Cg/cg.h>
#include <Cg/cgProgramManager.h>
class cgContextManager;
class cgContextContainer
{
public:
// retrieve the listing file for the last compile
const char *GetLastListing();
// loads and compiles the cg program
cgProgramContainer * LoadCGProgramFromFile(
const char * filename, // filename of the Cg program
const char * title, // title of the program
cgProfileType type, // profile of the program
cgVertexDefinition * va = 0, // optionally, set streams or allow different vetex definitions
DWORD * outIndex = 0,
const char * entry = 0);
cgProgramContainer * LoadCGProgramFromMemory(
const char * memory, // memory location that contain the cg program
const char * title, // name of the program
cgProfileType type, // profile of the program
cgVertexDefinition * va = 0, // optionally, set the streams for each vertex entry
DWORD * outIndex = 0,
const char * entry = 0);
// use outIndex returned from LoadCGProgramFrom to retriece the program iterator
cgProgramContainer * GetProgramIterator(DWORD index);
// program operators (for multiple programs(vertex, pixel) in one cg
// pass NULL to get first program
cgProgramIter *GetNextProgram(cgProgramIter *iter);
// get a specific program
cgProgramIter *ProgramByName(const char *name);
// get the vertexshader or pixel shader handle that is passed to
// SetVertexShader and SetPixelShader
DWORD GetShaderHandle(cgProfileType type)
{
return pm.GetShaderHandle( type);
}
~cgContextContainer( );
friend class cgContextManager;
protected:
cgContextContainer( LPDIRECT3DDEVICE8 pd3dDevice, cgContext * context);
private:
cgProgramContainer * CreateProgramContainer(DWORD * outIndex = 0);
cgProgramContainer * CreateProgramContainer(
cgProgramIter *ProgramIter,
LPDIRECT3DDEVICE8 pd3dDevice,
DWORD * outIndex = 0); // index of this
// loads and compiles the cg program
HRESULT AddProgramFromFile(const char * filename, const char * name, cgProfileType type, const char * entry = 0);
HRESULT AddProgramFromMemory(const char * memory, const char * name, cgProfileType type, const char * entry = 0);
void Free();
cgProgramManager pm; // manage the vertex or pixel shader that is derived from this
cgContext * m_Context;
cg_string m_ContextDefinition;
LPDIRECT3DDEVICE8 m_pd3dDevice;
};
class cgContextManager
{
private:
cg_vector < cgContextContainer *> m_ContextContainers;
cg_vector < DWORD > m_ContextIndices; // indirection to m_Shaders
// Programs hold an index to this array for
// their shaders. The array int at that index
// holds the index into the m_Shaders array.
// each context has a list of programs (up to one for each profile)
public:
cgContextManager();
~cgContextManager();
cgError Free();
cgContextContainer *CreateContextContainer(LPDIRECT3DDEVICE8 pd3dDevice, DWORD * outIndex);
};
#endif // WIN32
#endif

View File

@@ -0,0 +1,158 @@
/*
*
* 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<49>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 _cgD3D_h
#define _cgD3D_h
#if WIN32
#include <Cg/cg.h>
#include <assert.h>
#ifndef STRICT
#define STRICT
#endif
#include <windows.h>
#include <commdlg.h>
#include <tchar.h>
#include <stdio.h>
#include <d3d8.h>
#include <d3dx8.h>
#define MAX_STREAMS 16
#include <Cg/cgProgramManager.h>
#include <Cg/cgContextManager.h>
////////////////////////////////////////////////
//
// cgDX8Vertex and cgDX8Pixel are defined with
// macros:
//
// CG_PROFILE_MACRO(DX8Vertex,dx8vs,"dx8vs")
// CG_PROFILE_MACRO(DX8Pixel,dx8ps,"dx8ps")
//
// cgDX8VertexProfile
class cgDirect3D
{
public:
cgDirect3D();
~cgDirect3D();
// add a path to locate the cg programs
// do not add the trailing '\\'
void AddFilePath(const char * dirpath);
void AddFilePath(cg_string & path);
void NotePad(const char * title, const char * listing )
{
cg_string text;
text = title;
if(listing != NULL)
text += listing;
else
text += "*** NO LISTING ***\n";
char * TmpLstFile = tmpnam(0);
FILE * fpLst = fopen(TmpLstFile, "w");
fputs(text.c_str(), fpLst);
fclose(fpLst);
char Cmd[1000];
sprintf(Cmd, "notepad %s", TmpLstFile);
int Ret = system(Cmd);
unlink(TmpLstFile);
}
cgContextContainer * CreateContextContainer(LPDIRECT3DDEVICE8 pd3dDevice, DWORD * outIndex = 0)
{
return cm.CreateContextContainer(pd3dDevice, outIndex);
}
private:
cgContextManager cm;
LPDIRECT3DDEVICE8 m_pd3dDevice;
};
#define CGRTERR_ILLEGAL_PROFILE -1
#define CGRTERR_VERTEX_ATTRIBUTES_NOT_SET -2
#endif // WIN32
#endif

View File

@@ -0,0 +1,275 @@
/*
*
* 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<49>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 CGD3D8_INCLUDED
#define CGD3D8_INCLUDED
#if WIN32
#pragma once
#include "cg.h"
#include <d3d8.h>
#include <d3dx8.h>
// Set up for either Win32 import/export/lib.
#if WIN32
# include <windows.h>
#ifdef CGD3D8DLL_EXPORTS
#define CGD3D8DLL_API __declspec(dllexport)
#elif defined (CG_LIB)
#define CGD3D8DLL_API
#else
#define CGD3D8DLL_API __declspec(dllimport)
#endif
#else
#define CGD3D8DLL_API
#endif
/*---------------------------------------------------------------------------
// CGerrors that will be fed to cgSetError
// Use cgD3D8TranslateCGerror() to translate these errors into strings.
---------------------------------------------------------------------------*/
enum cgD3D8Errors
{
cgD3D8Failed = 1000,
cgD3D8DebugTrace = 1001,
};
/*---------------------------------------------------------------------------
// HRESULTs specific to cgD3D8. When the CGerror is set to cgD3D8Failed
// cgD3D8GetLastError will return an HRESULT that could be one these.
// Use cgD3D8TranslateHRESULT() to translate these errors into strings.
---------------------------------------------------------------------------*/
const HRESULT CGD3D8ERR_NOTLOADED = MAKE_HRESULT(1, 0x877, 1);
const HRESULT CGD3D8ERR_NODEVICE = MAKE_HRESULT(1, 0x877, 2);
const HRESULT CGD3D8ERR_NOTSAMPLER = MAKE_HRESULT(1, 0x877, 3);
const HRESULT CGD3D8ERR_INVALIDPROFILE = MAKE_HRESULT(1, 0x877, 4);
const HRESULT CGD3D8ERR_NULLVALUE = MAKE_HRESULT(1, 0x877, 5);
const HRESULT CGD3D8ERR_OUTOFRANGE = MAKE_HRESULT(1, 0x877, 6);
const HRESULT CGD3D8ERR_NOTUNIFORM = MAKE_HRESULT(1, 0x877, 7);
const HRESULT CGD3D8ERR_NOTMATRIX = MAKE_HRESULT(1, 0x877, 8);
const HRESULT CGD3D8ERR_INVALIDPARAM = MAKE_HRESULT(1, 0x877, 9);
const HRESULT CGD3D8ERR_INVALIDSAMPLERSTATE = MAKE_HRESULT(1, 0x877, 100);
const HRESULT CGD3D8ERR_INVALIDVEREXDECL = MAKE_HRESULT(1, 0x877, 101);
/*---------------------------------------------------------------------------
// Other error return values
---------------------------------------------------------------------------*/
const DWORD CGD3D8_INVALID_REG = 0xFFFFFFFF;
#ifdef __cplusplus
extern "C"
{
#endif
/*---------------------------------------------------------------------------
// Minimal Interface
---------------------------------------------------------------------------*/
CGD3D8DLL_API
DWORD cgD3D8TypeToSize(
CGtype type
);
CGD3D8DLL_API
DWORD cgD3D8ResourceToInputRegister(
CGresource resource
);
CGD3D8DLL_API
CGbool cgD3D8GetVertexDeclaration(
CGprogram prog,
DWORD decl[MAX_FVF_DECL_SIZE]
);
CGD3D8DLL_API
CGbool cgD3D8ValidateVertexDeclaration(
CGprogram prog,
const DWORD* decl
);
/*---------------------------------------------------------------------------
// Expanded Interface
---------------------------------------------------------------------------*/
/* ----- D3D Device Control ----------- */
CGD3D8DLL_API
IDirect3DDevice8* cgD3D8GetDevice();
CGD3D8DLL_API
HRESULT cgD3D8SetDevice(
IDirect3DDevice8* pDevice
);
/* ----- Shader Management ----------- */
CGD3D8DLL_API
HRESULT cgD3D8LoadProgram(
CGprogram prog,
CGbool paramShadowing,
DWORD assemFlags,
DWORD vshaderUsage,
const DWORD* vertexDecl
);
CGD3D8DLL_API
HRESULT cgD3D8UnloadProgram(
CGprogram prog
);
CGD3D8DLL_API
CGbool cgD3D8IsProgramLoaded(
CGprogram prog
);
CGD3D8DLL_API
HRESULT cgD3D8BindProgram(
CGprogram prog
);
/* ----- Parameter Management ----------- */
CGD3D8DLL_API
HRESULT cgD3D8SetUniform(
CGparameter param,
const void* floats
);
CGD3D8DLL_API
HRESULT cgD3D8SetUniformArray(
CGparameter param,
DWORD offset,
DWORD numItems,
const void* values
);
CGD3D8DLL_API
HRESULT cgD3D8SetUniformMatrix(
CGparameter param,
const D3DMATRIX* matrix
);
CGD3D8DLL_API
HRESULT cgD3D8SetUniformMatrixArray(
CGparameter param,
DWORD offset,
DWORD numItems,
const D3DMATRIX* matrices
);
CGD3D8DLL_API
HRESULT cgD3D8SetTexture(
CGparameter param,
IDirect3DBaseTexture8* tex
);
CGD3D8DLL_API
HRESULT cgD3D8SetTextureStageState(
CGparameter param,
D3DTEXTURESTAGESTATETYPE type,
DWORD value
);
CGD3D8DLL_API
HRESULT cgD3D8SetTextureWrapMode(
CGparameter param,
DWORD value
);
/* ----- Parameter Management (Shadowing) ----------- */
CGD3D8DLL_API
HRESULT cgD3D8EnableParameterShadowing(
CGprogram prog,
CGbool enable
);
CGD3D8DLL_API
CGbool cgD3D8IsParameterShadowingEnabled(
CGprogram prog
);
/* --------- Profile Options ----------------- */
CGD3D8DLL_API
CGprofile cgD3D8GetLatestVertexProfile();
CGD3D8DLL_API
CGprofile cgD3D8GetLatestPixelProfile();
CGD3D8DLL_API
char const* cgD3D8GetOptimalOptions(
CGprofile profile
);
/* --------- Error reporting ----------------- */
CGD3D8DLL_API
HRESULT cgD3D8GetLastError();
CGD3D8DLL_API
const char* cgD3D8TranslateCGerror(
CGerror error
);
CGD3D8DLL_API
const char* cgD3D8TranslateHRESULT(
HRESULT hr
);
CGD3D8DLL_API
void cgD3D8EnableDebugTracing(
CGbool enable
);
#ifdef __cplusplus
};
#endif
#endif // WIN32
#endif

View File

@@ -0,0 +1,271 @@
/*
*
* 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<49>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 CGD3D9_INCLUDED
#define CGD3D9_INCLUDED
#if WIN32
#pragma once
#include "cg.h"
#include <d3d9.h>
#include <d3dx9.h>
// Set up for either Win32 import/export/lib.
#if WIN32
# include <windows.h>
#ifdef CGD3D9DLL_EXPORTS
#define CGD3D9DLL_API __declspec(dllexport)
#elif defined (CG_LIB)
#define CGD3D9DLL_API
#else
#define CGD3D9DLL_API __declspec(dllimport)
#endif
#else
#define CGD3D9DLL_API
#endif
/*---------------------------------------------------------------------------
// CGerrors that will be fed to cgSetError
// Use cgD3D9TranslateCGerror() to translate these errors into strings.
---------------------------------------------------------------------------*/
enum cgD3D9Errors
{
cgD3D9Failed = 1000,
cgD3D9DebugTrace = 1001,
};
/*---------------------------------------------------------------------------
// HRESULTs specific to cgD3D9. When the CGerror is set to cgD3D9Failed
// cgD3D9GetLastError will return an HRESULT that could be one these.
// Use cgD3D9TranslateHRESULT() to translate these errors into strings.
---------------------------------------------------------------------------*/
const HRESULT CGD3D9ERR_NOTLOADED = MAKE_HRESULT(1, 0x877, 1);
const HRESULT CGD3D9ERR_NODEVICE = MAKE_HRESULT(1, 0x877, 2);
const HRESULT CGD3D9ERR_NOTSAMPLER = MAKE_HRESULT(1, 0x877, 3);
const HRESULT CGD3D9ERR_INVALIDPROFILE = MAKE_HRESULT(1, 0x877, 4);
const HRESULT CGD3D9ERR_NULLVALUE = MAKE_HRESULT(1, 0x877, 5);
const HRESULT CGD3D9ERR_OUTOFRANGE = MAKE_HRESULT(1, 0x877, 6);
const HRESULT CGD3D9ERR_NOTUNIFORM = MAKE_HRESULT(1, 0x877, 7);
const HRESULT CGD3D9ERR_NOTMATRIX = MAKE_HRESULT(1, 0x877, 8);
const HRESULT CGD3D9ERR_INVALIDPARAM = MAKE_HRESULT(1, 0x877, 9);
/*---------------------------------------------------------------------------
// Other error return values
---------------------------------------------------------------------------*/
const DWORD CGD3D9_INVALID_USAGE = 0xFF;
#ifdef __cplusplus
extern "C"
{
#endif
/*---------------------------------------------------------------------------
// Minimal Interface
---------------------------------------------------------------------------*/
CGD3D9DLL_API
DWORD cgD3D9TypeToSize(
CGtype type
);
CGD3D9DLL_API
BYTE cgD3D9ResourceToDeclUsage(
CGresource resource
);
CGD3D9DLL_API
CGbool cgD3D9GetVertexDeclaration(
CGprogram prog,
D3DVERTEXELEMENT9 decl[MAXD3DDECLLENGTH]
);
CGD3D9DLL_API
CGbool cgD3D9ValidateVertexDeclaration(
CGprogram prog,
const D3DVERTEXELEMENT9* decl
);
/*---------------------------------------------------------------------------
// Expanded Interface
---------------------------------------------------------------------------*/
/* ----- D3D Device Control ----------- */
CGD3D9DLL_API
IDirect3DDevice9* cgD3D9GetDevice();
CGD3D9DLL_API
HRESULT cgD3D9SetDevice(
IDirect3DDevice9* pDevice
);
/* ----- Shader Management ----------- */
CGD3D9DLL_API
HRESULT cgD3D9LoadProgram(
CGprogram prog,
CGbool paramShadowing,
DWORD assemFlags
);
CGD3D9DLL_API
HRESULT cgD3D9UnloadProgram(
CGprogram prog
);
CGD3D9DLL_API
CGbool cgD3D9IsProgramLoaded(
CGprogram prog
);
CGD3D9DLL_API
HRESULT cgD3D9BindProgram(
CGprogram prog
);
/* ----- Parameter Management ----------- */
CGD3D9DLL_API
HRESULT cgD3D9SetUniform(
CGparameter param,
const void* floats
);
CGD3D9DLL_API
HRESULT cgD3D9SetUniformArray(
CGparameter param,
DWORD offset,
DWORD numItems,
const void* values
);
CGD3D9DLL_API
HRESULT cgD3D9SetUniformMatrix(
CGparameter param,
const D3DMATRIX* matrix
);
CGD3D9DLL_API
HRESULT cgD3D9SetUniformMatrixArray(
CGparameter param,
DWORD offset,
DWORD numItems,
const D3DMATRIX* matrices
);
CGD3D9DLL_API
HRESULT cgD3D9SetTexture(
CGparameter param,
IDirect3DBaseTexture9* tex
);
CGD3D9DLL_API
HRESULT cgD3D9SetSamplerState(
CGparameter param,
D3DSAMPLERSTATETYPE type,
DWORD value
);
CGD3D9DLL_API
HRESULT cgD3D9SetTextureWrapMode(
CGparameter param,
DWORD value
);
/* ----- Parameter Management (Shadowing) ----------- */
CGD3D9DLL_API
HRESULT cgD3D9EnableParameterShadowing(
CGprogram prog,
CGbool enable
);
CGD3D9DLL_API
CGbool cgD3D9IsParameterShadowingEnabled(
CGprogram prog
);
/* --------- Profile Options ----------------- */
CGD3D9DLL_API
CGprofile cgD3D9GetLatestVertexProfile();
CGD3D9DLL_API
CGprofile cgD3D9GetLatestPixelProfile();
CGD3D9DLL_API
char const* cgD3D9GetOptimalOptions(
CGprofile profile
);
/* --------- Error reporting ----------------- */
CGD3D9DLL_API
HRESULT cgD3D9GetLastError();
CGD3D9DLL_API
const char* cgD3D9TranslateCGerror(
CGerror error
);
CGD3D9DLL_API
const char* cgD3D9TranslateHRESULT(
HRESULT hr
);
CGD3D9DLL_API
void cgD3D9EnableDebugTracing(
CGbool enable
);
#ifdef __cplusplus
};
#endif
#endif // WIN32
#endif

View File

@@ -0,0 +1,62 @@
/*
*
* 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<49>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.
*
*/
CG_PROFILE_MACRO(Vertex,vp20,VP20,"vp20",6146,1)
CG_PROFILE_MACRO(Fragment20,fp20,FP20,"fp20",6147,0)
CG_PROFILE_MACRO(Vertex30,vp30,VP30,"vp30",6148,1)
CG_PROFILE_MACRO(Fragment,fp30,FP30,"fp30",6149,0)
CG_PROFILE_MACRO(ARBVertex,arbvp1,ARBVP1,"arbvp1",6150,1)
CG_PROFILE_MACRO(ARBFragment,arbfp1,ARBFP1,"arbfp1",7000,0)
#ifndef CG_IN_PROFILES_INCLUDE
# undef CG_PROFILE_MACRO
#endif

View File

@@ -0,0 +1,326 @@
/*
*
* 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<49>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.
*
*/
/*********************************************************************NVMH2****
File: cgProgramManager.h
Copyright (C) 1999, 2000 NVIDIA Corporation
This file is provided without support, instruction, or implied warranty of any
kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is
not liable under any circumstances for any damages or loss whatsoever arising
from the use or inability to use this file or items derived from it.
Comments:
cgProgramManager - a class for loading various pixel & vertex shaders
******************************************************************************/
#ifndef __NV_PROGRAM_MANAGER_H
#define __NV_PROGRAM_MANAGER_H
#if WIN32
#pragma warning (disable:4786) // identifier was truncated to '255' characters in the browser information
#include <windows.h>
#include <d3d8.h>
#include <d3dx8.h>
#include <Cg/cgTemplates.h>
#include <Cg/cg.h>
// to allow multiple streams and user specifed vertex type
// D3DVSDT_FLOAT1 0x00 // 1D float expanded to (value, 0., 0., 1.)
// D3DVSDT_FLOAT2 0x01 // 2D float expanded to (value, value, 0., 1.)
// D3DVSDT_FLOAT3 0x02 // 3D float expanded to (value, value, value, 1.)
// D3DVSDT_FLOAT4 0x03 // 4D float
// D3DVSDT_D3DCOLOR 0x04 // 4D packed unsigned bytes mapped to 0. to 1. range
// // Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A)
// D3DVSDT_UBYTE4 0x05 // 4D unsigned byte
// D3DVSDT_SHORT2 0x06 // 2D signed short expanded to (value, value, 0., 1.)
// D3DVSDT_SHORT4 0x07 // 4D signed short
// was cgVertexAttribute
typedef struct cgVertexDefinition
{
int D3DVSDT_type; // one of D3DVSDT_*
char * name; // name of the entry
int stream; // stream to put the vertex in
} cgVertexDefinition;
#define CGVERTEXDEFINITIONEND {-1, 0, 0}
// internal cgDirect3D data structure
typedef struct cgiVertexAttribute
{
char name[64];
int D3DVSDT_type;
int bind_location;
cgBindIter * BindIter;
} cgiVertexAttribute;
typedef cg_vector<cgiVertexAttribute> cgiVertexAttributeList;
typedef cg_list<cgBindIter *> cgBindIterList;
class cgProgramManager;
class cgContextContainer;
class cgProgramContainer
{
public:
// get a text definition of what the runtime expects for the vertex
const char * GetVertexDeclaration();
/*
Example: returns string containing
"struct stream0
{
D3DXVECTOR3 position;
D3DXVECTOR2 tex0;
};"
*/
// convert D3DXMATRIX class to type specified in cg program
// even if your cg program uses 3x3, you can use this to pass a matrix to it
// upper left hand part of D3DXMATRIX is used to fill the cg matrix
HRESULT SetShaderConstantD3DXMATRIX(cgBindIter * iter, const D3DXMATRIX *, int nArrayElements = 0, int ArrayOffset = 0);
// All other data formats use this interface
// The D3D runtime records the size of your data and puts that in the constant fields
HRESULT SetShaderConstant(cgBindIter * iter, void * data, int nArrayElements = 0, int ArrayOffset = 0);
// for arrays:
// if nArrayElements is specified, write this number of elements rather than the whole array
// if ArrayOffset is specified, start writing at this array element
// otherwise nArrayElements and ArrayOffset are not specified
// returns texture position 0-8 for the iterator
// -1 is failure
int GetTexturePosition(cgBindIter * BindIter);
int GetTexturePosition(const char * name);
// set the texture via name (needs to search bindings by name, so this is the slowest
// not recommended
HRESULT SetTexture(const char * name, LPDIRECT3DBASETEXTURE8 pTexture);
// does a GetTexturePosition, then settexture(n, nTexture)
HRESULT SetTexture(cgBindIter * BindIter, LPDIRECT3DBASETEXTURE8 pTexture);
// does a GetTexturePosition, then SetTextureStageState(n, nTexture, Value)
HRESULT SetTextureStageState(cgBindIter * BindIter, D3DTEXTURESTAGESTATETYPE Type,DWORD Value);
// Direct3D hardcodes wrap state, D3DRS_WRAP1, D3DWRAPCOORD_0 | D3DWRAPCOORD_1
// WrapCoords : 0, D3DWRAPCOORD_0, D3DWRAPCOORD_1 or'd together
HRESULT SetTextureWrapMode(cgBindIter * BindIter, DWORD WrapCoords);
// activate this shader (SetVertexShader or SetPixelShader)
HRESULT SetShaderActive();
// locate a binding within a program by parameter name
// it is recommended to do this once and use the cgBindIter to reference data
cgBindIter *GetVertexBindByName(const char *vertex_attr_name);
cgBindIter *GetTextureBindByName(const char *texture_name);
cgBindIter *GetParameterBindByName(const char *parameter_name);
void FreeBindIter(cgBindIter *);
// Get the type for this bind iterator
cgValueType GetBindValueType(const cgBindIter *BindIter, int *array_size)
{
return cgGetBindValueType(BindIter, array_size);
}
// locate and bindinf iterator by full name
// e.g. appdata.texcoord0
cgBindIter *GetBindByFullName(const char *parameter_name);
// from the iterator, get the name of the program
const char *GetProgramName();
const char *GetProgramObjectCode();
cgProfileType GetProgramProfile() { return m_ProfileType;}
// get the shader handle passed to Direct3D
DWORD GetShaderHandle() {return m_dwShaderHandle;}
private:
cgBindIter *AllocBind();
void SaveBind(cgBindIter * BindIter); // for deleting
cgBindIterList m_BindIterList;
void GetParameterConstantPosition(cgBindIter * iter, int * pos, int *width, int * num4vectors, int *nArrayElements);
void GetParameterConstantPosition(const char * name, int * pos, int *width, int * num4vectors, int *nArrayElements);
HRESULT CreateProgramShader();
HRESULT CreateVertexShader();
HRESULT CreatePixelShader();
// take asm code, assembles it and create a handle
HRESULT CreateShaderHandleFromFile(
const cg_string & strFilePath,
const cg_string & strSourceFile,
const DWORD * pDeclaration,
DWORD Usage);
HRESULT CreateShaderHandleFromMemory(
const char * pShaderText,
const DWORD * pDeclaration,
DWORD Usage);
HRESULT Free();
// cgDX8VertexProfile or cgDX8PixelProfile (cg_profiles.h)
// These types are defined with macros:
// CG_PROFILE_MACRO(DX8Vertex,dx8vs,"dx8vs")
// CG_PROFILE_MACRO(DX8Pixel,dx8ps,"dx8ps")
friend cgProgramManager;
friend cgContextContainer;
DWORD m_dwShaderHandle; // DWORD handle returned by DX8 runtime
cgProfileType m_ProfileType; // profile for this program
HRESULT SetVertexDefinition(cgVertexDefinition * streams);
cgProgramContainer(LPDIRECT3DDEVICE8 pDev, cgProgramIter *m_ProgramIter,
cgProfileType ProfileType);
~cgProgramContainer();
HRESULT LoadShaderConstants();
cg_string m_ProgramSourceFile; // text file name
cg_string m_ProgramObjectFile; // compiled shader object file (.vso, .pso)
// for declaration of vertex positions
cgiVertexAttributeList m_VertexAttributes[MAX_STREAMS];
cgProgramIter *m_ProgramIter;
LPDIRECT3DDEVICE8 m_pd3dDevice;
};
class cgProgramManager
{
private:
cg_vector < cgProgramContainer * > m_ProgramContainers; // m_Shaders[0] is always = 0
cg_vector < DWORD > m_ProgramIndices; // indirection to m_Shaders
// Programs hold an index to this array for
// their shaders. The array int at that index
// holds the index into the m_Shaders array.
public:
cgProgramManager(LPDIRECT3DDEVICE8 pDev);
~cgProgramManager();
HRESULT Free();
cgProgramContainer * CreateProgramContainer(LPDIRECT3DDEVICE8 pDev,
cgProgramIter * ProgramIter,
DWORD Usage,
cgProfileType ProfileType,
DWORD * outIndex );
DWORD GetShaderHandle( DWORD Index );
DWORD GetShaderHandle( cgProfileType ProfileType );
//
cgProgramContainer * GetProgramIterator(DWORD index);
private:
// for creating programs
LPDIRECT3DDEVICE8 m_pd3dDevice;
};
#endif // WIN32
#endif

View File

@@ -0,0 +1,366 @@
/*
*
* 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<49>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.
*
*/
/*********************************************************************NVMH2****
File: cgTemplates.h
Copyright (C) 1999, 2000 NVIDIA Corporation
This file is provided without support, instruction, or implied warranty of any
kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is
not liable under any circumstances for any damages or loss whatsoever arising
from the use or inability to use this file or items derived from it.
Comments:
cgTemplates - cg utility templates
******************************************************************************/
#pragma once
#ifndef CG_TEMPLATE_H
#define CG_TEMPLATE_H
#include <stdlib.h>
//////////////////////////////////////////
//
// templated cg_vector class
//
//////////////////////////////////////////
template <class T>
class cg_vector{
public:
typedef int size_type;
cg_vector();
cg_vector( cg_vector<T>& v );
~cg_vector();
void clear();
int size() const;
T& operator [] ( int i );
void push_back( const T& t );
private:
T* data;
int num;
int capacity;
const static int initSize;
};
//definitions of cg_vector methods
template <class T>
const int cg_vector<T>::initSize = 16;
template <class T>
cg_vector<T>::cg_vector(){
data = NULL;
clear();
}
template <class T>
cg_vector<T>::cg_vector( cg_vector<T>& v ){
data = NULL;
clear();
for( int i=0; i<v.size(); i++ ){
push_back( v[i] );
}
}
template <class T>
cg_vector<T>::~cg_vector(){
delete[] data;
}
template <class T>
void cg_vector<T>::clear(){
if( data ){
delete[] data;
}
data = (T*)new T[initSize];
num = 0;
capacity = initSize;
}
template <class T>
int cg_vector<T>::size() const{
return num;
}
template <class T>
void cg_vector<T>::push_back( const T& t ){
if( num >= capacity ){
T* temp = new T[ 2 * capacity ];
for( int i = 0; i < num; i++ ){
temp[i] = data[i];
}
delete[] data;
data = temp;
capacity *= 2;
}
data[num] = t;
num++;
}
template <class T>
T& cg_vector<T>::operator [] ( int i ){
if( i>=0 && i < num ){
return data[i];
}else{
return data[0];
}
}
//////////////////////////////////////////
//
// templated cg_list class
//
//////////////////////////////////////////
template <class T>
class cg_list{
public:
class Node{
public:
Node( const T& _data, Node* _next, Node* _prev ){
data = _data;
next = _next;
prev = _prev;
}
T data;
Node* next;
Node* prev;
};
class iterator{
public:
iterator( Node* _node ){
node = _node;
}
iterator(){
node = NULL;
}
bool operator == ( const iterator& it ) const{
return node == it.node;
}
bool operator != ( const iterator& it ) const{
return !( *this == it );
}
T& operator * (){
return node -> data;
}
void operator ++ (){
node = node -> next;
}
void operator ++ (int){
node = node -> next;
}
Node* node;
};
cg_list();
cg_list( const cg_list<T>& l );
~cg_list();
iterator begin();
iterator end();
void push_back( const T& t );
void clear();
void remove( const T& value );
private:
Node* head;
Node* tail;
void insert( const T& t, Node* node );
void remove( Node* node );
};
// definitions of cg_list methods
template <class T>
cg_list<T>::cg_list(){
head = tail = new Node( T(), NULL, NULL );
}
template <class T>
cg_list<T>::~cg_list(){
clear();
delete head;
}
template <class T>
cg_list<T>::cg_list( const cg_list<T>& l ){
head = tail = new Node( T(), NULL, NULL );
cg_list<T>::iterator it = l.begin();
while( it != l.end() ){
push_back( *it );
it++;
}
}
template <class T>
cg_list<T>::iterator cg_list<T>::begin(){
return head;
}
template <class T>
cg_list<T>::iterator cg_list<T>::end(){
return tail;
}
template <class T>
void cg_list<T>::push_back( const T& t ){
insert( t, tail );
}
template <class T>
void cg_list<T>::clear(){
while( head != tail ){
remove( head );
}
}
template <class T>
void cg_list<T>::remove( const T& value ){
Node* curr = head;
Node* temp;
while( curr != tail ){
temp = curr;
curr = curr -> next;
if( temp -> data == value ){
remove( temp );
}
}
}
template <class T>
void cg_list<T>::insert( const T& t, cg_list<T>::Node* node ){
Node* newNode = new Node( t, node, node -> prev );
if( node -> prev == NULL ){
head = newNode;
}else{
node -> prev -> next = newNode;
}
node -> prev = newNode;
}
template <class T>
void cg_list<T>::remove( cg_list<T>::Node* node ){
if( node == tail ){
return;
}
node -> next -> prev = node -> prev;
if( node -> prev == NULL ){
head = node -> next;
}else{
node -> prev -> next = node -> next;
}
delete node;
}
//////////////////////////////////////////
//
// cg_string class
//
//////////////////////////////////////////
class cg_string{
public:
typedef int size_type;
cg_string();
cg_string( const char* s);
cg_string( const cg_string& s );
~cg_string();
int size() const;
const char* c_str() const;
void resize( int n, char c = '\0' );
cg_string& erase( int pos = 0, int n = npos );
int find_last_of( const cg_string& s, int pos = npos ) const;
cg_string substr( int pos = 0, int len = npos ) const;
char& operator [] ( int i );
const char& operator [] ( int i ) const;
cg_string& operator = ( const cg_string& s );
cg_string& operator += ( const cg_string& s );
cg_string operator + ( const cg_string& s ) const;
const static int npos;
private:
char* data;
int num; //length of the string, not counting the trailing '\0'.
int capacity;
const static int initSize;
void set( const char* s, int n );
};
#endif

View File

@@ -0,0 +1,332 @@
/*
*
* 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<49>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.
*
*/
/*
* The following macro invocations define the supported CG basic hardware
* bind locations.
*
* The macros have the form :
*
* CG_BINDLOCATION_MACRO(name, compiler_name, enum_int)
*
* name : The name of the location.
* enum_name : The C enumerant.
* compiler_name : The name of the location within the compiler syntax.
* int_id : Integer enumerant associated with this bind location.
* addressable : The bind location must have an integer address
* associated with it.
* ParamType : the cgParamType of this register.
*
*/
CG_BINDLOCATION_MACRO(TexUnit0,CG_TEXUNIT0,"texunit 0",2048,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit1,CG_TEXUNIT1,"texunit 1",2049,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit2,CG_TEXUNIT2,"texunit 2",2050,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit3,CG_TEXUNIT3,"texunit 3",2051,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit4,CG_TEXUNIT4,"texunit 4",2052,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit5,CG_TEXUNIT5,"texunit 5",2053,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit6,CG_TEXUNIT6,"texunit 6",2054,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit7,CG_TEXUNIT7,"texunit 7",2055,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit8,CG_TEXUNIT8,"texunit 8",2056,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit9,CG_TEXUNIT9,"texunit 9",2057,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit10,CG_TEXUNIT10,"texunit 10",2058,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit11,CG_TEXUNIT11,"texunit 11",2059,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit12,CG_TEXUNIT12,"texunit 12",2060,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit13,CG_TEXUNIT13,"texunit 13",2061,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit14,CG_TEXUNIT14,"texunit 14",2062,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(TexUnit15,CG_TEXUNIT15,"texunit 15",2063,0,cgTexObjParam)
CG_BINDLOCATION_MACRO(Attr0,CG_ATTR0,"ATTR0",2113,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr1,CG_ATTR1,"ATTR1",2114,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr2,CG_ATTR2,"ATTR2",2115,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr3,CG_ATTR3,"ATTR3",2116,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr4,CG_ATTR4,"ATTR4",2117,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr5,CG_ATTR5,"ATTR5",2118,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr6,CG_ATTR6,"ATTR6",2119,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr7,CG_ATTR7,"ATTR7",2120,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr8,CG_ATTR8,"ATTR8",2121,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr9,CG_ATTR9,"ATTR9",2122,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr10,CG_ATTR10,"ATTR10",2123,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr11,CG_ATTR11,"ATTR11",2124,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr12,CG_ATTR12,"ATTR12",2125,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr13,CG_ATTR13,"ATTR13",2126,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr14,CG_ATTR14,"ATTR14",2127,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Attr15,CG_ATTR15,"ATTR15",2128,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(VertUniform,CG_C,"c",2178,1,cgUniformParam)
CG_BINDLOCATION_MACRO(Tex0,CG_TEX0,"TEX0",2179,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tex1,CG_TEX1,"TEX1",2180,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tex2,CG_TEX2,"TEX2",2181,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tex3,CG_TEX3,"TEX3",2192,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tex4,CG_TEX4,"TEX4",2193,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tex5,CG_TEX5,"TEX5",2194,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tex6,CG_TEX6,"TEX6",2195,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tex7,CG_TEX7,"TEX7",2196,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(HPos,CG_HPOS,"HPOS",2243,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Col0,CG_COL0,"COL0",2245,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Col1,CG_COL1,"COL1",2246,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Col2,CG_COL2,"COL2",2247,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Col3,CG_COL3,"COL3",2248,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSiz,CG_PSIZ,"PSIZ",2309,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(WPos,CG_WPOS,"WPOS",2373,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position0,CG_POSITION0,"POSITION0",2437,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position1,CG_POSITION1,"POSITION1",2438,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position2,CG_POSITION2,"POSITION2",2439,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position3,CG_POSITION3,"POSITION3",2440,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position4,CG_POSITION4,"POSITION4",2441,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position5,CG_POSITION5,"POSITION5",2442,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position6,CG_POSITION6,"POSITION6",2443,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position7,CG_POSITION7,"POSITION7",2444,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position8,CG_POSITION8,"POSITION8",2445,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position9,CG_POSITION9,"POSITION9",2446,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position10,CG_POSITION10,"POSITION10",2447,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position11,CG_POSITION11,"POSITION11",2448,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position12,CG_POSITION12,"POSITION12",2449,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position13,CG_POSITION13,"POSITION13",2450,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position14,CG_POSITION14,"POSITION14",2451,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Position15,CG_POSITION15,"POSITION15",2452,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Diffuse0,CG_DIFFUSE0,"DIFFUSE0",2501,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent0,CG_TANGENT0,"TANGENT0",2565,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent1,CG_TANGENT1,"TANGENT1",2566,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent2,CG_TANGENT2,"TANGENT2",2567,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent3,CG_TANGENT3,"TANGENT3",2568,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent4,CG_TANGENT4,"TANGENT4",2569,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent5,CG_TANGENT5,"TANGENT5",2570,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent6,CG_TANGENT6,"TANGENT6",2571,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent7,CG_TANGENT7,"TANGENT7",2572,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent8,CG_TANGENT8,"TANGENT8",2573,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent9,CG_TANGENT9,"TANGENT9",2574,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent10,CG_TANGENT10,"TANGENT10",2575,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent11,CG_TANGENT11,"TANGENT11",2576,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent12,CG_TANGENT12,"TANGENT12",2577,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent13,CG_TANGENT13,"TANGENT13",2578,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent14,CG_TANGENT14,"TANGENT14",2579,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Tangent15,CG_TANGENT15,"TANGENT15",2580,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Specular0,CG_SPECULAR0,"SPECULAR0",2629,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices0,CG_BLENDINDICES0,"BLENDINDICES0",2693,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices1,CG_BLENDINDICES1,"BLENDINDICES1",2694,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices2,CG_BLENDINDICES2,"BLENDINDICES2",2695,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices3,CG_BLENDINDICES3,"BLENDINDICES3",2696,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices4,CG_BLENDINDICES4,"BLENDINDICES4",2697,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices5,CG_BLENDINDICES5,"BLENDINDICES5",2698,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices6,CG_BLENDINDICES6,"BLENDINDICES6",2699,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices7,CG_BLENDINDICES7,"BLENDINDICES7",2700,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices8,CG_BLENDINDICES8,"BLENDINDICES8",2701,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices9,CG_BLENDINDICES9,"BLENDINDICES9",2702,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices10,CG_BLENDINDICES10,"BLENDINDICES10",2703,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices11,CG_BLENDINDICES11,"BLENDINDICES11",2704,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices12,CG_BLENDINDICES12,"BLENDINDICES12",2705,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices13,CG_BLENDINDICES13,"BLENDINDICES13",2706,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices14,CG_BLENDINDICES14,"BLENDINDICES14",2707,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendIndices15,CG_BLENDINDICES15,"BLENDINDICES15",2708,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color0,CG_COLOR0,"COLOR0",2757,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color1,CG_COLOR1,"COLOR1",2758,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color2,CG_COLOR2,"COLOR2",2759,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color3,CG_COLOR3,"COLOR3",2760,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color4,CG_COLOR4,"COLOR4",2761,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color5,CG_COLOR5,"COLOR5",2762,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color6,CG_COLOR6,"COLOR6",2763,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color7,CG_COLOR7,"COLOR7",2764,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color8,CG_COLOR8,"COLOR8",2765,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color9,CG_COLOR9,"COLOR9",2766,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color10,CG_COLOR10,"COLOR10",2767,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color11,CG_COLOR11,"COLOR11",2768,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color12,CG_COLOR12,"COLOR12",2769,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color13,CG_COLOR13,"COLOR13",2770,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color14,CG_COLOR14,"COLOR14",2771,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Color15,CG_COLOR15,"COLOR15",2772,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize0,CG_PSIZE0,"PSIZE0",2821,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize1,CG_PSIZE1,"PSIZE1",2822,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize2,CG_PSIZE2,"PSIZE2",2823,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize3,CG_PSIZE3,"PSIZE3",2824,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize4,CG_PSIZE4,"PSIZE4",2825,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize5,CG_PSIZE5,"PSIZE5",2826,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize6,CG_PSIZE6,"PSIZE6",2827,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize7,CG_PSIZE7,"PSIZE7",2828,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize8,CG_PSIZE8,"PSIZE8",2829,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize9,CG_PSIZE9,"PSIZE9",2830,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize10,CG_PSIZE10,"PSIZE10",2831,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize11,CG_PSIZE11,"PSIZE11",2832,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize12,CG_PSIZE12,"PSIZE12",2833,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize13,CG_PSIZE13,"PSIZE13",2834,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize14,CG_PSIZE14,"PSIZE14",2835,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(PSize15,CG_PSIZE15,"PSIZE15",2836,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal0,CG_BINORMAL0,"BINORMAL0",2885,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal1,CG_BINORMAL1,"BINORMAL1",2886,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal2,CG_BINORMAL2,"BINORMAL2",2887,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal3,CG_BINORMAL3,"BINORMAL3",2888,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal4,CG_BINORMAL4,"BINORMAL4",2889,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal5,CG_BINORMAL5,"BINORMAL5",2890,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal6,CG_BINORMAL6,"BINORMAL6",2891,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal7,CG_BINORMAL7,"BINORMAL7",2892,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal8,CG_BINORMAL8,"BINORMAL8",2893,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal9,CG_BINORMAL9,"BINORMAL9",2894,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal10,CG_BINORMAL10,"BINORMAL10",2895,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal11,CG_BINORMAL11,"BINORMAL11",2896,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal12,CG_BINORMAL12,"BINORMAL12",2897,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal13,CG_BINORMAL13,"BINORMAL13",2898,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal14,CG_BINORMAL14,"BINORMAL14",2899,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BiNormal15,CG_BINORMAL15,"BINORMAL15",2900,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG0,CG_FOG0,"FOG0",2917,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG1,CG_FOG1,"FOG1",2918,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG2,CG_FOG2,"FOG2",2919,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG3,CG_FOG3,"FOG3",2920,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG4,CG_FOG4,"FOG4",2921,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG5,CG_FOG5,"FOG5",2922,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG6,CG_FOG6,"FOG6",2923,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG7,CG_FOG7,"FOG7",2924,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG8,CG_FOG8,"FOG8",2925,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG9,CG_FOG9,"FOG9",2926,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG10,CG_FOG10,"FOG10",2927,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG11,CG_FOG11,"FOG11",2928,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG12,CG_FOG12,"FOG12",2929,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG13,CG_FOG13,"FOG13",2930,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG14,CG_FOG14,"FOG14",2931,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FOG15,CG_FOG15,"FOG15",2932,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH0,CG_DEPTH0,"DEPTH0",2933,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH1,CG_DEPTH1,"DEPTH1",2934,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH2,CG_DEPTH2,"DEPTH2",2935,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH3,CG_DEPTH3,"DEPTH3",2936,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH4,CG_DEPTH4,"DEPTH4",2937,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH5,CG_DEPTH5,"DEPTH5",2938,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH6,CG_DEPTH6,"DEPTH6",2939,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH7,CG_DEPTH7,"DEPTH7",2940,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH8,CG_DEPTH8,"DEPTH8",2941,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH9,CG_DEPTH9,"DEPTH9",29542,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH10,CG_DEPTH10,"DEPTH10",2943,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH11,CG_DEPTH11,"DEPTH11",2944,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH12,CG_DEPTH12,"DEPTH12",2945,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH13,CG_DEPTH13,"DEPTH13",2946,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH14,CG_DEPTH14,"DEPTH14",2947,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(DEPTH15,CG_DEPTH15,"DEPTH15",2948,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE0,CG_SAMPLE0,"SAMPLE0",2949,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE1,CG_SAMPLE1,"SAMPLE1",2950,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE2,CG_SAMPLE2,"SAMPLE2",2951,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE3,CG_SAMPLE3,"SAMPLE3",2952,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE4,CG_SAMPLE4,"SAMPLE4",2953,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE5,CG_SAMPLE5,"SAMPLE5",2954,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE6,CG_SAMPLE6,"SAMPLE6",2955,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE7,CG_SAMPLE7,"SAMPLE7",2956,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE8,CG_SAMPLE8,"SAMPLE8",2957,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE9,CG_SAMPLE9,"SAMPLE9",2958,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE10,CG_SAMPLE10,"SAMPLE10",2959,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE11,CG_SAMPLE11,"SAMPLE11",2960,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE12,CG_SAMPLE12,"SAMPLE12",2961,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE13,CG_SAMPLE13,"SAMPLE13",2962,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE14,CG_SAMPLE14,"SAMPLE14",2963,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(SAMPLE15,CG_SAMPLE15,"SAMPLE15",2964,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight0,CG_BLENDWEIGHT0,"BLENDWEIGHT0",3028,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight1,CG_BLENDWEIGHT1,"BLENDWEIGHT1",3029,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight2,CG_BLENDWEIGHT2,"BLENDWEIGHT2",3030,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight3,CG_BLENDWEIGHT3,"BLENDWEIGHT3",3031,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight4,CG_BLENDWEIGHT4,"BLENDWEIGHT4",3032,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight5,CG_BLENDWEIGHT5,"BLENDWEIGHT5",3033,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight6,CG_BLENDWEIGHT6,"BLENDWEIGHT6",3034,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight7,CG_BLENDWEIGHT7,"BLENDWEIGHT7",3035,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight8,CG_BLENDWEIGHT8,"BLENDWEIGHT8",3036,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight9,CG_BLENDWEIGHT9,"BLENDWEIGHT9",3037,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight10,CG_BLENDWEIGHT10,"BLENDWEIGHT10",3038,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight11,CG_BLENDWEIGHT11,"BLENDWEIGHT11",3039,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight12,CG_BLENDWEIGHT12,"BLENDWEIGHT12",3040,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight13,CG_BLENDWEIGHT13,"BLENDWEIGHT13",3041,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight14,CG_BLENDWEIGHT14,"BLENDWEIGHT14",3042,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(BlendWeight15,CG_BLENDWEIGHT15,"BLENDWEIGHT15",3043,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal0,CG_NORMAL0,"NORMAL0",3092,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal1,CG_NORMAL1,"NORMAL1",3093,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal2,CG_NORMAL2,"NORMAL2",3094,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal3,CG_NORMAL3,"NORMAL3",3095,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal4,CG_NORMAL4,"NORMAL4",3096,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal5,CG_NORMAL5,"NORMAL5",3097,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal6,CG_NORMAL6,"NORMAL6",3098,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal7,CG_NORMAL7,"NORMAL7",3099,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal8,CG_NORMAL8,"NORMAL8",3100,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal9,CG_NORMAL9,"NORMAL9",3101,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal10,CG_NORMAL10,"NORMAL10",3102,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal11,CG_NORMAL11,"NORMAL11",3103,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal12,CG_NORMAL12,"NORMAL12",3104,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal13,CG_NORMAL13,"NORMAL13",3105,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal14,CG_NORMAL14,"NORMAL14",3106,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(Normal15,CG_NORMAL15,"NORMAL15",3107,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(FogCoord,CG_FOGCOORD,"FOGCOORD",3156,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord0,CG_TEXCOORD0,"TEXCOORD0",3220,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord1,CG_TEXCOORD1,"TEXCOORD1",3221,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord2,CG_TEXCOORD2,"TEXCOORD2",3222,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord3,CG_TEXCOORD3,"TEXCOORD3",3223,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord4,CG_TEXCOORD4,"TEXCOORD4",3224,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord5,CG_TEXCOORD5,"TEXCOORD5",3225,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord6,CG_TEXCOORD6,"TEXCOORD6",3226,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord7,CG_TEXCOORD7,"TEXCOORD7",3227,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord8,CG_TEXCOORD8,"TEXCOORD8",3228,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord9,CG_TEXCOORD9,"TEXCOORD9",3229,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord10,CG_TEXCOORD10,"TEXCOORD10",3230,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord11,CG_TEXCOORD11,"TEXCOORD11",3231,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord12,CG_TEXCOORD12,"TEXCOORD12",3232,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord13,CG_TEXCOORD13,"TEXCOORD13",3233,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord14,CG_TEXCOORD14,"TEXCOORD14",3234,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(TexCoord15,CG_TEXCOORD15,"TEXCOORD15",3235,0,cgConnectorMemberParam)
CG_BINDLOCATION_MACRO(CombinerConst0,CG_COMBINER_CONST0,"COMBINER_CONST0",3284,0,cgUniformParam)
CG_BINDLOCATION_MACRO(CombinerConst1,CG_COMBINER_CONST1,"COMBINER_CONST1",3285,0,cgUniformParam)
CG_BINDLOCATION_MACRO(CombinerStageConst0,CG_COMBINER_STAGE_CONST0,"COMBINER_STAGE_CONST0",3286,1,cgUniformParam)
CG_BINDLOCATION_MACRO(CombinerStageConst1,CG_COMBINER_STAGE_CONST1,"COMBINER_STAGE_CONST1",3287,1,cgUniformParam)
CG_BINDLOCATION_MACRO(OffsetTextureMatrix,CG_OFFSET_TEXTURE_MATRIX,"OFFSET_TEXTURE_MATRIX",3288,0,cgUniformParam)
CG_BINDLOCATION_MACRO(OffsetTextureScale,CG_OFFSET_TEXTURE_SCALE,"OFFSET_TEXTURE_SCALE",3289,0,cgUniformParam)
CG_BINDLOCATION_MACRO(OffsetTextureBias,CG_OFFSET_TEXTURE_BIAS,"OFFSET_TEXTURE_BIAS",3290,0,cgUniformParam)
CG_BINDLOCATION_MACRO(ConstEye,CG_CONST_EYE,"CONST_EYE",3291,0,cgUniformParam)
CG_BINDLOCATION_MACRO(TessFactor,CG_TESSFACTOR,"TESSFACTOR",3255,0,cgConnectorMemberParam)
#undef CG_BINDLOCATION_MACRO

View File

@@ -0,0 +1,142 @@
/*
*
* 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<49>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.
*
*/
/*
* The following macro invocations define the supported CG basic data types.
*
* The macros have the form :
*
* CG_DATATYPE_MACRO(name, compiler_name, nrows, ncols)
*
* name : The name of the data type.
* compiler_name : The name of the data type within the compiler syntax.
* enum_name : The C enumerant.
* nrows : Number of rows for matrix types. Should be 0 other-wise.
* ncols : Number of columns for matrix types. Should be 0
* other-wise.
*
*/
CG_DATATYPE_MACRO(Half,half,CG_HALF,0,0)
CG_DATATYPE_MACRO(Half2,half2,CG_HALF2,0,0)
CG_DATATYPE_MACRO(Half3,half3,CG_HALF3,0,0)
CG_DATATYPE_MACRO(Half4,half4,CG_HALF4,0,0)
CG_DATATYPE_MACRO(Half1x1,half1x1,CG_HALF1x1,1,1)
CG_DATATYPE_MACRO(Half1x2,half1x2,CG_HALF1x2,1,2)
CG_DATATYPE_MACRO(Half1x3,half1x3,CG_HALF1x3,1,3)
CG_DATATYPE_MACRO(Half1x4,half1x4,CG_HALF1x4,1,4)
CG_DATATYPE_MACRO(Half2x1,half2x1,CG_HALF2x1,2,1)
CG_DATATYPE_MACRO(Half2x2,half2x2,CG_HALF2x2,2,2)
CG_DATATYPE_MACRO(Half2x3,half2x3,CG_HALF2x3,2,3)
CG_DATATYPE_MACRO(Half2x4,half2x4,CG_HALF2x4,2,4)
CG_DATATYPE_MACRO(Half3x1,half3x1,CG_HALF3x1,3,1)
CG_DATATYPE_MACRO(Half3x2,half3x2,CG_HALF3x2,3,2)
CG_DATATYPE_MACRO(Half3x3,half3x3,CG_HALF3x3,3,3)
CG_DATATYPE_MACRO(Half3x4,half3x4,CG_HALF3x4,3,4)
CG_DATATYPE_MACRO(Half4x1,half4x1,CG_HALF4x1,4,1)
CG_DATATYPE_MACRO(Half4x2,half4x2,CG_HALF4x2,4,2)
CG_DATATYPE_MACRO(Half4x3,half4x3,CG_HALF4x3,4,3)
CG_DATATYPE_MACRO(Half4x4,half4x4,CG_HALF4x4,4,4)
CG_DATATYPE_MACRO(Float,float,CG_FLOAT,0,0)
CG_DATATYPE_MACRO(Float2,float2,CG_FLOAT2,0,0)
CG_DATATYPE_MACRO(Float3,float3,CG_FLOAT3,0,0)
CG_DATATYPE_MACRO(Float4,float4,CG_FLOAT4,0,0)
CG_DATATYPE_MACRO(Float1x1,float1x1,CG_FLOAT1x1,1,1)
CG_DATATYPE_MACRO(Float1x2,float1x2,CG_FLOAT1x2,1,2)
CG_DATATYPE_MACRO(Float1x3,float1x3,CG_FLOAT1x3,1,3)
CG_DATATYPE_MACRO(Float1x4,float1x4,CG_FLOAT1x4,1,4)
CG_DATATYPE_MACRO(Float2x1,float2x1,CG_FLOAT2x1,2,1)
CG_DATATYPE_MACRO(Float2x2,float2x2,CG_FLOAT2x2,2,2)
CG_DATATYPE_MACRO(Float2x3,float2x3,CG_FLOAT2x3,2,3)
CG_DATATYPE_MACRO(Float2x4,float2x4,CG_FLOAT2x4,2,4)
CG_DATATYPE_MACRO(Float3x1,float3x1,CG_FLOAT3x1,3,1)
CG_DATATYPE_MACRO(Float3x2,float3x2,CG_FLOAT3x2,3,2)
CG_DATATYPE_MACRO(Float3x3,float3x3,CG_FLOAT3x3,3,3)
CG_DATATYPE_MACRO(Float3x4,float3x4,CG_FLOAT3x4,3,4)
CG_DATATYPE_MACRO(Float4x1,float4x1,CG_FLOAT4x1,4,1)
CG_DATATYPE_MACRO(Float4x2,float4x2,CG_FLOAT4x2,4,2)
CG_DATATYPE_MACRO(Float4x3,float4x3,CG_FLOAT4x3,4,3)
CG_DATATYPE_MACRO(Float4x4,float4x4,CG_FLOAT4x4,4,4)
CG_DATATYPE_MACRO(Sampler1D,sampler1D,CG_SAMPLER1D,0,0)
CG_DATATYPE_MACRO(Sampler2D,sampler2D,CG_SAMPLER2D,0,0)
CG_DATATYPE_MACRO(Sampler3D,sampler3D,CG_SAMPLER3D,0,0)
CG_DATATYPE_MACRO(SamplerRECT,samplerRECT,CG_SAMPLERRECT,0,0)
CG_DATATYPE_MACRO(SamplerCUBE,samplerCUBE,CG_SAMPLERCUBE,0,0)
CG_DATATYPE_MACRO(Fixed,fixed,CG_FIXED,0,0)
CG_DATATYPE_MACRO(Fixed2,fixed2,CG_FIXED2,0,0)
CG_DATATYPE_MACRO(Fixed3,fixed3,CG_FIXED3,0,0)
CG_DATATYPE_MACRO(Fixed4,fixed4,CG_FIXED4,0,0)
CG_DATATYPE_MACRO(Fixed1x1,fixed1x1,CG_FIXED1x1,1,1)
CG_DATATYPE_MACRO(Fixed1x2,fixed1x2,CG_FIXED1x2,1,2)
CG_DATATYPE_MACRO(Fixed1x3,fixed1x3,CG_FIXED1x3,1,3)
CG_DATATYPE_MACRO(Fixed1x4,fixed1x4,CG_FIXED1x4,1,4)
CG_DATATYPE_MACRO(Fixed2x1,fixed2x1,CG_FIXED2x1,2,1)
CG_DATATYPE_MACRO(Fixed2x2,fixed2x2,CG_FIXED2x2,2,2)
CG_DATATYPE_MACRO(Fixed2x3,fixed2x3,CG_FIXED2x3,2,3)
CG_DATATYPE_MACRO(Fixed2x4,fixed2x4,CG_FIXED2x4,2,4)
CG_DATATYPE_MACRO(Fixed3x1,fixed3x1,CG_FIXED3x1,3,1)
CG_DATATYPE_MACRO(Fixed3x2,fixed3x2,CG_FIXED3x2,3,2)
CG_DATATYPE_MACRO(Fixed3x3,fixed3x3,CG_FIXED3x3,3,3)
CG_DATATYPE_MACRO(Fixed3x4,fixed3x4,CG_FIXED3x4,3,4)
CG_DATATYPE_MACRO(Fixed4x1,fixed4x1,CG_FIXED4x1,4,1)
CG_DATATYPE_MACRO(Fixed4x2,fixed4x2,CG_FIXED4x2,4,2)
CG_DATATYPE_MACRO(Fixed4x3,fixed4x3,CG_FIXED4x3,4,3)
CG_DATATYPE_MACRO(Fixed4x4,fixed4x4,CG_FIXED4x4,4,4)
CG_DATATYPE_MACRO(Half1,half1,CG_HALF1,0,0)
CG_DATATYPE_MACRO(Float1,float1,CG_FLOAT1,0,0)
CG_DATATYPE_MACRO(Fixed1,fixed1,CG_FIXED1,0,0)
#undef CG_DATATYPE_MACRO

View File

@@ -0,0 +1,273 @@
/*
*
* 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<49>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 _cg_deprecated_api_h
#define _cg_deprecated_api_h
// Set up for either Win32 import/export/lib.
#ifndef CGDLL_API
#ifdef WIN32
#ifdef CGDLL_EXPORTS
#define CGDLL_API __declspec(dllexport)
#elif defined (CG_LIB)
#define CGDLL_API
#else
#define CGDLL_API __declspec(dllimport)
#endif
#else
#define CGDLL_API
#endif
#endif
/*************************************************************************/
/*** CG Run-Time Library API ***/
/*************************************************************************/
/*************************************************************************/
/*** Data types and structures ***/
/*************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
# define CG_ERROR_MACRO(code, enum_name, new_enum_name, message) \
cg##enum_name = code,
# include <Cg/cg_errors.h>
} cgError;
typedef struct
{
/* Opaque structure */
void *Data;
} cgContext;
typedef struct
{
/* Opaque structure */
void *Data;
} cgProgramIter;
typedef struct
{
/* Opaque structure */
void *Data;
} cgBindIter;
typedef enum
{
cgUnknownValueType,
cgTypeStartEnum = 1024,
# define CG_DATATYPE_MACRO(name, compiler_name, enum_name, ncols, nrows) \
cg##name##ValueType,
#include <Cg/cg_datatypes.h>
} cgValueType;
typedef enum
{
cgConstParam,
cgUniformParam,
cgConnectorMemberParam,
cgVaryingParam = cgConnectorMemberParam,
cgTexObjParam,
cgAnyParam,
cgUndefinedParam,
} cgParamType;
typedef enum
{
# define CG_BINDLOCATION_MACRO(name,enum_name,compiler_name,\
enum_int,addressable,param_type) \
cgBind##name = enum_int,
#include <Cg/cg_bindlocations.h>
cgBindUndefined
} cgBindLocation;
typedef enum
{
cgProfileStart = 6144,
CG_PROFILE_UNKNOWN,
cgUnknownProfile = CG_PROFILE_UNKNOWN,
# define CG_PROFILE_MACRO(name, compiler_id, compiler_id_caps, compiler_opt,int_id,vertex_profile) \
cg##name##Profile = int_id,
# include "Cg/cg_profiles.h"
cgNProfiles,
} cgProfileType;
/*************************************************************************/
/*** Function Prototypes ***/
/*************************************************************************/
/*******************************************************************/
/*** cg Misc Functions ****/
/*******************************************************************/
CGDLL_API void cgCleanup(void);
/* This will probably be deprecated in future releases */
CGDLL_API void cgSetCompilerExe(const char *exe);
CGDLL_API const char *cgErrorMsg(cgError error);
/*******************************************************************/
/*** cgContext Functions ****/
/*******************************************************************/
CGDLL_API cgContext *cgCreateContext(void);
CGDLL_API void cgFreeContext(cgContext *context);
CGDLL_API cgError cgAddProgram(cgContext *context,
const char *text,
cgProfileType profile,
const char *entry);
CGDLL_API cgError cgAddProgramFromFile(cgContext *context,
const char *filename,
cgProfileType profile,
const char *entry);
CGDLL_API cgError cgAddProgramArgs(cgContext *context,
const char *text,
cgProfileType profile,
const char *entry,
int nargs,
const char **args);
CGDLL_API cgError cgAddProgramFromFileArgs(cgContext *context,
const char *filename,
cgProfileType profile,
const char *entry,
int nargs,
const char **args);
CGDLL_API cgError cgAddPrecompiledProgram(cgContext *context,
const char *text,
cgProfileType profile,
const char *entry);
CGDLL_API cgError cgAddPrecompiledProgramFromFile(cgContext *context,
const char *filename,
cgProfileType profile,
const char *entry);
CGDLL_API const char *cgGetLastListing(cgContext *context);
/*******************************************************************/
/*** cgProgram Functions ***/
/*******************************************************************/
CGDLL_API cgProgramIter *cgGetNextProgram(cgContext *context,
cgProgramIter *iter);
CGDLL_API cgProgramIter *cgProgramByName(cgContext *context,
const char *name);
CGDLL_API cgProgramIter *cgGetLastProgram(cgContext *context);
CGDLL_API void cgFreeProgramIter(cgProgramIter *program);
CGDLL_API const char *cgGetProgramName(const cgProgramIter *program);
CGDLL_API cgProfileType cgGetProgramProfile(const cgProgramIter *program);
CGDLL_API const char *cgGetProgramObjectCode(const cgProgramIter *program);
/*******************************************************************/
/*** Parameter and Binding Functions ****/
/*******************************************************************/
CGDLL_API cgBindIter *cgGetNextBind(cgProgramIter *program,
cgBindIter *iter);
CGDLL_API cgBindIter *cgGetBindByName(cgProgramIter *program,
const char *parameter_name);
CGDLL_API cgBindIter *cgDuplicateBindIter(cgBindIter *bind);
CGDLL_API void cgFreeBindIter(cgBindIter *iter);
CGDLL_API const char *cgGetBindParamName(const cgBindIter *bind);
CGDLL_API cgParamType cgGetBindParamType(const cgBindIter *bind);
CGDLL_API cgBindLocation cgGetBindLocation(const cgBindIter *bind);
CGDLL_API unsigned long cgGetBindAddress(const cgBindIter *bind);
CGDLL_API cgValueType cgGetBindValueType(const cgBindIter *bind,
int *array_size);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,193 @@
/*
*
* 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<49>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.
*
*/
/*
* The following macro invocations define error codes returned by various cg
* API functions.
*
* The macros have the form :
*
* CG_ERROR_MACRO(code, enum_name, message)
*
* code : The integer error code associated with the error.
* enum_name : The name of enumerant of the error code.
* (Note : the prefix "cg" will be added to the name).
* new_enum_name : The name of enumerant of the error code in the new API.
* message : A description string associated with the error.
*
*/
CG_ERROR_MACRO(0,
NoError,
CG_NO_ERROR,
"No error has occurred.")
CG_ERROR_MACRO(1,
CompileError,
CG_COMPILER_ERROR,
"The compile returned an error.")
CG_ERROR_MACRO(2,
InvalidParameterError,
CG_INVALID_PARAMETER_ERROR,
"The parameter used is invalid.")
CG_ERROR_MACRO(3,
InvalidProfileError,
CG_INVALID_PROFILE_ERROR,
"The profile is not supported.")
CG_ERROR_MACRO(4,
ProgramLoadError,
CG_PROGRAM_LOAD_ERROR,
"The program could not load.")
CG_ERROR_MACRO(5,
ProgramBindError,
CG_PROGRAM_BIND_ERROR,
"The program could not bind.")
CG_ERROR_MACRO(6,
ProgramNotLoadedError,
CG_PROGRAM_NOT_LOADED_ERROR,
"The program must be loaded before this operation may be used.")
CG_ERROR_MACRO(7,
UnsupportedGLExtensionError,
CG_UNSUPPORTED_GL_EXTENSION_ERROR,
"An unsupported GL extension was required to perform this operation.")
CG_ERROR_MACRO(8,
InvalidValueTypeError,
CG_INVALID_VALUE_TYPE_ERROR,
"An unknown value type was assigned to a parameter.")
CG_ERROR_MACRO(9,
NotMatrixParamError,
CG_NOT_MATRIX_PARAM_ERROR,
"The parameter is not of matrix type.")
CG_ERROR_MACRO(10,
InvalidEnumerantError,
CG_INVALID_ENUMERANT_ERROR,
"The enumerant parameter has an invalid value.")
CG_ERROR_MACRO(11,
Not4x4MatrixError,
CG_NOT_4x4_MATRIX_ERROR,
"The parameter must be a 4x4 matrix type.")
CG_ERROR_MACRO(12,
FileReadError,
CG_FILE_READ_ERROR,
"The file could not be read.")
CG_ERROR_MACRO(13,
FileWriteError,
CG_FILE_WRITE_ERROR,
"The file could not be written.")
CG_ERROR_MACRO(14,
NVParseError,
CG_NVPARSE_ERROR,
"nvparse could not successfully parse the output from the Cg "
"compiler backend.")
CG_ERROR_MACRO(15,
MemoryAllocError,
CG_MEMORY_ALLOC_ERROR,
"Memory allocation failed.")
CG_ERROR_MACRO(16,
InvalidContextHandleError,
CG_INVALID_CONTEXT_HANDLE_ERROR,
"Invalid context handle.")
CG_ERROR_MACRO(17,
InvalidProgramHandleError,
CG_INVALID_PROGRAM_HANDLE_ERROR,
"Invalid program handle.")
CG_ERROR_MACRO(18,
InvalidParamHandleError,
CG_INVALID_PARAM_HANDLE_ERROR,
"Invalid parameter handle.")
CG_ERROR_MACRO(19,
UnknownProfileError,
CG_UNKNOWN_PROFILE_ERROR,
"The specified profile is unknown.")
CG_ERROR_MACRO(20,
VarArgError,
CG_VAR_ARG_ERROR,
"The variable arguments were specified incorrectly.")
CG_ERROR_MACRO(21,
InvalidDimensionError,
CG_INVALID_DIMENSION_ERROR,
"The dimension value is invalid.")
CG_ERROR_MACRO(22,
ArrayParamError,
CG_ARRAY_PARAM_ERROR,
"The parameter must be an array.")
CG_ERROR_MACRO(23,
OutOfArrayBoundsError,
CG_OUT_OF_ARRAY_BOUNDS_ERROR,
"Index into the array is out of bounds.")
#undef CG_ERROR_MACRO

View File

@@ -0,0 +1,88 @@
/*
*
* 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<49>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.
*
*/
/*
* The following macro invocations define the supported CG profiles.
*
* The macros have the form :
*
* CG_PROFILE_MACRO(name, compiler_id, compiler_opt)
*
* name : The name of the profile. Used consistently with the API.
* compiler_id : The identifier string for the profile used by the compiler.
* compiler_id_caps : compiler_id in caps.
* compiler_opt : The command-line switch used to force compilation into
* the profile.
* int_id : Integer enumerant associated with this bind location.
* vertex_profile : Non-zero if this is a vertex profile, otherwise it
* is considered to be a fragment profile.
*
*
*/
#define CG_IN_PROFILES_INCLUDE
#include "cgGL_profiles.h"
CG_PROFILE_MACRO(DX9Vertex11,vs_1_1,VS_1_1,"vs_1_1",6153,1)
CG_PROFILE_MACRO(DX9Vertex20,vs_2_0,VS_2_0,"vs_2_0",6154,1)
CG_PROFILE_MACRO(DX9Vertex2x,vs_2_x,VS_2_X,"vs_2_x",6155,1)
CG_PROFILE_MACRO(DX9Pixel11,ps_1_1,PS_1_1,"ps_1_1",6159,0)
CG_PROFILE_MACRO(DX9Pixel12,ps_1_2,PS_1_2,"ps_1_2",6160,0)
CG_PROFILE_MACRO(DX9Pixel13,ps_1_3,PS_1_3,"ps_1_3",6161,0)
CG_PROFILE_MACRO(DX9Pixel20,ps_2_0,PS_2_0,"ps_2_0",6162,0)
CG_PROFILE_MACRO(DX9Pixel2x,ps_2_x,PS_2_X,"ps_2_x",6163,0)
#undef CG_PROFILE_MACRO
#undef CG_IN_PROFILES_INCLUDE

View File

@@ -0,0 +1,183 @@
/*=============================================================================
GLCGPShader.cpp : OpenGL cg pixel shaders support.
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
Revision history:
* Created by Honitch Andrey
=============================================================================*/
#include "stdafx.h"
#include "GL_Renderer.h"
#include "GLCGPShader.h"
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
CPShader *CCGPShader_GL::m_LastPS;
//=======================================================================
void CCGPShader_GL::mfReset()
{
mfDel();
}
CCGPShader_GL::~CCGPShader_GL()
{
int i;
if (m_Script)
{
delete [] m_Script;
m_Script = NULL;
}
for (i=0; i<m_Params.Num(); i++)
{
SCGParam *pr = &m_Params[i];
SAFE_DELETE_ARRAY(pr->m_ParamName);
}
m_Params.Free();
m_Params.Free();
mfDel();
}
void CCGPShader_GL::mfCompileParam4f(char *scr, SShader *ef, TArray<SCGParam4f> *Params)
{
guard(CCGPShader_GL::mfCompileParam4f);
gcEf.mfCompileCGParam(scr, ef, Params);
unguard;
}
bool CCGPShader_GL::mfCompile(char *scr, SShader *ef)
{
char* name;
long cmd;
char *params;
char *data;
guard(CCGPShader_GL::mfCompile);
enum {eScript=1, eParam4f, eParamStateMatrix, ePointer, eNoFog};
static tokenDesc commands[] =
{
{eScript, "Script"},
{eParam4f, "Param4f"},
{0,0}
};
while ((cmd = shGetObject (&scr, commands, &name, &params)) > 0)
{
data = NULL;
if (name)
data = name;
else
if (params)
data = params;
switch (cmd)
{
case eParam4f:
mfCompileParam4f(params, ef, &m_Params);
break;
case eScript:
{
int len = strlen(data) + 1;
m_Script = new char [len];
memcpy(m_Script, data, len);
}
break;
}
}
unguard;
return 1;
}
void CCGPShader_GL::mfSetVariables(TArray<SCGParam4f>* Vars)
{
int i;
if (!Vars)
return;
for (i=0; i<Vars->Num(); i++)
{
SCGParam4f *p = &Vars->Get(i);
if (!p->m_pBind)
{
char str[128];
strcpy(str, "main.");
strcat(str, p->m_ParamName);
p->m_pBind = cgGetBindByName(m_CGProgram, str);
if (p->m_pBind == NULL)
{
iLog->Log("Couldn't find parameter '%s' in CG program '%s' (%s)", str, m_Name);
p->m_pBind = (void *)(-1);
continue;
}
}
if ((int)p->m_pBind == -1)
continue;
float *v = p->mfGet();
mfParameter4f((cgBindIter *)p->m_pBind, v);
}
}
bool CCGPShader_GL::mfActivate()
{
if (!m_CGProgram)
{
mfLoad(m_Script);
mfUnbind();
}
return true;
}
bool CCGPShader_GL::mfSet(bool bStat, SShadeLayerHW *slw)
{
if (!bStat)
{
if (CRenderer::CV_r_log == 4)
gRenDev->Logv(SRendItem::m_RecurseLevel, "--- Reset CGPShader \"%s\"\n", m_Name);
mfDisable();
return true;
}
if (CRenderer::CV_r_log == 4)
gRenDev->Logv(SRendItem::m_RecurseLevel, "--- Set CGPShader \"%s\"\n", m_Name);
if (m_CGProgram < 0)
return false;
if (!m_CGProgram)
{
if (!mfActivate())
return false;
m_LastPS = NULL;
}
if (m_Frame != gRenDev->GetFrameID())
{
m_Frame = gRenDev->GetFrameID();
gRenDev->m_RP.m_PS.m_NumCGPShaders++;
}
if (m_LastPS != this)
{
m_LastPS = this;
mfBind();
}
mfEnable();
mfSetVariables(&m_Params);
if (slw)
mfSetVariables(slw->m_CGPSParams);
return true;
}

View File

@@ -0,0 +1,442 @@
/*=============================================================================
D3DCGPShader.h : Direct3D8 CG pixel shaders interface declaration.
Copyright 1999 K&M. All Rights Reserved.
Revision history:
* Created by Honitch Andrey
=============================================================================*/
#ifndef __D3DCGPSHADER_H__
#define __D3DCGPSAHDER_H__
#ifndef _XBOX
#include "cg\cgD3D8.h"
#endif
#include "D3DPShaders.h"
class CCGPShader_D3D : public CPShader
{
uint m_Flags;
SCGScript *m_Script;
SCGScript *m_DeclarationsScript;
SCGScript *m_CoreScript;
SCGScript *m_InputParmsScript;
TArray<SCGParam4f> m_Params;
int m_CurInst;
#ifndef _XBOX
CGprofile m_CGProfileType;
#endif
struct SCGInstance
{
int m_Mask;
TArray<SCGParam4f> *m_Params;
TArray<SCGBindConst> *m_BindConstants;
TArray<SCGBind> *m_BindVars;
union
{
#ifndef _XBOX
CGprogram m_CGProgram;
#endif
int m_dwHandle;
};
};
TArray<SCGInstance> m_Insts;
public:
virtual int Size()
{
return 0;
}
#ifndef _XBOX
void mfSaveCGFile(const char *scr)
{
char name[128];
sprintf(name, "%s.cg", m_Name.c_str());
FILE *fp = fopen(name, "w");
fprintf(fp, scr);
fclose (fp);
}
static void mfCgErrorCallback()
{
CGerror error = cgGetError(); // Recall that cgGetError() removes the error from the stack error, so you won't be able to check it later on
const char* str = cgD3D8TranslateCGerror(error);
CCGPShader_D3D *pPS = (CCGPShader_D3D *)gRenDev->m_RP.m_CurPS;
iLog->Log("WARNING: CCGPShader_D3D::mfError: (CGError: '%s' in CG program '%s')\n", str, pPS->m_Name.c_str());
if (error == cgD3D8Failed)
{
HRESULT hres = cgD3D8GetLastError();
const char* errStr = cgD3D8TranslateHRESULT(hres);
iLog->Log("WARNING: CCGPShader_D3D::mfError: (D3DError: '%s' in CG program '%s')\n", errStr, pPS->m_Name.c_str());
}
else
if (error == cgD3D8DebugTrace)
bool debugTrace = true;
else
bool otherError = true;
if (gRenDev->m_RP.m_CurPS && gRenDev->m_RP.m_CurPS->mfGetCurScript())
{
pPS->mfSaveCGFile(gRenDev->m_RP.m_CurPS->mfGetCurScript());
}
}
#endif
CCGPShader_D3D()
{
mfInit();
#ifndef _XBOX
m_CGProfileType = cgD3D8GetLatestPixelProfile();
#endif
}
void mfInit()
{
#ifndef _XBOX
if (!gcpRendD3D->m_CGContext)
{
cgD3D8SetDevice(gcpRendD3D->mfGetD3DDevice());
gcpRendD3D->m_CGContext = cgCreateContext();
assert(gcpRendD3D->m_CGContext);
cgSetErrorCallback(mfCgErrorCallback);
#ifdef _DEBUG
cgD3D8EnableDebugTracing(true);
#endif
}
#endif
m_CurScript = NULL;
m_CurInst = -1;
m_Flags = 0;
m_Script = NULL;
m_CoreScript = NULL;
m_InputParmsScript = NULL;
m_DeclarationsScript = NULL;
m_bCGType = true;
}
void mfFree();
void mfGetSrcFileName(char *srcname);
void mfGetDstFileName(char *dstname, SCGScript *pPosScr);
void mfUnbind()
{
gcpRendD3D->mfGetD3DDevice()->SetPixelShader(NULL);
}
void mfBind()
{
HRESULT hr;
if (m_Insts[m_CurInst].m_dwHandle)
{
hr = gcpRendD3D->mfGetD3DDevice()->SetPixelShader(m_Insts[m_CurInst].m_dwHandle);
if (FAILED(hr))
return;
}
if (m_Insts[m_CurInst].m_BindConstants)
{
int i;
for (i=0; i<m_Insts[m_CurInst].m_BindConstants->Num(); i++)
{
SCGBindConst *p = &m_Insts[m_CurInst].m_BindConstants->Get(i);
gcpRendD3D->mfGetD3DDevice()->SetPixelShaderConstant(p->m_dwBind, &p->m_Val[0], 1);
}
}
}
int mfGetCGInstanceID(int Num)
{
SCGInstance *cgc;
if (m_CurInst >= 0 && m_Insts.Num() > m_CurInst)
{
cgc = &m_Insts[m_CurInst];
if (cgc->m_Mask == Num)
{
return m_CurInst;
}
}
int i;
for (i=0; i<m_Insts.Num(); i++)
{
cgc = &m_Insts[i];
if (cgc->m_Mask == Num)
{
m_CurInst = i;
return i;
}
}
SCGInstance cg;
cg.m_Mask = Num;
cg.m_BindConstants = NULL;
cg.m_BindVars = NULL;
cg.m_dwHandle = 0;
#ifndef _XBOX
cg.m_CGProgram = NULL;
#endif
cg.m_Params = NULL;
m_Insts.AddElem(cg);
m_CurInst = m_Insts.Num()-1;
return m_CurInst;
}
#ifndef _XBOX
const char *mfGetObjectCode(int Num)
{
CGprogram pi = NULL;
if (m_Insts[m_CurInst].m_CGProgram && (int)m_Insts[m_CurInst].m_CGProgram != -1)
pi = m_Insts[m_CurInst].m_CGProgram;
else
{
for (int i=0; i<m_Insts.Num(); i++)
{
if (m_Insts[i].m_CGProgram && (int)m_Insts[i].m_CGProgram != -1)
{
pi = m_Insts[i].m_CGProgram;
break;
}
}
}
if (pi)
return cgGetProgramString(pi, CG_COMPILED_PROGRAM);
return NULL;
}
const char *mfLoadCG(const char *prog_text)
{
// Test adding source text to context
m_CurScript = prog_text;
const char *profileOpts[] =
{
cgD3D8GetOptimalOptions(m_CGProfileType),
NULL,
};
m_Insts[m_CurInst].m_CGProgram = cgCreateProgram(gcpRendD3D->m_CGContext, CG_SOURCE, prog_text, m_CGProfileType, "main", profileOpts);
CGerror err = cgGetError();
if (err != CG_NO_ERROR)
{
iLog->Log("Couldn't create CG pixel program '%s' (%s)", m_Name.c_str(), cgGetErrorString(err));
mfSaveCGFile(prog_text);
return NULL;
}
if (!m_Insts[m_CurInst].m_CGProgram)
{
iLog->Log("Couldn't find function '%s' in CG program '%s'", "main", m_Name.c_str());
return NULL;
}
// Assemble the shader
if (FAILED(cgD3D8LoadProgram(m_Insts[m_CurInst].m_CGProgram, false, 0, 0, NULL)))
{
iLog->Log("Couldn't load CG vertex program '%s'", m_Name.c_str());
return NULL;
}
m_CurScript = NULL;
if (m_Insts[m_CurInst].m_CGProgram)
{
const char *code = mfGetObjectCode(-1);
return code;
}
return NULL;
}
#endif
void mfLoad(const char *prog_text)
{
// Load and create vertex shader
HRESULT hr;
#ifdef _XBOX
LPXGBUFFER pCode;
LPXGBUFFER pBuffer = NULL;
hr = XGAssembleShader(m_Name.c_str(), prog_text, strlen(prog_text), 0, NULL, &pCode, &pBuffer, NULL, NULL, NULL, 0);
#else
LPD3DXBUFFER pCode;
LPD3DXBUFFER pBuffer = NULL;
hr = D3DXAssembleShader(prog_text, strlen(prog_text), 0, NULL, &pCode, &pBuffer);
#endif
if (FAILED(hr))
{
iLog->Log("WARNING: CCGPShader_D3D::mfLoad: Could not assemble vertex shader '%s' (%s)\n", m_Name.c_str(), gcpRendD3D->D3DError(hr));
if( pBuffer != NULL)
{
TCHAR* pstr;
TCHAR strOut[4096];
TCHAR* pstrOut;
// Need to replace \n with \r\n so edit box shows newlines properly
pstr = (TCHAR*)pBuffer->GetBufferPointer();
strOut[0] = '\0';
pstrOut = strOut;
for( int i = 0; i < 4096; i++ )
{
if( *pstr == '\n' )
*pstrOut++ = '\r';
*pstrOut = *pstr;
if( *pstr == '\0' )
break;
if( i == 4095 )
*pstrOut = '\0';
pstrOut++;
pstr++;
}
// remove any blank lines at the end
while( strOut[lstrlen(strOut) - 1] == '\n' || strOut[lstrlen(strOut) - 1] == '\r' )
{
strOut[lstrlen(strOut) - 1] = '\0';
}
iLog->Log("WARNING: CCGPShader_D3D::mfLoad: Shader script error (%s)\n", strOut);
SAFE_RELEASE( pBuffer );
}
}
#ifndef _XBOX
hr = gcpRendD3D->mfGetD3DDevice()->CreatePixelShader((DWORD*)pCode->GetBufferPointer(), (DWORD*)&m_Insts[m_CurInst].m_dwHandle);
#else
hr = gcpRendD3D->mfGetD3DDevice()->CreatePixelShader((D3DPIXELSHADERDEF*)pCode->GetBufferPointer(), (DWORD*)&m_Insts[m_CurInst].m_dwHandle);
#endif
if (FAILED(hr))
{
iLog->Log("CCGPShader_D3D::mfLoad: Could not create vertex shader '%s' (%s)\n", m_Name.c_str(), gcpRendD3D->D3DError(hr));
return;
}
}
void mfParameter(SCGParam *ParamBind, const float *v, int nComps)
{
if (!ParamBind->m_dwBind)
{
if (m_Insts[m_CurInst].m_BindVars)
{
int i;
for (i=0; i<m_Insts[m_CurInst].m_BindVars->Num(); i++)
{
SCGBind *p = &m_Insts[m_CurInst].m_BindVars->Get(i);
if (p->m_Name == ParamBind->m_Name)
{
assert(p->m_nComponents <= nComps);
ParamBind->m_dwBind = p->m_dwBind;
if (ParamBind->m_dwBind == 0)
ParamBind->m_dwBind = 65536;
ParamBind->m_nBindComponents = p->m_nComponents;
break;
}
}
if (i == m_Insts[m_CurInst].m_BindVars->Num())
ParamBind->m_dwBind = -1;
}
else
ParamBind->m_dwBind = -1;
if (ParamBind->m_dwBind == -1)
return;
}
if (ParamBind->m_dwBind == 65536)
gcpRendD3D->mfGetD3DDevice()->SetPixelShaderConstant(0, v, nComps);
else
gcpRendD3D->mfGetD3DDevice()->SetPixelShaderConstant(ParamBind->m_dwBind, v, nComps);
}
void mfParameter4f(SCGParam *ParamBind, const vec4_t v)
{
mfParameter(ParamBind, v, 1);
}
void mfDel()
{
if(m_Insts[m_CurInst].m_dwHandle && (int)m_Insts[m_CurInst].m_dwHandle != -1)
{
if (m_Insts[m_CurInst].m_BindConstants)
delete m_Insts[m_CurInst].m_BindConstants;
if (m_Insts[m_CurInst].m_BindVars)
delete m_Insts[m_CurInst].m_BindVars;
if (m_Insts[m_CurInst].m_Params)
delete m_Insts[m_CurInst].m_Params;
if (m_Insts[m_CurInst].m_dwHandle)
{
gcpRendD3D->mfGetD3DDevice()->DeletePixelShader(m_Insts[m_CurInst].m_dwHandle);
m_Insts[m_CurInst].m_dwHandle = 0;
}
}
m_Insts[m_CurInst].m_dwHandle = 0;
}
bool mfIsValid(int Num) const { return (m_Insts[Num].m_dwHandle != 0); }
SCGScript *mfGenerateScriptVP();
void mfSetVariables(TArray<SCGParam4f>* Vars);
public:
char *mfCreateAdditionalVP();
void mfCompileParam4f(char *scr, SShader *ef, TArray<SCGParam4f> *Params, int nLights);
bool mfActivate() { return false; }
public:
virtual ~CCGPShader_D3D() {};
virtual bool mfCompile(char *scr) { return false; }
virtual bool mfSet(bool bStat, int nSetPointers=1) { return false; }
virtual void mfSetVariables(TArray<SParam>* Vars) {}
virtual void mfReset() {}
virtual const char *mfGetCurScript() { return m_CurScript; }
virtual bool mfIsCombiner() { return false; }
virtual void mfEnable() {}
virtual void mfDisable() {}
static SCGScript *mfAddNewScript(const char *Name, const char *Script)
{
int i;
if (Name)
{
CName nm = CName(Name);
if (nm.GetIndex())
{
for (i=0; i<m_CGScripts.Num(); i++)
{
SCGScript *scr = m_CGScripts[i];
if (!scr || !scr->m_Name.GetIndex())
continue;
if (nm == scr->m_Name)
{
if (!Script || stricmp(Script, scr->m_Script) == 0)
return scr;
delete [] scr->m_Script;
break;
}
}
}
}
if (!Script)
{
if (Name)
iLog->Log("Error: CCGPShader_GL::mfAddNewScript: Couldn't find CG script for name '%s'", Name);
return NULL;
}
SCGScript *scr = new SCGScript;
if (Name)
scr->m_Name = CName(Name, eFN_Add);
int len = strlen(Script)+1;
scr->m_Script = new char[len];
strcpy(scr->m_Script, Script);
if (Name)
m_CGScripts.AddElem(scr);
return scr;
}
static void mfDeleteSharedScripts()
{
int i;
for (i=0; i<m_CGScripts.Num(); i++)
{
SCGScript *scr = m_CGScripts[i];
if (!scr)
continue;
SAFE_DELETE_ARRAY(scr->m_Script);
delete scr;
m_CGScripts[i] = NULL;
}
}
const char *m_CurScript;
static TArray<SCGScript *> m_CGScripts;
};
#endif // __D3DCGPSHADER_H__

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,608 @@
/*=============================================================================
D3DCGVProgram.h : Direct3D CG programs interface declaration.
Copyright 1999 K&M. All Rights Reserved.
Revision history:
* Created by Honitch Andrey
=============================================================================*/
#ifndef __D3DCGVPROGRAM_H__
#define __D3DCGVPROGRAM_H__
#ifndef _XBOX
#include "cg\cgD3D8.h"
#endif
#define CG_CACHE_VER 1.0
#define VPFI_NOFOG 1
#define VPFI_UNIFIEDPOS 2
#define VPFI_SUPPORTMULTVLIGHTS 4
#define VPFI_NOISE 8
class CCGVProgram_D3D : public CVProgram
{
uint m_Flags;
SCGScript *m_Script;
SCGScript *m_PosScript;
SCGScript *m_DeclarationsScript;
SCGScript *m_CoreScript;
SCGScript *m_InputParmsScript;
TArray<SCGParam4f> m_ParamsNoObj;
TArray<SCGMatrix> m_MatrixNoObj;
TArray<SCGParam4f> m_ParamsObj;
TArray<SCGMatrix> m_MatrixObj;
TArray<SArrayPointer *> m_Pointers;
int m_CurInst;
#ifndef _XBOX
CGprofile m_CGProfileType;
#endif
struct SCGInstance
{
int Streams;
int VertFormat;
int m_Mask;
CName m_PosScriptName;
TArray<SCGParam4f> *m_ParamsNoObj;
TArray<SCGMatrix> *m_MatrixNoObj;
TArray<SCGParam4f> *m_ParamsObj;
TArray<SCGMatrix> *m_MatrixObj;
TArray<SCGBindConst> *m_BindConstants;
TArray<SCGBind> *m_BindVars;
union
{
#ifndef _XBOX
CGprogram m_CGProgram;
#endif
DWORD m_dwHandle;
};
};
TArray<SCGInstance> m_Insts;
public:
virtual int Size()
{
return 0;
}
#ifndef _XBOX
void mfSaveCGFile(const char *scr)
{
char name[128];
sprintf(name, "%s.cg", m_Name.c_str());
FILE *fp = fopen(name, "w");
fprintf(fp, scr);
fclose (fp);
}
static void mfCgErrorCallback()
{
CGerror error = cgGetError(); // Recall that cgGetError() removes the error from the stack error, so you won't be able to check it later on
const char* str = cgD3D8TranslateCGerror(error);
CCGVProgram_D3D *pVP = (CCGVProgram_D3D *)gRenDev->m_RP.m_CurVP;
iLog->Log("WARNING: CCGVProgram_D3D::mfError: (CGError: '%s' in CG program '%s')\n", str, pVP->m_Name.c_str());
if (error == cgD3D8Failed)
{
HRESULT hres = cgD3D8GetLastError();
const char* errStr = cgD3D8TranslateHRESULT(hres);
iLog->Log("WARNING: CCGVProgram_D3D::mfError: (D3DError: '%s' in CG program '%s')\n", errStr, pVP->m_Name.c_str());
}
else
if (error == cgD3D8DebugTrace)
bool debugTrace = true;
else
bool otherError = true;
if (gRenDev->m_RP.m_CurVP && gRenDev->m_RP.m_CurVP->mfGetCurScript())
{
pVP->mfSaveCGFile(gRenDev->m_RP.m_CurVP->mfGetCurScript());
}
}
#endif
CCGVProgram_D3D()
{
mfInit();
#ifndef _XBOX
m_CGProfileType = cgD3D8GetLatestVertexProfile();
#endif
}
void mfInit()
{
#ifndef _XBOX
if (!gcpRendD3D->m_CGContext)
{
cgD3D8SetDevice(gcpRendD3D->mfGetD3DDevice());
gcpRendD3D->m_CGContext = cgCreateContext();
assert(gcpRendD3D->m_CGContext);
cgSetErrorCallback(mfCgErrorCallback);
#ifdef _DEBUG
cgD3D8EnableDebugTracing(true);
#endif
}
#endif
m_CurScript = NULL;
m_CurInst = -1;
m_Flags = 0;
m_Script = NULL;
m_CoreScript = NULL;
m_InputParmsScript = NULL;
m_PosScript = NULL;
m_DeclarationsScript = NULL;
m_bCGType = true;
}
void mfFree();
void mfGetSrcFileName(char *srcname);
void mfGetDstFileName(char *dstname, SCGScript *pPosScr);
void mfUnbind()
{
}
void mfBind()
{
HRESULT hr;
if (m_Insts[m_CurInst].m_dwHandle)
{
hr = gcpRendD3D->mfGetD3DDevice()->SetVertexShader(m_Insts[m_CurInst].m_dwHandle);
if (FAILED(hr))
return;
}
if (m_Insts[m_CurInst].m_BindConstants)
{
int i;
for (i=0; i<m_Insts[m_CurInst].m_BindConstants->Num(); i++)
{
SCGBindConst *p = &m_Insts[m_CurInst].m_BindConstants->Get(i);
gcpRendD3D->mfGetD3DDevice()->SetVertexShaderConstant(p->m_dwBind, &p->m_Val[0], 1);
}
}
}
int mfGetCGInstanceID(int Streams, int VertFormat, int Num, CCGVProgram_D3D *pPosVP)
{
SCGInstance *cgc;
if (m_CurInst >= 0 && m_Insts.Num() > m_CurInst)
{
cgc = &m_Insts[m_CurInst];
if (cgc->Streams == Streams && cgc->VertFormat == VertFormat && cgc->m_Mask == Num)
{
if (!pPosVP || pPosVP->m_PosScript->m_Name == cgc->m_PosScriptName)
return m_CurInst;
}
}
int i;
for (i=0; i<m_Insts.Num(); i++)
{
cgc = &m_Insts[i];
if (cgc->Streams == Streams && cgc->VertFormat == VertFormat && cgc->m_Mask == Num && (!pPosVP || pPosVP->m_PosScript->m_Name == cgc->m_PosScriptName))
{
m_CurInst = i;
return i;
}
}
SCGInstance cg;
cg.Streams = Streams;
cg.VertFormat = VertFormat;
cg.m_Mask = Num;
cg.m_BindConstants = NULL;
cg.m_BindVars = NULL;
cg.m_dwHandle = 0;
#ifndef _XBOX
cg.m_CGProgram = NULL;
#endif
cg.m_ParamsNoObj = NULL;
cg.m_ParamsObj = NULL;
cg.m_MatrixNoObj = NULL;
cg.m_MatrixObj = NULL;
if (Num & VPVST_FOGGLOBAL)
{
if (!cg.m_ParamsNoObj)
cg.m_ParamsNoObj = new TArray<SCGParam4f>;
SCGParam4f pr;
pr.m_Name = "Fog";
pr.m_nComponents = 1;
pr.m_pBind = NULL;
SParamComp_Fog p;
p.m_Type = 2;
pr.m_Comps[0] = SParamComp::mfAdd(&p);
p.m_Type = 3;
pr.m_Comps[1] = SParamComp::mfAdd(&p);
cg.m_ParamsNoObj->AddElem(pr);
}
if (Num & VPVST_CLIPPLANES)
{
if (!cg.m_ParamsNoObj)
cg.m_ParamsNoObj = new TArray<SCGParam4f>;
SCGParam4f pr;
pr.m_nComponents = 1;
pr.m_pBind = NULL;
pr.m_Name = "ClipPlane";
SParamComp_ClipPlane p;
pr.m_Flags = PF_CANMERGED;
pr.m_Comps[0] = SParamComp::mfAdd(&p);
cg.m_ParamsNoObj->AddElem(pr);
}
if (pPosVP && pPosVP->m_PosScript)
{
cg.m_PosScriptName = pPosVP->m_PosScript->m_Name;
if (cg.m_PosScriptName != m_PosScript->m_Name && pPosVP->m_ParamsNoObj.Num())
{
if (!cg.m_ParamsNoObj)
cg.m_ParamsNoObj = new TArray<SCGParam4f>;
for (int i=0; i<pPosVP->m_ParamsNoObj.Num(); i++)
{
cg.m_ParamsNoObj->AddElem(pPosVP->m_ParamsNoObj[i]);
cg.m_ParamsNoObj->Get(cg.m_ParamsNoObj->Num()-1).m_pBind = NULL;
cg.m_ParamsNoObj->Get(cg.m_ParamsNoObj->Num()-1).m_dwBind = 0;
}
cg.m_ParamsNoObj->Shrink();
for (int i=0; i<pPosVP->m_ParamsObj.Num(); i++)
{
cg.m_ParamsObj->AddElem(pPosVP->m_ParamsObj[i]);
cg.m_ParamsObj->Get(cg.m_ParamsObj->Num()-1).m_pBind = NULL;
cg.m_ParamsObj->Get(cg.m_ParamsObj->Num()-1).m_dwBind = 0;
}
cg.m_ParamsObj->Shrink();
}
}
m_Insts.AddElem(cg);
m_CurInst = m_Insts.Num()-1;
return m_CurInst;
}
#ifndef _XBOX
const char *mfGetObjectCode(CGprogram cgPr)
{
return cgGetProgramString(cgPr, CG_COMPILED_PROGRAM);
}
const char *mfLoadCG(const char *prog_text)
{
// Test adding source text to context
m_CurScript = prog_text;
const char *profileOpts[] =
{
cgD3D8GetOptimalOptions(m_CGProfileType),
NULL,
};
m_Insts[m_CurInst].m_CGProgram = cgCreateProgram(gcpRendD3D->m_CGContext, CG_SOURCE, prog_text, m_CGProfileType, "main", profileOpts);
CGerror err = cgGetError();
if (err != CG_NO_ERROR)
{
iLog->Log("Couldn't create CG program '%s' (%s)", m_Name.c_str(), cgGetErrorString(err));
mfSaveCGFile(prog_text);
m_CurScript = NULL;
return NULL;
}
if (!m_Insts[m_CurInst].m_CGProgram)
{
iLog->Log("Couldn't load function '%s' in CG program '%s'", "main", m_Name.c_str());
m_CurScript = NULL;
return NULL;
}
// Assemble the shader
if (FAILED(cgD3D8LoadProgram(m_Insts[m_CurInst].m_CGProgram, false, 0, 0, &gRenDev->m_RP.m_D3DFixedPipeline[m_Insts[m_CurInst].Streams][m_Insts[m_CurInst].VertFormat].m_Declaration[0])))
{
iLog->Log("Couldn't load CG vertex program '%s'", m_Name.c_str());
m_CurScript = NULL;
return NULL;
}
m_CurScript = NULL;
if (m_Insts[m_CurInst].m_CGProgram)
{
const char *code = mfGetObjectCode(-1);
return code;
}
return NULL;
}
#endif
void mfLoad(const char *prog_text)
{
// Load and create vertex shader
HRESULT hr;
#ifdef _XBOX
LPXGBUFFER pCode;
LPXGBUFFER pBuffer = NULL;
hr = XGAssembleShader(m_Name.c_str(), prog_text, strlen(prog_text), 0, NULL, &pCode, &pBuffer, NULL, NULL, NULL, 0);
#else
LPD3DXBUFFER pCode;
LPD3DXBUFFER pBuffer = NULL;
hr = D3DXAssembleShader( prog_text, strlen(prog_text), 0, NULL, &pCode, &pBuffer );
#endif
if (FAILED(hr))
{
iLog->Log("WARNING: CCGVProgram_D3D::mfLoad: Could not assemble vertex shader '%s' (%s)\n", m_Name.c_str(), gcpRendD3D->D3DError(hr));
if( pBuffer != NULL)
{
TCHAR* pstr;
TCHAR strOut[4096];
TCHAR* pstrOut;
// Need to replace \n with \r\n so edit box shows newlines properly
pstr = (TCHAR*)pBuffer->GetBufferPointer();
strOut[0] = '\0';
pstrOut = strOut;
for( int i = 0; i < 4096; i++ )
{
if( *pstr == '\n' )
*pstrOut++ = '\r';
*pstrOut = *pstr;
if( *pstr == '\0' )
break;
if( i == 4095 )
*pstrOut = '\0';
pstrOut++;
pstr++;
}
// remove any blank lines at the end
while( strOut[lstrlen(strOut) - 1] == '\n' || strOut[lstrlen(strOut) - 1] == '\r' )
{
strOut[lstrlen(strOut) - 1] = '\0';
}
iLog->Log("WARNING: CCGVProgram_D3D::mfLoad: Shader script error (%s)\n", strOut);
SAFE_RELEASE( pBuffer );
}
}
hr = gcpRendD3D->mfGetD3DDevice()->CreateVertexShader( &gRenDev->m_RP.m_D3DFixedPipeline[m_Insts[m_CurInst].Streams][m_Insts[m_CurInst].VertFormat].m_Declaration[0], (DWORD*)pCode->GetBufferPointer(), (DWORD *)&m_Insts[m_CurInst].m_dwHandle, 0);
if (FAILED(hr))
{
iLog->Log("CCGVProgram_D3D::mfLoad: Could not create vertex shader '%s'\n", m_Name.c_str());
return;
}
}
SCGBind *mfGetParameterBind(const char *Name)
{
CName nm = CName(Name, eFN_Add);
if (!m_Insts[m_CurInst].m_BindVars)
m_Insts[m_CurInst].m_BindVars = new TArray<SCGBind>;
int i;
for (i=0; i<m_Insts[m_CurInst].m_BindVars->Num(); i++)
{
if (nm == m_Insts[m_CurInst].m_BindVars->Get(i).m_Name)
return &m_Insts[m_CurInst].m_BindVars->Get(i);
}
return NULL;
}
void mfParameter(SCGBind *ParamBind, const float *v, int nComps)
{
if (!ParamBind->m_dwBind)
{
if (m_Insts[m_CurInst].m_BindVars)
{
int i;
for (i=0; i<m_Insts[m_CurInst].m_BindVars->Num(); i++)
{
SCGBind *p = &m_Insts[m_CurInst].m_BindVars->Get(i);
if (p->m_Name == ParamBind->m_Name)
{
assert(p->m_nComponents <= nComps);
ParamBind->m_dwBind = p->m_dwBind;
if (ParamBind->m_dwBind == 0)
ParamBind->m_dwBind = 65536;
ParamBind->m_nBindComponents = p->m_nComponents;
break;
}
}
if (i == m_Insts[m_CurInst].m_BindVars->Num())
ParamBind->m_dwBind = -1;
}
else
ParamBind->m_dwBind = -1;
}
if (ParamBind->m_dwBind == -1)
return;
if (ParamBind->m_dwBind == 65536)
gcpRendD3D->mfGetD3DDevice()->SetVertexShaderConstant(0, v, ParamBind->m_nBindComponents);
else
gcpRendD3D->mfGetD3DDevice()->SetVertexShaderConstant(ParamBind->m_dwBind, v, ParamBind->m_nBindComponents);
}
void mfParameter4f(SCGBind *ParamBind, const vec4_t v)
{
mfParameter(ParamBind, v, 1);
}
int m_ObjFrame;
void mfParameterStateMatrix(SCGMatrix *ParamBind)
{
static int sFrame;
static int sFlags;
static D3DXMATRIX matWorldViewProj;
CD3D8Renderer *r = gcpRendD3D;
LPDIRECT3DDEVICE8 dv = r->mfGetD3DDevice();
D3DXMATRIX *matView = r->m_matView->GetTop();
switch(ParamBind->m_eCGParamType)
{
case ECGP_Matr_ViewProj:
{
if (sFrame != r->m_RP.m_FrameObject)
{
sFrame = r->m_RP.m_FrameObject;
D3DXMATRIX *matProj = r->m_matProj->GetTop();
D3DXMatrixMultiply(&matWorldViewProj, matView, matProj);
D3DXMatrixTranspose(&matWorldViewProj, &matWorldViewProj);
}
if (m_ObjFrame != r->m_RP.m_FrameObject)
{
m_ObjFrame = r->m_RP.m_FrameObject;
mfParameter(ParamBind, &matWorldViewProj(0, 0), 4);
}
}
break;
case ECGP_Matr_View_IT:
D3DXMatrixInverse(&matWorldViewProj, NULL, matView);
mfParameter(ParamBind, &matWorldViewProj(0, 0), 4);
break;
case ECGP_Matr_View:
D3DXMatrixTranspose(&matWorldViewProj, matView);
mfParameter(ParamBind, &matWorldViewProj(0, 0), 4);
break;
case ECGP_Matr_View_I:
D3DXMatrixInverse(&matWorldViewProj, NULL, matView);
D3DXMatrixTranspose(&matWorldViewProj, &matWorldViewProj);
mfParameter(ParamBind, &matWorldViewProj(0, 0), 4);
break;
case ECGP_Matr_View_T:
mfParameter(ParamBind, (float *)matView, 4);
break;
default:
iLog->Log("Unknown matrix state type %d int CG program '%s'", m_Name.c_str());
assert(0);
}
}
void mfSetStateMatrices(bool bObj)
{
if (!bObj)
{
for (int i=0; i<m_MatrixNoObj.Num(); i++)
{
SCGMatrix *tm = &m_MatrixNoObj[i];
mfParameterStateMatrix(tm);
}
if (m_Insts[m_CurInst].m_MatrixNoObj)
{
for (int i=0; i<m_Insts[m_CurInst].m_MatrixNoObj->Num(); i++)
{
SCGMatrix *tm = &m_Insts[m_CurInst].m_MatrixNoObj->Get(i);
mfParameterStateMatrix(tm);
}
}
}
else
{
for (int i=0; i<m_MatrixObj.Num(); i++)
{
SCGMatrix *tm = &m_MatrixObj[i];
mfParameterStateMatrix(tm);
}
if (m_Insts[m_CurInst].m_MatrixObj)
{
for (int i=0; i<m_Insts[m_CurInst].m_MatrixObj->Num(); i++)
{
SCGMatrix *tm = &m_Insts[m_CurInst].m_MatrixObj->Get(i);
mfParameterStateMatrix(tm);
}
}
}
}
void mfDel()
{
if(m_Insts[m_CurInst].m_dwHandle && (int)m_Insts[m_CurInst].m_dwHandle != -1)
{
if (m_Insts[m_CurInst].m_BindConstants)
delete m_Insts[m_CurInst].m_BindConstants;
if (m_Insts[m_CurInst].m_BindVars)
delete m_Insts[m_CurInst].m_BindVars;
if (m_Insts[m_CurInst].m_ParamsNoObj)
delete m_Insts[m_CurInst].m_ParamsNoObj;
if (m_Insts[m_CurInst].m_ParamsObj)
delete m_Insts[m_CurInst].m_ParamsObj;
if (m_Insts[m_CurInst].m_MatrixNoObj)
delete m_Insts[m_CurInst].m_MatrixNoObj;
if (m_Insts[m_CurInst].m_MatrixObj)
delete m_Insts[m_CurInst].m_MatrixObj;
if (m_Insts[m_CurInst].m_dwHandle)
{
gcpRendD3D->mfGetD3DDevice()->DeleteVertexShader(m_Insts[m_CurInst].m_dwHandle);
m_Insts[m_CurInst].m_dwHandle = 0;
}
}
m_Insts[m_CurInst].m_dwHandle = 0;
}
bool mfIsValid(int Num) const { return (m_Insts[Num].m_dwHandle != 0); }
SCGScript *mfGenerateScriptVP(SCGScript *pPosScript);
void mfCompileVertAttributes(char *scr, SShader *ef);
void mfSetVariables(TArray<SCGParam4f>* Vars);
public:
char *mfCreateAdditionalVP(SCGScript *pPosScript);
void mfCompileParam4f(char *scr, SShader *ef, TArray<SCGParam4f> *Params, int nLights);
void mfCompileParamStateMatrix(char *scr, SShader *ef, TArray<SCGMatrix> *Params);
bool mfActivate(CCGVProgram_D3D *pPosVP);
public:
virtual ~CCGVProgram_D3D();
virtual bool mfCompile(char *scr);
virtual bool mfSet(bool bStat, SShaderPassHW *slw, int nSetPointers=1);
virtual void mfSetVariables(bool bObj, TArray<SCGParam4f>* Vars);
virtual void mfReset();
virtual void mfPrecache();
virtual bool mfHasPointer(ESrcPointer ePtr);
virtual const char *mfGetCurScript() { return m_CurScript; }
static SCGScript *mfAddNewScript(const char *Name, const char *Script)
{
int i;
if (Name)
{
CName nm = CName(Name);
if (nm.GetIndex())
{
for (i=0; i<m_CGScripts.Num(); i++)
{
SCGScript *scr = m_CGScripts[i];
if (!scr || !scr->m_Name.GetIndex())
continue;
if (nm == scr->m_Name)
{
if (!Script || stricmp(Script, scr->m_Script) == 0)
return scr;
delete [] scr->m_Script;
break;
}
}
}
}
if (!Script)
{
if (Name)
iLog->Log("Error: CCGVProgram_GL::mfAddNewScript: Couldn't find CG script for name '%s'", Name);
return NULL;
}
SCGScript *scr = new SCGScript;
if (Name)
scr->m_Name = CName(Name, eFN_Add);
int len = strlen(Script)+1;
scr->m_Script = new char[len];
strcpy(scr->m_Script, Script);
if (Name)
m_CGScripts.AddElem(scr);
return scr;
}
static void mfDeleteSharedScripts()
{
int i;
for (i=0; i<m_CGScripts.Num(); i++)
{
SCGScript *scr = m_CGScripts[i];
if (!scr)
continue;
SAFE_DELETE_ARRAY(scr->m_Script);
delete scr;
m_CGScripts[i] = NULL;
}
}
static TArray<SCGScript *> m_CGScripts;
};
#endif // __D3DCGVPROGRAMS_H__

View File

@@ -0,0 +1,192 @@
#ifndef D3DCUBEMAPS_H
#define D3DCUBEMAPS_H
struct SSingleLight
{
typedef byte Type;
int components;
int format;
SSingleLight(float _power) :
components(3), format(D3DFMT_X8R8G8B8), power(_power) {}
void operator() (const Vec3d& v, Type * t)
{
float z = v[2] > 0 ? v[2] : 0;
z = (float)pow(z, power);
t[0] = (Type)(z * 255.0f);
t[1] = (Type)(z * 255.0f);
t[2] = (Type)(z * 255.0f);
}
float power;
};
struct SNormalizeVector
{
typedef byte Type;
int components;
int format;
SNormalizeVector() : components(4), format(D3DFMT_X8R8G8B8) {}
void operator() (const Vec3d & v, Type * t)
{
Vec3d v2 = v;
v2 += Vec3d(1.0f,1.0f,1.0f);
t[2] = (Type)(v2[0] * 127.0f);
t[1] = (Type)(v2[1] * 127.0f);
t[0] = (Type)(v2[2] * 127.0f);
}
};
// make a cube map from a functor
template <class FunctionOfDirection> void MakeCubeMap(FunctionOfDirection & f, LPDIRECT3DCUBETEXTURE8 pCubeTexture, int size, bool bMips)
{
typedef typename FunctionOfDirection::Type Type;
int components = f.components;
int format = f.format;
Type * ip;
DWORD dwMipmaps = pCubeTexture->GetLevelCount();
int dwLevel = 0;
while (true)
{
float offset = .5;
float delta = 1;
float halfsize = size/2.f;
Vec3d v;
D3DLOCKED_RECT Locked;
D3DXVECTOR3 Normal;
D3DSURFACE_DESC ddsdDesc;
// positive x image
{
pCubeTexture->GetLevelDesc(dwLevel, &ddsdDesc);
pCubeTexture->LockRect((D3DCUBEMAP_FACES)0, dwLevel, &Locked, NULL, 0);
Type* pBits = (Type*)(Locked.pBits);
ip = pBits;
for(int j = 0; j < size; j++)
{
for(int i=0; i < size; i++)
{
v[2] = -(i*delta + offset - halfsize);
v[1] = -(j*delta + offset - halfsize);
v[0] = halfsize;
v.Normalize();
f(v, ip);
ip += components;
}
}
pCubeTexture->UnlockRect((D3DCUBEMAP_FACES)0, dwLevel);
}
// negative x image
{
pCubeTexture->GetLevelDesc(dwLevel, &ddsdDesc);
pCubeTexture->LockRect((D3DCUBEMAP_FACES)1, dwLevel, &Locked, NULL, 0);
Type* pBits = (Type*)(Locked.pBits);
ip = pBits;
for(int j = 0; j < size; j++)
{
for(int i=0; i < size; i++)
{
v[2] = (i*delta + offset - halfsize);
v[1] = -(j*delta + offset - halfsize);
v[0] = -halfsize;
v.Normalize();
f(v, ip);
ip += components;
}
}
pCubeTexture->UnlockRect((D3DCUBEMAP_FACES)1, dwLevel);
}
// positive y image
{
pCubeTexture->GetLevelDesc(dwLevel, &ddsdDesc);
pCubeTexture->LockRect((D3DCUBEMAP_FACES)2, dwLevel, &Locked, NULL, 0);
Type* pBits = (Type*)(Locked.pBits);
ip = pBits;
for(int j = 0; j < size; j++)
{
for(int i=0; i < size; i++)
{
v[0] = (i*delta + offset - halfsize);
v[2] = (j*delta + offset - halfsize);
v[1] = halfsize;
v.Normalize();
f(v, ip);
ip += components;
}
}
pCubeTexture->UnlockRect((D3DCUBEMAP_FACES)2, dwLevel);
}
// negative y image
{
pCubeTexture->GetLevelDesc(dwLevel, &ddsdDesc);
pCubeTexture->LockRect((D3DCUBEMAP_FACES)3, dwLevel, &Locked, NULL, 0);
Type* pBits = (Type*)(Locked.pBits);
ip = pBits;
for(int j = 0; j < size; j++)
{
for(int i=0; i < size; i++)
{
v[0] = (i*delta + offset - halfsize);
v[2] = -(j*delta + offset - halfsize);
v[1] = -halfsize;
v.Normalize();
f(v, ip);
ip += components;
}
}
pCubeTexture->UnlockRect((D3DCUBEMAP_FACES)3, dwLevel);
}
// positive z image
{
pCubeTexture->GetLevelDesc(dwLevel, &ddsdDesc);
pCubeTexture->LockRect((D3DCUBEMAP_FACES)4, dwLevel, &Locked, NULL, 0);
Type* pBits = (Type*)(Locked.pBits);
ip = pBits;
for(int j = 0; j < size; j++)
{
for(int i=0; i < size; i++)
{
v[0] = (i*delta + offset - halfsize);
v[1] = -(j*delta + offset - halfsize);
v[2] = halfsize;
v.Normalize();
f(v, ip);
ip += components;
}
}
pCubeTexture->UnlockRect((D3DCUBEMAP_FACES)4, dwLevel);
}
// negative z image
{
pCubeTexture->GetLevelDesc(dwLevel, &ddsdDesc);
pCubeTexture->LockRect((D3DCUBEMAP_FACES)5, dwLevel, &Locked, NULL, 0);
Type* pBits = (Type*)(Locked.pBits);
ip = pBits;
for(int j = 0; j < size; j++)
{
for(int i=0; i < size; i++)
{
v[0] = -(i*delta + offset - halfsize);
v[1] = -(j*delta + offset - halfsize);
v[2] = -halfsize;
v.Normalize();
f(v, ip);
ip += components;
}
}
pCubeTexture->UnlockRect((D3DCUBEMAP_FACES)5, dwLevel);
}
size >>= 1;
if (!bMips || !size)
break;
dwLevel++;
}
}
#endif

View File

@@ -0,0 +1,240 @@
#include "stdafx.h"
#include "DriverD3D8.h"
//=========================================================================================
#include "../CryFont/FBitmap.h"
bool CD3D8Renderer::FontUploadTexture(class CFBitmap* pBmp)
{
if(!pBmp)
return false;
char name[128];
sprintf(name, "$AutoDownload_%d", m_TexGenID++);
int flags = FT_NOMIPS | FT_HASALPHA | FT_NOREMOVE;
STexPic *tp = m_TexMan->CreateTexture(name, pBmp->GetWidth(), pBmp->GetHeight(), 1, flags, 0, (byte *)pBmp->GetData(), eTT_Base, -1.0f, -1.0f, 0, NULL, 0, eTF_8888);
pBmp->m_pIRenderData = (void*)tp;
return true;
}
void CD3D8Renderer::FontReleaseTexture(class CFBitmap *pBmp)
{
if(!pBmp)
return;
STexPic *tp = (STexPic *)pBmp->m_pIRenderData;
tp->Release(false);
}
void CD3D8Renderer::FontSetTexture(class CFBitmap* pBmp)
{
STexPic *tp = (STexPic *)pBmp->m_pIRenderData;
tp->Set();
EF_SetColorOp(eCO_MODULATE);
}
void CD3D8Renderer::FontSetRenderingState(unsigned long nVPWidth, unsigned long nVPHeight)
{
// setup various d3d things that we need
FontSetState(false);
D3DXMATRIX *m;
m_matProj->Push();
m_matProj->LoadIdentity();
m = m_matProj->GetTop();
D3DXMatrixOrthoOffCenterRH(m, 0.0f, (float)m_Viewport.Width, (float)m_Viewport.Height, 0.0f, -1.0f, 1.0f);
m_pd3dDevice->SetTransform(D3DTS_PROJECTION, m);
EF_PushMatrix();
m_matView->LoadIdentity();
m_pd3dDevice->SetTransform(D3DTS_VIEW, m_matView->GetTop());
}
// match table with the blending modes
static int nBlendMatchTable[] =
{
D3DBLEND_ZERO,
D3DBLEND_ONE,
D3DBLEND_SRCCOLOR,
D3DBLEND_INVSRCCOLOR,
D3DBLEND_SRCALPHA,
D3DBLEND_INVSRCALPHA,
D3DBLEND_DESTALPHA,
D3DBLEND_INVDESTALPHA,
D3DBLEND_DESTCOLOR,
D3DBLEND_INVDESTCOLOR,
};
void CD3D8Renderer::FontSetBlending(int blendSrc, int blendDest)
{
m_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, nBlendMatchTable[blendSrc]);
m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, nBlendMatchTable[blendDest]);
mCurState &= ~GS_BLEND_MASK;
mCurState |= GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA;
}
void CD3D8Renderer::FontRestoreRenderingState()
{
D3DXMATRIX *m;
m_matProj->Pop();
m = m_matProj->GetTop();
m_pd3dDevice->SetTransform(D3DTS_PROJECTION, m);
EF_PopMatrix();
FontSetState(true);
}
void CD3D8Renderer::FontSetState(bool bRestore)
{
static DWORD polyMode;
static D3DCOLORVALUE color;
static bool bMatColor;
static int State;
// grab the modes that we might need to change
if(!bRestore)
{
D3DSetCull(eCULL_None);
color = m_Material.Diffuse;
bMatColor = m_bMatColor;
State = mCurState;
polyMode = m_polygon_mode;
EF_SetVertColor();
if(polyMode == R_WIREFRAME_MODE)
m_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST | GS_ALPHATEST_GEQUAL128);
EF_SetColorOp(eCO_MODULATE);
}
else
{
if (m_bMatColor)
EF_SetGlobalColor(color.r,color.g,color.b,color.a);
if(polyMode == R_WIREFRAME_MODE)
m_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
SetState(State);
}
m_pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
m_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
}
void CD3D8Renderer::DrawString(int x, int y,bool bIgnoreColor, const char *message, ...)
{
CXFont *pFont = m_pCurFont;
float xscale = m_fXFontScale;
float yscale = m_fYFontScale;
if (!pFont)
{
if (iConsole && iConsole->GetFont())
pFont = iConsole->GetFont();
}
if (!pFont)
return;
float xsize = pFont->m_charsize*xscale*(float)(m_width)/800.0f;
float ysize = pFont->m_charsize*yscale*(float)(m_height)/600.0f;
va_list arglist;
char buf[1024];
va_start(arglist, message);
vsprintf(buf, message, arglist);
va_end(arglist);
FontSetRenderingState(m_width, m_height);
m_TexMan->SetTexture(pFont->m_image->GetTextureID(), eTT_Base);
float fX, fY, fBaseX;
fX = fBaseX = (float)x;
fY = (float)y;
bool bRGB = ((GetFeatures() & RFT_RGBA) != 0) ? true : false;
CFColor fCol = m_CurFontColor;
if (!bRGB)
COLCONV(fCol);
char *p = buf;
int nChar;
//glBegin(GL_QUADS);
while(*p)
{
nChar = *p;
if (nChar=='$')
{
if (*(p+1))
{
p++;
if ((*p)!='$')
{
char sColor[2];
sColor[0] =(*p);
sColor[1] = '\0';
int nColor = atoi(sColor);
if (nColor<0 || nColor>=FONTCOLORS)
nColor = 1;
if (!bIgnoreColor) // only change color for first pass !
{
fCol = m_FontColorTable[nColor];
if (!bRGB)
COLCONV(fCol);
}
nChar = 255;
}
}
}
if(nChar < 255)
{
if(nChar == '\n' || nChar == '\r')
{
fY += ysize;
fX = fBaseX;
}
else
if(nChar == '\t')
{
fX += xsize*4;
}
else
if (nChar > 32 && nChar < 256)
{
float xot = (float)(nChar & 15)*pFont->m_char_inc;
float yot = 1.f-(-(float)(*buf >> 4)*pFont->m_char_inc);
/*glColor4fv (&fCol[0]);
glTexCoord2f(xot, yot);
glVertex2f (fX, fY);
glColor4fv (&fCol[0]);
glTexCoord2f(xot+pFont->m_char_inc, yot);
glVertex2f (fX+xsize, fY);
glColor4fv (&fCol[0]);
glTexCoord2f(xot+pFont->m_char_inc, yot+pFont->m_char_inc);
glVertex2f (fX+xsize, fY+ysize);
glColor4fv (&fCol[0]);
glTexCoord2f(xot, yot+pFont->m_char_inc);
glVertex2f (fX, fY+ysize);*/
}
}
fX += xsize;
p++;
}
FontRestoreRenderingState();
}

View File

@@ -0,0 +1,590 @@
/*=============================================================================
D3DPShaders.cpp : pixel shaders support for D3D.
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
Revision history:
* Created by Khonich Andrey
=============================================================================*/
#include "stdafx.h"
#include "DriverD3D8.h"
#include "D3DCGPShader.h"
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
// init memory pool usage
#ifndef PS2
#ifndef _XBOX
_ACCESS_POOL;
#endif
#endif
TArray<CPShader *> CPShader::m_PShaders;
CPShader *CPShader::m_CurRC;
//=======================================================================
CPShader *CPShader::mfForName(char *name, bool bCGType)
{
int i;
for (i=0; i<m_PShaders.Num(); i++)
{
if (!m_PShaders[i])
continue;
if (!stricmp(name, m_PShaders[i]->m_Name.c_str()))
return m_PShaders[i];
}
char scrname[128];
char dir[128];
if (!bCGType)
{
sprintf(dir, "%sDeclarations/PShaders/", gcEf.m_HWPath);
sprintf(scrname, "%s%s.cryps", dir, name);
}
else
{
sprintf(dir, "%sDeclarations/CGPShaders/", gcEf.m_HWPath);
sprintf(scrname, "%s%s.crycg", dir, name);
}
FILE *fp = iSystem->GetIPak()->FOpen(scrname, "r");
if (!fp)
{
iLog->Log("WARNING: Couldn't find pixel shader '%s'", name);
iLog->Log("WARNING: Full file name: '%s'", scrname);
return NULL;
}
iSystem->GetIPak()->FSeek(fp, 0, SEEK_END);
int len = iSystem->GetIPak()->FTell(fp);
char *buf = new char [len+1];
iSystem->GetIPak()->FSeek(fp, 0, SEEK_SET);
len = iSystem->GetIPak()->FRead(buf, 1, len, fp);
iSystem->GetIPak()->FClose(fp);
buf[len] = 0;
buf = gcEf.mfScriptPreprocessor(buf, dir, scrname);
CPShader *p = NULL;
if (!bCGType)
{
CPShader_D3D *pr = new CPShader_D3D;
pr->m_Name = name;
pr->m_Id = i;
m_PShaders.AddElem(pr);
pr->m_RefCounter = 1;
p = pr;
}
else
{
CPShader *pr;
pr = new CCGPShader_D3D;
pr->m_Name = name;
pr->m_Id = i;
m_PShaders.AddElem(pr);
pr->m_RefCounter = 1;
p = pr;
}
HANDLE statussrc = CreateFile(scrname,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,NULL);
if (statussrc != INVALID_HANDLE_VALUE)
{
GetFileTime(statussrc,NULL,NULL,&p->m_WriteTime);
CloseHandle(statussrc);
}
p->mfCompile(buf);
delete [] buf;
return p;
}
//=============================================================================
void CPShader::mfClearAll(void)
{
for (int i=0; i<m_PShaders.Num(); i++)
{
CPShader *vp = m_PShaders[i];
if (vp)
delete vp;
}
m_PShaders.Free();
}
bool CPShader_D3D::mfCompile(char *scr)
{
char* name;
long cmd;
char *params;
char *data;
guard(CPShader_D3D::mfCompile);
enum {eScript=1, eParam};
static tokenDesc commands[] =
{
{eScript, "Script"},
{eParam, "Param"},
{0,0}
};
SShader *ef = gcEf.m_CurShader;
while ((cmd = shGetObject (&scr, commands, &name, &params)) > 0)
{
data = NULL;
if (name)
data = name;
else
if (params)
data = params;
switch (cmd)
{
case eScript:
{
if (!(gRenDev->GetFeatures() & RFT_HW_TS))
{
iLog->Log("Render device doesn't support texture shaders (Shader '%s')\n", ef->m_Name.c_str());
break;
}
int n = strlen(params);
m_pScript = new char[n+1];
memcpy(m_pScript, params, n);
m_pScript[n] = 0;
}
break;
case eParam:
gcEf.mfCompileParam(params, ef, &m_Params);
break;
}
}
unguard;
return 1;
}
void CPShader_D3D::mfDeleteParams(TArray<SParam> &Vars)
{
int i, j;
for (i=0; i<Vars.Num(); i++)
{
SParam *p = &Vars[i];
for (j=0; j<4; j++)
{
if (p->m_Comps[j])
{
delete p->m_Comps[j];
p->m_Comps[j] = NULL;
}
}
}
Vars.Free();
}
void CPShader_D3D::mfReset()
{
if (m_dwShader)
{
gcpRendD3D->mfGetD3DDevice()->DeletePixelShader(m_dwShader);
m_dwShader = 0;
}
m_bActive = false;
}
CPShader_D3D::~CPShader_D3D()
{
mfDeleteParams(m_Params);
SAFE_DELETE (m_pScript);
mfReset();
}
void CPShader_D3D::mfSetFloat4f(int reg, float *v)
{
HRESULT hr = gcpRendD3D->mfGetD3DDevice()->SetPixelShaderConstant(reg, v, 1);
}
#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1
void CPShader_D3D::mfSetParams(TArray<SParam>& Vars, TArray<SParam>* AddParams)
{
int i;
HRESULT hr = 0;
for (i=0; i<Vars.Num(); i++)
{
SParam *p = &Vars[i];
float *v = p->mfGet();
if (p->m_Reg != GL_OFFSET_TEXTURE_2D_MATRIX_NV)
hr = gcpRendD3D->mfGetD3DDevice()->SetPixelShaderConstant(p->m_Reg, v, 1);
else
{
//v[0] = v[3] = 0;
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVMAT00, FLOATtoDWORD(v[0]));
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVMAT01, FLOATtoDWORD(v[1]));
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVMAT10, FLOATtoDWORD(v[2]));
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVMAT11, FLOATtoDWORD(v[3]));
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVLSCALE, FLOATtoDWORD(4.0f));
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVLOFFSET, FLOATtoDWORD(0.0f));
}
if (FAILED(hr))
return;
}
if (AddParams)
{
for (i=0; i<AddParams->Num(); i++)
{
SParam *p = &AddParams->Get(i);
float *v = p->mfGet();
if (p->m_Reg != GL_OFFSET_TEXTURE_2D_MATRIX_NV)
hr = gcpRendD3D->mfGetD3DDevice()->SetPixelShaderConstant(p->m_Reg, v, 1);
else
{
//v[0] = v[3] = 0;
v[0] *= CRenderer::CV_r_embm;
v[3] *= CRenderer::CV_r_embm;
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVMAT00, FLOATtoDWORD(v[0]));
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVMAT01, FLOATtoDWORD(v[1]));
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVMAT10, FLOATtoDWORD(v[2]));
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVMAT11, FLOATtoDWORD(v[3]));
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVLSCALE, FLOATtoDWORD(4.0f));
gcpRendD3D->mfGetD3DDevice()->SetTextureStageState(1, D3DTSS_BUMPENVLOFFSET, FLOATtoDWORD(0.0f));
}
if (FAILED(hr))
return;
}
}
}
bool CPShader_D3D::mfBind()
{
HRESULT hr;
if (!m_bActive)
mfActivate();
hr = gcpRendD3D->mfGetD3DDevice()->SetPixelShader( m_dwShader );
if (FAILED(hr))
return false;
return true;
}
bool CPShader_D3D::mfUnbind()
{
HRESULT hr;
hr = gcpRendD3D->mfGetD3DDevice()->SetPixelShader( NULL );
if (FAILED(hr))
return false;
return true;
}
#ifdef _XBOX
char * PSToXboxPS(const char * pInp)
{
size_t len = strlen(pInp);
char * p, *tmp;
char * pRet = p = new char[len+256];
const char * pFind = "_sat";
int lenFind = 4;
int nChar = 0;
int state = 0;
char cReg[16];
int iReg=0;
int AfterCom = 0;
bool bIsAlphaString = false;
int ChanelReg = 0;
while(*p++ = *pInp++)
{
if(*(pInp) != 0 && *(pInp) == 'p' && *(pInp+1) == 's')
*p++ = 'x';
}
for(p = pRet; *p; p++)
{
if(*p == '\n')
{
AfterCom = 0;
bIsAlphaString = false;
}
if(!AfterCom && *p == ',')
AfterCom = 1;
if(!AfterCom && *p == '.' && (*(p+1) == 'a') || (*(p+1) == 'A'))
bIsAlphaString = true;
if(state != 3 && state != 4)
{
if(state==0 && !AfterCom && pFind[nChar] == *p)
{
nChar++;
if(nChar >= lenFind)
{
for(int i = 1; *(p+i-1); i++)
*(p-lenFind+i) = *(p+i);
p -= lenFind;
nChar = 0;
state = 1;
}
}
else
{
nChar = 0;
if(state == 1)
{
if (*p != ' ' && *p != '\t')
state = 2;
}
if(state == 2)
{
if (*p != ' ' && *p != '\t' && *p != ',')
cReg[iReg++] = *p;
else
{
cReg[iReg] = 0;
char * ch = strchr(cReg, '.');
ChanelReg = 0;
if(ch)
{
if( *(ch+1) == 'a' || *(ch+1) == 'A')
ChanelReg = 2;
*ch = 0;
iReg = int(ch - cReg);
}
state = 3;
tmp = p;
AfterCom = 2;
}
}
}
}
else // if(state == 3 || state == 4)
{
if(AfterCom == 1 && cReg[nChar] == *p)
{
nChar++;
if(nChar >= iReg)
{
bool bSet = false;
if(!bIsAlphaString)
{
if(ChanelReg ==2)
{
}
else
if(*(p+1)=='.' && *(p+2)=='a')
{
}
else
bSet=true;
}
else // if(bIsAlphaString)
{
if(ChanelReg == 0)
{
if(*(p+1)=='.' && *(p+2)!='a')
{
bSet = true;
}
}
if(ChanelReg ==2)
{
bSet = true;
if(*(p+1)=='.' && *(p+2)!='a')
{
bSet = false;
}
}
}
if(bSet)
{
char * vp = strchr(p,0);
while (vp != p)
*(vp + lenFind) = *vp--;
p++;
for(int i=0; i<=lenFind-1; i++)
*p++ = pFind[i];
nChar = 0;
//iReg = 0;
state = 4;
//p = tmp-1;
}
}
}
else
nChar = 0;
if(*(p+1)==0 || (state==4 && (*(p+1)=='\n') ))
{
nChar = 0;
iReg = 0;
state = 0;
p = tmp-1;
}
}
}
strcpy(p-1, "\nxfc fog.a,r0,fog.rgb,zero,zero,zero,r0.a\n");
return pRet;
}
#endif //_XBOX
bool CPShader_D3D::mfActivate()
{
HRESULT hr;
if (m_bActive)
return true;
#ifdef _XBOX
LPXGBUFFER pCode;
LPXGBUFFER pBuffer = NULL;
if (!m_pScript)
return false;
m_bActive = 1;
#ifndef _XBOX
hr = XGAssembleShader(m_Name.c_str(), m_pScript, strlen(m_pScript), 0, NULL, &pCode, &pBuffer, NULL, NULL, NULL, 0);
#else //_XBOX
char * pScriptTmp = PSToXboxPS(m_pScript);
hr = XGAssembleShader(m_Name.c_str(), pScriptTmp, strlen(pScriptTmp), 0, NULL, &pCode, &pBuffer, NULL, NULL, NULL, 0);
delete [] pScriptTmp;
#endif ///_XBOX
if (FAILED(hr))
{
iLog->Log("CPShader_D3D::mfActivate: Couldn't assemble pixel shader '%s' (%s)\n", m_Name.c_str(), gcpRendD3D->D3DError(hr));
if( pBuffer != NULL)
{
TCHAR* pstr;
TCHAR strOut[4096];
TCHAR* pstrOut;
// Need to replace \n with \r\n so edit box shows newlines properly
pstr = (TCHAR*)pBuffer->GetBufferPointer();
strOut[0] = '\0';
pstrOut = strOut;
for( int i = 0; i < 4096; i++ )
{
if( *pstr == '\n' )
*pstrOut++ = '\r';
*pstrOut = *pstr;
if( *pstr == '\0' )
break;
if( i == 4095 )
*pstrOut = '\0';
pstrOut++;
pstr++;
}
// remove any blank lines at the end
while( strOut[lstrlen(strOut) - 1] == '\n' || strOut[lstrlen(strOut) - 1] == '\r' )
{
strOut[lstrlen(strOut) - 1] = '\0';
}
iLog->Log("ERROR: CPShader_D3D::mfActivate: Shader '%s' script error (%s)\n", strOut, m_Name.c_str());
SAFE_RELEASE( pBuffer );
}
return false;
}
// Create the pixel shader
if( FAILED( hr = gcpRendD3D->mfGetD3DDevice()->CreatePixelShader((D3DPIXELSHADERDEF *)pCode->GetBufferPointer(), &m_dwShader)))
{
iLog->Log("ERROR: CPShader_D3D::mfActivate: Couldn't create pixel shader '%s'\n", m_Name.c_str());
return false;
}
#else
LPD3DXBUFFER pCode;
LPD3DXBUFFER pBuffer = NULL;
if (!m_pScript)
return false;
m_bActive = 1;
// Assemble script (.nvp) and create shader
hr = D3DXAssembleShader( m_pScript, strlen(m_pScript), 0, NULL, &pCode, &pBuffer );
if (FAILED(hr))
{
iLog->Log("ERROR: CPShader_D3D::mfActivate: Couldn't assemble pixel shader '%s'\n", m_Name.c_str());
if( pBuffer != NULL)
{
TCHAR* pstr;
TCHAR strOut[4096];
TCHAR* pstrOut;
// Need to replace \n with \r\n so edit box shows newlines properly
pstr = (TCHAR*)pBuffer->GetBufferPointer();
strOut[0] = '\0';
pstrOut = strOut;
for( int i = 0; i < 4096; i++ )
{
if( *pstr == '\n' )
*pstrOut++ = '\r';
*pstrOut = *pstr;
if( *pstr == '\0' )
break;
if( i == 4095 )
*pstrOut = '\0';
pstrOut++;
pstr++;
}
// remove any blank lines at the end
while( strOut[lstrlen(strOut) - 1] == '\n' || strOut[lstrlen(strOut) - 1] == '\r' )
{
strOut[lstrlen(strOut) - 1] = '\0';
}
iLog->Log("ERROR: CPShader_D3D::mfActivate: Pixel shader '%s' script error (%s)\n", m_Name.c_str(), strOut);
SAFE_RELEASE( pBuffer );
}
return false;
}
// Create the pixel shader
hr = gcpRendD3D->mfGetD3DDevice()->CreatePixelShader( (DWORD*)pCode->GetBufferPointer(), &m_dwShader );
if (FAILED(hr))
{
iLog->Log("ERROR: CPShader_D3D::mfActivate: Couldn't create pixel shader '%s'\n", m_Name.c_str());
return false;
}
#endif
return true;
}
bool CPShader_D3D::mfSet(bool bStat, SShaderPassHW *slw)
{
if (!m_bActive)
{
if (!mfActivate())
return false;
}
if (!bStat)
{
if (CRenderer::CV_r_log >= 3)
gRenDev->Logv(SRendItem::m_RecurseLevel, "--- Reset PShader \"%s\"\n", m_Name.c_str());
mfUnbind();
}
else
{
if (CRenderer::CV_r_log >= 3)
gRenDev->Logv(SRendItem::m_RecurseLevel, "--- Set PShader \"%s\"\n", m_Name.c_str());
mfBind();
if (slw)
mfSetParams(m_Params, slw->m_RCParamsNoObj);
else
mfSetParams(m_Params, NULL);
}
return true;
}

View File

@@ -0,0 +1,58 @@
/*=============================================================================
D3DPShaders.h : Direct3D pixel shaders interface declaration.
Copyright 1999 K&M. All Rights Reserved.
Revision history:
* Created by Honitch Andrey
=============================================================================*/
#ifndef __D3DPSHADERS_H__
#define __D3DPSHADERS_H__
class CPShader_D3D : public CPShader
{
uint m_Flags;
bool m_bWasLoaded;
char *m_pScript;
int m_dwCodeSize;
DWORD m_dwShader;
TArray<SParam> m_Params;
bool mfBind();
bool mfUnbind();
void mfSetParams(TArray<SParam>& Params, TArray<SParam>* AddParams);
void mfSetParam(SParam *p);
void mfDeleteParams(TArray<SParam> &Vars);
bool mfActivate();
public:
static void mfSetFloat4f(int reg, float *p);
virtual int Size()
{
return 0;
}
CPShader_D3D() : CPShader()
{
m_bCGType = false;
m_Flags = 0;
m_dwShader = 0;
m_bWasLoaded = false;
m_pScript = NULL;
}
virtual ~CPShader_D3D();
virtual bool mfCompile(char *scr);
virtual bool mfSet(bool bStat, SShaderPassHW *slw=NULL);
virtual bool mfIsCombiner() { return false; }
virtual void mfReset();
virtual void mfEnable() {}
virtual void mfDisable() {}
};
#endif // __D3DPSHADERS_H__

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
/*=============================================================================
D3DShadows.cpp : shadows support.
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
Revision history:
* Created by Honich Andrey
=============================================================================*/
#include "stdafx.h"
#include "DriverD3D8.h"
#include "../Common/Shadow_Renderer.h"
// draw grid and project depth map on it
/*void CD3D8Renderer::DrawShadowGrid(const Vec3d & pos, const Vec3d & Scale, ShadowMapFrustum*lf, bool translate_projection, float alpha, IndexedVertexBuffer* pVertexBuffer, float anim_angle)
{
} */
void CD3D8Renderer::SetupShadowOnlyPass(int Num, ShadowMapFrustum * pFrustum, Vec3d * vShadowTrans, const float fShadowScale, Vec3d vObjTrans, float fObjScale, const Vec3d vObjAngles, Matrix44 * pObjMat)
{
}
// Make 8-bit identity texture that maps (s)=(z) to [0,255]/255.
int CD3D8Renderer::MakeShadowIdentityTexture()
{
return 0;
}
// setup projection texgen
void CD3D8Renderer::ConfigShadowTexgen(int Num, int rangeMap, ShadowMapFrustum * pFrustum, float * pLightFrustumMatrix, float * pLightViewMatrix)
{
}

View File

@@ -0,0 +1,826 @@
#ifndef __D3DTEXTURE_H
#define __D3DTEXTURE_H
class D3DDataFormat
{
public:
virtual void GetData(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, DWORD& dwValue) { assert(0); };
virtual void SetData(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, DWORD dwValue) { assert(0); };
virtual void GetColors(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, float& fRed, float& fGreen, float& fBlue, float& fAlpha) { assert(0); };
virtual void SetColors(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, float fRed, float fGreen, float fBlue, float fAlpha) { assert(0); };
virtual void GetLuminance(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, float& Luminance) { assert(0); };
virtual void SetLuminance(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, float Luminance) { assert(0); };
virtual void GetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, D3DXVECTOR3& inVector) { assert(0); };
virtual void SetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, const D3DXVECTOR3& inVector) { assert(0); };
};
class D3DDataFormat_32Bit : public D3DDataFormat
{
public:
virtual void GetData(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, DWORD& dwValue)
{
dwValue = (*(DWORD*) (((BYTE*)LockData.pBits) + (j * LockData.Pitch) + (i * sizeof(DWORD))) );
}
virtual void SetData(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, DWORD dwValue)
{
*(DWORD*)(((BYTE*)LockData.pBits) + (j * LockData.Pitch) + (i * sizeof(DWORD))) = dwValue;
}
};
class D3DDataFormat_16Bit : public D3DDataFormat
{
public:
virtual void GetData(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, DWORD& dwValue)
{
dwValue = ((DWORD)*(WORD*)(((BYTE*)LockData.pBits) + (j * LockData.Pitch) + (i * sizeof(WORD))) );
}
virtual void SetData(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, DWORD dwValue)
{
*(WORD*)(((BYTE*)LockData.pBits) + (j * LockData.Pitch) + (i * sizeof(WORD))) = (WORD)dwValue;
}
};
class D3DDataFormat_8Bit : public D3DDataFormat
{
public:
virtual void GetData(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, DWORD& dwValue)
{
dwValue = ((DWORD)*(BYTE*)(((BYTE*)LockData.pBits) + (j * LockData.Pitch) + (i * sizeof(BYTE))) );
}
virtual void SetData(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, DWORD dwValue)
{
*(BYTE*)(((BYTE*)LockData.pBits) + (j * LockData.Pitch) + (i * sizeof(WORD))) = (BYTE)dwValue;
}
};
class D3DDataFormat_A8R8G8B8 : public D3DDataFormat_32Bit
{
public:
virtual void GetColors(const D3DLOCKED_RECT& LockData, float& fRed, float& fGreen, float& fBlue, float& fAlpha, DWORD i, DWORD j)
{
DWORD dwValue;
GetData(LockData, i, j, dwValue);
fBlue = ((float)(dwValue & 0xFF))/ 255.0f;
fGreen = ((float)((dwValue >> 8) & 0xFF)) / 255.0f;
fRed = ((float)((dwValue >> 16) & 0xFF)) / 255.0f;
fAlpha = ((float)((dwValue >> 24) & 0xFF)) / 255.0f;
}
virtual void GetLuminance(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, float& Luminance)
{
float fRed, fGreen, fBlue, fAlpha;
GetColors(LockData, fRed, fGreen, fBlue, fAlpha, i, j);
Luminance = ((fRed * 0.3f) + (fGreen * 0.59f) + (fBlue * 0.11f));
}
virtual void SetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, const D3DXVECTOR3& inVector)
{
D3DXVECTOR3 vecScaled = (inVector + D3DXVECTOR3(1.0f, 1.0f, 1.0f)) * 127.5f;
BYTE red = (BYTE)vecScaled.x;
BYTE green = (BYTE)vecScaled.y;
BYTE blue = (BYTE)vecScaled.z;
BYTE alpha = 0xFF;
DWORD dwData = (DWORD)( ( (DWORD)alpha << 24 ) | ( (DWORD)red << 16 ) | ( (DWORD)green << 8 ) | ( (DWORD)blue << 0) );
SetData(LockData, i, j, dwData);
}
virtual void GetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, D3DXVECTOR3& outVector)
{
DWORD dwData;
GetData(LockData, i, j, dwData);
outVector.x = (float)((dwData >> 16) & 0xFF);
outVector.y = (float)((dwData >> 8) & 0xFF);
outVector.z = (float)((dwData) & 0xFF);
outVector /= 127.5f;
outVector -= D3DXVECTOR3(1.0f, 1.0f, 1.0f);
}
};
class D3DDataFormat_X8R8G8B8 : public D3DDataFormat_32Bit
{
public:
virtual void GetColors(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, float& fRed, float& fGreen, float& fBlue, float& fAlpha)
{
DWORD dwValue;
GetData(LockData, i, j, dwValue);
fBlue = ((float)(dwValue & 0xFF))/ 255.0f;
fGreen = ((float)((dwValue >> 8) & 0xFF)) / 255.0f;
fRed = ((float)((dwValue >> 16) & 0xFF)) / 255.0f;
fAlpha = 1.0f;
}
virtual void GetLuminance(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, float& Luminance)
{
float fRed, fGreen, fBlue, fAlpha;
GetColors(LockData, i, j, fRed, fGreen, fBlue, fAlpha);
Luminance = ((fRed * 0.3f) + (fGreen * 0.59f) + (fBlue * 0.11f));
}
virtual void SetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, const D3DXVECTOR3& inVector)
{
D3DXVECTOR3 vecScaled = (inVector + D3DXVECTOR3(1.0f, 1.0f, 1.0f)) * 127.5f;
BYTE red = (BYTE)vecScaled.x;
BYTE green = (BYTE)vecScaled.y;
BYTE blue = (BYTE)vecScaled.z;
BYTE alpha = 0xFF;
DWORD dwData = (DWORD)( ( (DWORD)alpha << 24 ) | ( (DWORD)red << 16 ) | ( (DWORD)green << 8 ) | ( (DWORD)blue << 0) );
SetData(LockData, i, j, dwData);
}
virtual void GetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, D3DXVECTOR3& outVector)
{
DWORD dwData;
GetData(LockData, i, j, dwData);
outVector.x = (float)((dwData >> 16) & 0xFF);
outVector.y = (float)((dwData >> 8) & 0xFF);
outVector.z = (float)((dwData) & 0xFF);
outVector /= 127.5f;
outVector -= D3DXVECTOR3(1.0f, 1.0f, 1.0f);
}
};
class D3DDataFormat_Q8W8V8U8 : public D3DDataFormat_32Bit
{
virtual void SetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, const D3DXVECTOR3& inVector)
{
D3DXVECTOR3 vecScaled = inVector * 127.5f;
signed char red = (signed char)vecScaled.x;
signed char green = (signed char)vecScaled.y;
signed char blue = (signed char)vecScaled.z;
signed char alpha = 0;
DWORD dwData = (DWORD)( ( (DWORD)(unsigned char)alpha << 24 ) | ( (DWORD)(unsigned char)blue << 16 ) | ( (DWORD)(unsigned char)green << 8 ) | ( (DWORD)(unsigned char)red << 0) );
SetData(LockData, i, j, dwData);
}
virtual void GetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, D3DXVECTOR3& outVector)
{
DWORD dwData;
GetData(LockData, i, j, dwData);
outVector.x = (float)(signed char)((dwData) & 0xFF);
outVector.y = (float)(signed char)((dwData >> 8) & 0xFF);
outVector.z = (float)(signed char)((dwData >> 16) & 0xFF);
outVector /= 127.5f;
}
};
class D3DDataFormat_X8L8V8U8 : public D3DDataFormat_32Bit
{
virtual void SetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, const D3DXVECTOR3& inVector)
{
D3DXVECTOR3 vecScaled = inVector * 127.5f;
signed char red = (signed char)vecScaled.x;
signed char green = (signed char)vecScaled.y;
signed char blue = (signed char)vecScaled.z;
signed char alpha = 0;
DWORD dwData = (DWORD)( ( (DWORD)(unsigned char)alpha << 24 ) | ( (DWORD)(unsigned char)blue << 16 ) | ( (DWORD)(unsigned char)green << 8 ) | ( (DWORD)(unsigned char)red << 0) );
SetData(LockData, i, j, dwData);
}
virtual void GetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, D3DXVECTOR3& outVector)
{
DWORD dwData;
GetData(LockData, i, j, dwData);
outVector.x = (float)(signed char)((dwData) & 0xFF);
outVector.y = (float)(signed char)((dwData >> 8) & 0xFF);
outVector.z = (float)(signed char)((dwData >> 16) & 0xFF);
outVector /= 127.5f;
}
};
class D3DDataFormat_D3DHS : public D3DDataFormat_32Bit
{
virtual void SetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, const D3DXVECTOR3& inVector)
{
D3DXVECTOR3 vecScaled = inVector * 32767.0f;
signed short h = (signed short)vecScaled.x;
signed short l = (signed short)vecScaled.y;
DWORD dwData = ( ( (DWORD)(unsigned short)h << 16 ) | ( (DWORD)(unsigned short)l << 0 ) );
SetData(LockData, i, j, dwData);
}
virtual void GetVector(const D3DLOCKED_RECT& LockData, DWORD i, DWORD j, D3DXVECTOR3& outVector)
{
DWORD dwData;
GetData(LockData, i, j, dwData);
outVector.x = (float)(unsigned short)((dwData >> 16) & 0xFFFF);
outVector.y = (float)(unsigned short)((dwData) & 0xFFFF);
outVector.z = 1.0f;
outVector /= 32767.0f;
}
};
class D3D2DTextureLocker
{
public:
enum
{
MAX_LOCK_LEVELS = 12
};
D3D2DTextureLocker(LPDIRECT3DTEXTURE8 pTexture)
: m_pTexture(pTexture),
m_pDataFormat(NULL)
{
m_pTexture->AddRef();
for (DWORD i=0; i < MAX_LOCK_LEVELS; i++)
{
m_bLocked[i] = false;
}
m_dwLevels = m_pTexture->GetLevelCount();
D3DSURFACE_DESC LevelDesc;
m_pTexture->GetLevelDesc(0, &LevelDesc);
switch(LevelDesc.Format)
{
case D3DFMT_UNKNOWN:
case D3DFMT_VERTEXDATA:
case D3DFMT_INDEX16:
#ifndef _XBOX
case D3DFMT_INDEX32:
#endif
case D3DFMT_DXT1:
case D3DFMT_DXT2:
#ifndef _XBOX
case D3DFMT_DXT3:
#endif
case D3DFMT_DXT4:
#ifndef _XBOX
case D3DFMT_DXT5:
default:
assert(!"Don't understand surface format");
break;
case D3DFMT_R8G8B8:
assert(!"Don't handle 24 bit surfaces");
break;
case D3DFMT_X8L8V8U8:
m_pDataFormat = new D3DDataFormat_X8L8V8U8;
break;
#endif
case D3DFMT_A8R8G8B8:
m_pDataFormat = new D3DDataFormat_A8R8G8B8;
break;
case D3DFMT_X8R8G8B8:
m_pDataFormat = new D3DDataFormat_X8R8G8B8;
break;
case D3DFMT_Q8W8V8U8:
m_pDataFormat = new D3DDataFormat_Q8W8V8U8;
break;
case MAKEFOURCC('N', 'V', 'H', 'S'):
m_pDataFormat = new D3DDataFormat_D3DHS;
break;
}
assert(m_pDataFormat);
}
virtual ~D3D2DTextureLocker()
{
for (DWORD i = 0; i < MAX_LOCK_LEVELS; i++)
{
if (m_bLocked[i])
{
Unlock(i);
}
}
SAFE_RELEASE(m_pTexture);
SAFE_DELETE(m_pDataFormat);
}
bool Lock(DWORD dwLevel)
{
HRESULT hr;
assert(dwLevel < m_dwLevels);
assert(!m_bLocked[dwLevel]);
m_bLocked[dwLevel] = true;
hr = m_pTexture->LockRect(dwLevel, &m_LockData[dwLevel], NULL, 0);
m_pTexture->GetLevelDesc(dwLevel, &m_LevelDesc[dwLevel]);
if (FAILED(hr))
return false;
return true;
}
bool Unlock(DWORD dwLevel)
{
HRESULT hr;
assert(dwLevel < m_dwLevels);
assert(m_bLocked[dwLevel]);
m_bLocked[dwLevel] = false;
hr = m_pTexture->UnlockRect(dwLevel);
if (FAILED(hr))
return false;
return true;
}
void WrapAddress(DWORD dwLevel, DWORD& i, DWORD& j)
{
if (i >= 0)
{
i = (i % m_LevelDesc[dwLevel].Width);
}
else
{
i = (m_LevelDesc[dwLevel].Width - 1) + (i % m_LevelDesc[dwLevel].Width);
}
if (j >= 0)
{
j = (j % m_LevelDesc[dwLevel].Height);
}
else
{
j = (m_LevelDesc[dwLevel].Height - 1) + (j % m_LevelDesc[dwLevel].Height);
}
assert(i >= 0);
assert(j >= 0);
assert(i < m_LevelDesc[dwLevel].Width);
assert(j < m_LevelDesc[dwLevel].Height);
}
void GetMapData(DWORD dwLevel, DWORD i, DWORD j, DWORD& dwValue)
{
assert(m_bLocked[dwLevel]);
WrapAddress(dwLevel, i, j);
m_pDataFormat->GetData(m_LockData[dwLevel], i, j, dwValue);
}
void SetMapData(DWORD dwLevel, DWORD i, DWORD j, DWORD dwValue)
{
assert(m_bLocked[dwLevel]);
WrapAddress(dwLevel, i, j);
m_pDataFormat->SetData(m_LockData[dwLevel], i, j, dwValue);
}
void GetMapColors(DWORD dwLevel, DWORD i, DWORD j, float& fRed, float& fGreen, float& fBlue, float& fAlpha)
{
assert(m_bLocked[dwLevel]);
WrapAddress(dwLevel, i, j);
m_pDataFormat->GetColors(m_LockData[dwLevel], i, j, fRed, fGreen, fBlue, fAlpha);
}
void GetMapLuminance(DWORD dwLevel, DWORD i, DWORD j, float& Luminance)
{
assert(m_bLocked[dwLevel]);
WrapAddress(dwLevel, i, j);
m_pDataFormat->GetLuminance(m_LockData[dwLevel], i, j, Luminance);
}
void SetMapVector(DWORD dwLevel, DWORD i, DWORD j, const D3DXVECTOR3& inVector)
{
assert(m_bLocked[dwLevel]);
WrapAddress(dwLevel, i, j);
m_pDataFormat->SetVector(m_LockData[dwLevel], i, j, inVector);
}
void GetMapVector(DWORD dwLevel, DWORD i, DWORD j, D3DXVECTOR3& inVector)
{
assert(m_bLocked[dwLevel]);
WrapAddress(dwLevel, i, j);
m_pDataFormat->GetVector(m_LockData[dwLevel], i, j, inVector);
}
private:
D3DDataFormat* m_pDataFormat;
DWORD m_dwLevels;
bool m_bLocked[MAX_LOCK_LEVELS];
D3DLOCKED_RECT m_LockData[MAX_LOCK_LEVELS];
D3DSURFACE_DESC m_LevelDesc[MAX_LOCK_LEVELS];
LPDIRECT3DTEXTURE8 m_pTexture;
};
class D3D2DSurfaceLocker
{
public:
D3D2DSurfaceLocker(LPDIRECT3DSURFACE8 pSurface)
: m_pSurface(pSurface),
m_pDataFormat(NULL)
{
m_pSurface->AddRef();
m_bLocked = false;
m_pSurface->GetDesc(&m_LevelDesc);
switch(m_LevelDesc.Format)
{
case D3DFMT_UNKNOWN:
case D3DFMT_VERTEXDATA:
case D3DFMT_INDEX16:
#ifndef _XBOX
case D3DFMT_INDEX32:
#endif
#ifndef _XBOX
case D3DFMT_DXT1:
case D3DFMT_DXT2:
case D3DFMT_DXT3:
case D3DFMT_DXT4:
case D3DFMT_DXT5:
default:
assert(!"Don't understand surface format");
break;
case D3DFMT_R8G8B8:
assert(!"Don't handle 24 bit surfaces");
break;
case D3DFMT_X8L8V8U8:
m_pDataFormat = new D3DDataFormat_X8L8V8U8;
break;
#endif
case D3DFMT_A8R8G8B8:
m_pDataFormat = new D3DDataFormat_A8R8G8B8;
break;
case D3DFMT_X8R8G8B8:
m_pDataFormat = new D3DDataFormat_X8R8G8B8;
break;
case D3DFMT_Q8W8V8U8:
m_pDataFormat = new D3DDataFormat_Q8W8V8U8;
break;
case MAKEFOURCC('N', 'V', 'H', 'S'):
m_pDataFormat = new D3DDataFormat_D3DHS;
break;
}
assert(m_pDataFormat);
}
virtual ~D3D2DSurfaceLocker()
{
if (m_bLocked)
{
Unlock();
}
SAFE_RELEASE(m_pSurface);
SAFE_DELETE(m_pDataFormat);
}
bool Lock()
{
HRESULT hr;
assert(!m_bLocked);
m_bLocked = true;
hr = m_pSurface->LockRect(&m_LockData, NULL, 0);
if (FAILED(hr))
return false;
return true;
}
bool Unlock()
{
HRESULT hr;
assert(m_bLocked);
m_bLocked = false;
hr = m_pSurface->UnlockRect();
if (FAILED(hr))
return false;
return true;
}
void WrapAddress(DWORD& i, DWORD& j)
{
if (i >= 0)
{
i = (i % m_LevelDesc.Width);
}
else
{
i = (m_LevelDesc.Width - 1) + (i % m_LevelDesc.Width);
}
if (j >= 0)
{
j = (j % m_LevelDesc.Height);
}
else
{
j = (m_LevelDesc.Height - 1) + (j % m_LevelDesc.Height);
}
assert(i >= 0);
assert(j >= 0);
assert(i < m_LevelDesc.Width);
assert(j < m_LevelDesc.Height);
}
void GetMapData(DWORD i, DWORD j, DWORD& dwValue)
{
assert(m_bLocked);
WrapAddress(i, j);
m_pDataFormat->GetData(m_LockData, i, j, dwValue);
}
void SetMapData(DWORD i, DWORD j, DWORD dwValue)
{
assert(m_bLocked);
WrapAddress(i, j);
m_pDataFormat->SetData(m_LockData, i, j, dwValue);
}
void GetMapColors(DWORD i, DWORD j, float& fRed, float& fGreen, float& fBlue, float& fAlpha)
{
assert(m_bLocked);
WrapAddress(i, j);
m_pDataFormat->GetColors(m_LockData, i, j, fRed, fGreen, fBlue, fAlpha);
}
void GetMapLuminance(DWORD i, DWORD j, float& Luminance)
{
assert(m_bLocked);
WrapAddress(i, j);
m_pDataFormat->GetLuminance(m_LockData, i, j, Luminance);
}
void SetMapVector(DWORD i, DWORD j, const D3DXVECTOR3& inVector)
{
assert(m_bLocked);
WrapAddress(i, j);
m_pDataFormat->SetVector(m_LockData, i, j, inVector);
}
void GetMapVector(DWORD i, DWORD j, D3DXVECTOR3& inVector)
{
assert(m_bLocked);
WrapAddress(i, j);
m_pDataFormat->GetVector(m_LockData, i, j, inVector);
}
private:
D3DDataFormat* m_pDataFormat;
bool m_bLocked;
D3DSURFACE_DESC m_LevelDesc;
D3DLOCKED_RECT m_LockData;
LPDIRECT3DSURFACE8 m_pSurface;
};
class CD3DTexture
{
public:
// Gets height from luminance value
static LPDIRECT3DTEXTURE8 CreateNormalMap(LPDIRECT3DDEVICE8 pD3DDev, LPDIRECT3DTEXTURE8 pSource, STexPic *ti, bool bMips, D3DXVECTOR3 Scale, D3DFORMAT Format = D3DFMT_Q8W8V8U8, D3DPOOL Pool = D3DPOOL_MANAGED)
{
LPDIRECT3DTEXTURE8 pNormalMap = NULL;
D3DSURFACE_DESC ddsdDescDest;
D3DSURFACE_DESC ddsdDescSource;
D3DXVECTOR3 Normal;
HRESULT hr;
DWORD i, j;
LPDIRECT3DTEXTURE8 pNewTex = NULL;
assert(pSource && pSource->GetType() == D3DRTYPE_TEXTURE);
if (!pSource)
return NULL;
(pSource)->GetLevelDesc(0, &ddsdDescSource);
// Handle conversion from compressed to specified format
switch(ddsdDescSource.Format)
{
default:
break;
case D3DFMT_DXT1:
case D3DFMT_DXT3:
case D3DFMT_DXT5:
{
hr = D3DXCreateTexture(pD3DDev, ddsdDescSource.Width, ddsdDescSource.Height, bMips ? D3DX_DEFAULT : 1, 0, Format, D3DPOOL_SYSTEMMEM, &pNewTex);
if (FAILED(hr))
return NULL;
// Copy the levels to RGB textures
for (i = 0; i < 1; i++)
{
LPDIRECT3DSURFACE8 pDestSurf;
LPDIRECT3DSURFACE8 pSourceSurf;
pNewTex->GetSurfaceLevel(i, &pDestSurf);
pSource->GetSurfaceLevel(i, &pSourceSurf);
D3DXLoadSurfaceFromSurface(pDestSurf, NULL, NULL, pSourceSurf, NULL, NULL, D3DX_FILTER_NONE, 0);
SAFE_RELEASE(pDestSurf);
SAFE_RELEASE(pSourceSurf);
}
pSource = pNewTex;
}
break;
}
hr = D3DXCreateTexture(pD3DDev, ddsdDescSource.Width, ddsdDescSource.Height, bMips ? D3DX_DEFAULT : 1, 0, Format, Pool, &pNormalMap );
if (FAILED(hr))
{
SAFE_RELEASE(pNewTex);
return NULL;
}
D3D2DTextureLocker SourceLocker(pSource);
D3D2DTextureLocker DestLocker(pNormalMap);
for (DWORD Level = 0; Level < 1; Level++)
{
pNormalMap->GetLevelDesc(Level, &ddsdDescDest);
DWORD dwWidth = ddsdDescDest.Width;
DWORD dwHeight = ddsdDescDest.Height;
SourceLocker.Lock(Level);
DestLocker.Lock(Level);
for(i=0; i < dwWidth; i++)
{
for(j = 0; j < dwHeight; j++)
{
float fRight, fLeft, fUp, fDown;
SourceLocker.GetMapLuminance(Level, i + 1, j, fRight);
SourceLocker.GetMapLuminance(Level, i - 1, j, fLeft);
SourceLocker.GetMapLuminance(Level, i, j - 1, fUp);
SourceLocker.GetMapLuminance(Level, i, j + 1, fDown);
D3DXVECTOR3 dfdi(2.f, 0.f, fRight - fLeft);
D3DXVECTOR3 dfdj(0.f, 2.f, fDown - fUp);
D3DXVec3Cross(&Normal, &dfdi, &dfdj);
Normal[0] *= Scale[0];
Normal[1] *= Scale[1];
Normal[2] *= Scale[2];
D3DXVec3Normalize(&Normal, &Normal);
if (ti->m_eTT == eTT_DSDTBump)
Normal[2] = 0.5f;
DestLocker.SetMapVector(Level, i, j, Normal);
}
}
SourceLocker.Unlock(Level);
DestLocker.Unlock(Level);
}
SAFE_RELEASE(pNewTex);
return pNormalMap;
}
static void FilterNormalMap(LPDIRECT3DDEVICE8 pD3DDev, LPDIRECT3DTEXTURE8 pNormalMap)
{
D3DSURFACE_DESC ddsdDescSource;
D3DXVECTOR3 Normal;
DWORD i, j;
D3D2DTextureLocker SurfaceLocker(pNormalMap);
for (DWORD Level = 0; Level < pNormalMap->GetLevelCount() - 1; Level++)
{
SurfaceLocker.Lock(Level);
SurfaceLocker.Lock(Level + 1);
pNormalMap->GetLevelDesc(Level, &ddsdDescSource);
for(i=0; i < ddsdDescSource.Width; i+=2)
{
for(j = 0; j < ddsdDescSource.Height; j+=2)
{
D3DXVECTOR3 Vectors[4];
SurfaceLocker.GetMapVector(Level, i, j, Vectors[0]);
SurfaceLocker.GetMapVector(Level, i+1, j, Vectors[1]);
SurfaceLocker.GetMapVector(Level, i+1, j+1, Vectors[2]);
SurfaceLocker.GetMapVector(Level, i+1, j+1, Vectors[3]);
D3DXVECTOR3 Normal = Vectors[0] + Vectors[1] + Vectors[2] + Vectors[3];
D3DXVec3Normalize(&Normal, &Normal);
SurfaceLocker.SetMapVector(Level + 1, i / 2, j / 2, Normal);
}
}
SurfaceLocker.Unlock(Level);
SurfaceLocker.Unlock(Level + 1);
}
}
static LPDIRECT3DCUBETEXTURE8 CreateNormalizationCubeMap(LPDIRECT3DDEVICE8 pD3DDev, DWORD dwWidth, DWORD dwMipmaps = 0, D3DPOOL Pool = D3DPOOL_MANAGED)
{
HRESULT hr;
LPDIRECT3DCUBETEXTURE8 pCubeTexture;
hr = D3DXCreateCubeTexture(pD3DDev, dwWidth, dwMipmaps, 0, D3DFMT_X8R8G8B8, Pool, &pCubeTexture);
if(FAILED(hr))
{
return NULL;
}
if (dwMipmaps == 0)
dwMipmaps = pCubeTexture->GetLevelCount();
for (DWORD dwLevel = 0; dwLevel < dwMipmaps; dwLevel++)
{
for (int i = 0; i < 6; i++)
{
D3DLOCKED_RECT Locked;
D3DXVECTOR3 Normal;
float w,h;
D3DSURFACE_DESC ddsdDesc;
pCubeTexture->GetLevelDesc(dwLevel, &ddsdDesc);
pCubeTexture->LockRect((D3DCUBEMAP_FACES)i, dwLevel, &Locked, NULL, 0);
for (unsigned int y = 0; y < ddsdDesc.Height; y++)
{
h = (float)y / ((float)(ddsdDesc.Height - 1));
h *= 2.0f;
h -= 1.0f;
for (unsigned int x = 0; x < ddsdDesc.Width; x++)
{
w = (float)x / ((float)(ddsdDesc.Width - 1));
w *= 2.0f;
w -= 1.0f;
DWORD* pBits = (DWORD*)((BYTE*)Locked.pBits + (y * Locked.Pitch));
pBits += x;
switch((D3DCUBEMAP_FACES)i)
{
case D3DCUBEMAP_FACE_POSITIVE_X:
Normal = D3DXVECTOR3(1.0f, -h, -w);
break;
case D3DCUBEMAP_FACE_NEGATIVE_X:
Normal = D3DXVECTOR3(-1.0f, -h, w);
break;
case D3DCUBEMAP_FACE_POSITIVE_Y:
Normal = D3DXVECTOR3(w, 1.0f, h);
break;
case D3DCUBEMAP_FACE_NEGATIVE_Y:
Normal = D3DXVECTOR3(w, -1.0f, -h);
break;
case D3DCUBEMAP_FACE_POSITIVE_Z:
Normal = D3DXVECTOR3(w, -h, 1.0f);
break;
case D3DCUBEMAP_FACE_NEGATIVE_Z:
Normal = D3DXVECTOR3(-w, -h, -1.0f);
break;
default:
assert(0);
break;
}
D3DXVec3Normalize(&Normal, &Normal);
// Scale to be a color from 0 to 255 (127 is 0)
Normal += D3DXVECTOR3(1.0f, 1.0f, 1.0f);
Normal *= 127.0f;
// Store the color
*pBits = (DWORD)(((DWORD)Normal.x << 16) | ((DWORD)Normal.y << 8) | ((DWORD)Normal.z << 0));
}
}
pCubeTexture->UnlockRect((D3DCUBEMAP_FACES)i, 0);
}
}
return pCubeTexture;
}
};
#endif __D3DTEXTURE_H

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,133 @@
/*=============================================================================
D3DTexturesStreaming.cpp : Direct3D8 specific texture streaming technology.
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
Revision history:
* Created by Honitch Andrey
=============================================================================*/
#include "stdafx.h"
#include "DriverD3D8.h"
//===============================================================================
void STexPic::BuildMips(TArray<SMipmap *>* Mips)
{
}
void STexPicD3D::BuildMips(TArray<SMipmap *>* Mips)
{
CD3D8Renderer *r = gcpRendD3D;
LPDIRECT3DDEVICE8 dv = r->mfGetD3DDevice();
IDirect3DTexture8 *pID3DTexture = NULL;
IDirect3DCubeTexture8 *pID3DCubeTexture = NULL;
HRESULT h;
D3DLOCKED_RECT d3dlr;
D3DSURFACE_DESC ddsdDescDest;
if (m_eTT != eTT_Cubemap)
{
pID3DTexture = (IDirect3DTexture8*)m_RefTex->m_VidTex;
Mips[0].Free();
for (int i=0; i<m_nMips; i++)
{
pID3DTexture->GetLevelDesc(i, &ddsdDescDest);
assert (ddsdDescDest.Width && ddsdDescDest.Height);
int size = CD3D8TexMan::TexSize(ddsdDescDest.Width, ddsdDescDest.Height, ddsdDescDest.Format);
SMipmap *mp = new SMipmap(ddsdDescDest.Width, ddsdDescDest.Height, size);
h = pID3DTexture->LockRect(i, &d3dlr, NULL, 0);
memcpy(&mp->DataArray[0], d3dlr.pBits, size);
pID3DTexture->UnlockRect(i);
Mips[0].AddElem(mp);
}
}
else
{
pID3DCubeTexture = (IDirect3DCubeTexture8*)m_RefTex->m_VidTex;
for (int n=0; n<6; n++)
{
Mips[n].Free();
for (int i=0; i<m_nMips; i++)
{
pID3DCubeTexture->GetLevelDesc(i, &ddsdDescDest);
assert (ddsdDescDest.Width && ddsdDescDest.Height);
int size = CD3D8TexMan::TexSize(ddsdDescDest.Width, ddsdDescDest.Height, ddsdDescDest.Format);
SMipmap *mp = new SMipmap(ddsdDescDest.Width, ddsdDescDest.Height, size);
h = pID3DCubeTexture->LockRect((D3DCUBEMAP_FACES)n, i, &d3dlr, NULL, 0);
memcpy(&mp->DataArray[0], d3dlr.pBits, size);
pID3DCubeTexture->UnlockRect((D3DCUBEMAP_FACES)n, i);
Mips[n].AddElem(mp);
}
}
}
}
void STexPic::DownloadMips(TArray<SMipmap *>* Mips, int nStartMip, int nEndMip, int SizeFirst)
{
}
void STexPicD3D::DownloadMips(TArray<SMipmap *>* Mips, int nStartMip, int nEndMip, int SizeFirst)
{
CD3D8Renderer *r = gcpRendD3D;
LPDIRECT3DDEVICE8 dv = r->mfGetD3DDevice();
IDirect3DTexture8 *pID3DTexture = NULL;
IDirect3DCubeTexture8 *pID3DCubeTexture = NULL;
HRESULT h;
D3DLOCKED_RECT d3dlr;
if (m_eTT != eTT_Cubemap)
{
pID3DTexture = (IDirect3DTexture8*)m_RefTex->m_VidTex;
if (!pID3DTexture)
{
if( FAILED( h = D3DXCreateTexture(dv, m_Width, m_Height, m_nMips, 0, (D3DFORMAT)m_RefTex->m_DstFormat, D3DPOOL_MANAGED, &pID3DTexture ) ) )
return;
m_RefTex->m_VidTex = pID3DTexture;
}
#ifndef _XBOX
pID3DTexture->SetLOD(nStartMip);
#endif
for (int i=0; i<Mips[0].Num(); i++)
{
int nLod = i+nStartMip;
SMipmap *mp = Mips[0][i];
int size = CD3D8TexMan::TexSize(mp->USize, mp->VSize, m_RefTex->m_DstFormat);
h = pID3DTexture->LockRect(nLod, &d3dlr, NULL, 0);
// Copy data to video texture
memcpy((byte *)d3dlr.pBits, &mp->DataArray[0], size);
// Unlock the video texture
pID3DTexture->UnlockRect(nLod);
}
Mips[0].Free();
}
else
{
pID3DCubeTexture = (IDirect3DCubeTexture8*)m_RefTex->m_VidTex;
if (!pID3DCubeTexture)
{
if( FAILED( h = D3DXCreateCubeTexture(dv, m_Width, m_nMips, 0, (D3DFORMAT)m_RefTex->m_DstFormat, D3DPOOL_MANAGED, &pID3DCubeTexture ) ) )
return;
m_RefTex->m_VidTex = pID3DCubeTexture;
}
#ifndef _XBOX
pID3DCubeTexture->SetLOD(nStartMip);
#endif
for (int n=0; n<6; n++)
{
for (int i=0; i<Mips[n].Num(); i++)
{
int nLod = i+nStartMip;
SMipmap *mp = Mips[n][i];
int size = CD3D8TexMan::TexSize(mp->USize, mp->VSize, m_RefTex->m_DstFormat);
h = pID3DCubeTexture->LockRect((D3DCUBEMAP_FACES)n, nLod, &d3dlr, NULL, 0);
// Copy data to video texture
memcpy((byte *)d3dlr.pBits, &mp->DataArray[0], size);
// Unlock the video texture
pID3DCubeTexture->UnlockRect((D3DCUBEMAP_FACES)n, nLod);
}
Mips[n].Free();
}
}
}

View File

@@ -0,0 +1,108 @@
/*=============================================================================
D3DVPrograms.h : Direct3D vertex programming interface declaration.
Copyright 1999 K&M. All Rights Reserved.
Revision history:
* Created by Honitch Andrey
=============================================================================*/
#ifndef __D3DVPROGRAMS_H__
#define __D3DVPROGRAMS_H__
#define VPF_TRACK_MATRIX 1
#define VPVST_FOGGLOBAL 1
#define VPVST_CLIPPLANES 2
#define VPVST_NOFOG 4
#define VPVST_USETANGENTS 0x10
#define VPFI_NOFOG 1
#define VPFI_UNIFIEDPOS 2
#define VPFI_SUPPORTMULTVLIGHTS 4
struct STrackMatrix
{
uint m_Address;
int m_Matrix;
int m_Transform;
};
class CVProgram_D3D : public CVProgram
{
static int m_LastTypeVP;
void *m_pCode[4];
char *m_Script;
int m_CodeSize[4];
uint m_Flags;
int m_dwShader[8][4][32]; // different handles for each declaration (VertexFormat)
TArray<SParam> m_Params;
TArray<STrackMatrix> m_TrackMatrix;
TArray<SArrayPointer *> m_Pointers;
void mfTrackMatrix(int Address, int Matrix, int Transform);
char *mfCreateAdditionalVP(int Num);
bool mfActivate(int Num, int Streams, int VertFormat);
public:
static CVProgram *m_LastVP;
virtual int Size()
{
return 0;
}
CVProgram_D3D() : CVProgram()
{
m_bCGType = false;
m_Flags = 0;
int i, j, n;
m_Script = NULL;
for (i=0; i<4; i++)
{
m_CodeSize[i] = 0;
}
m_Flags = 0;
for (i=0; i<4; i++)
{
m_pCode[i] = NULL;
for (j=0; j<4; j++)
{
for (n=0; n<32; n++)
{
m_dwShader[i][j][n] = 0;
}
}
}
}
void mfParameter(int index, float * v);
virtual ~CVProgram_D3D();
virtual bool mfCompile(char *scr, SShader *sh);
virtual bool mfSet(bool bStat, int nSetPointers=1);
virtual void mfSetVariables(TArray<SParam>* Vars);
virtual bool mfHasPointer(EPointer ePtr);
};
#define MT_MODELVIEW_PROJECTION 1
#define MT_MODELVIEW 2
#define MT_MATRIX0 3
#define MT_MATRIX1 4
#define MT_MATRIX2 5
#define MT_MATRIX3 6
#define MT_MATRIX4 7
#define MT_MATRIX5 8
#define MT_MATRIX6 9
#define MT_MATRIX7 10
#define MT_TEXTURE 11
#define MTR_IDENTITY 1
#define MTR_INVERSE 2
#define MTR_TRANSPOSE 3
#define MTR_INVERSE_TRANSPOSE 4
#endif // __D3DVPROGRAMS_H__

View File

@@ -0,0 +1,48 @@
#include "stdafx.h"
#include "DriverD3D8.h"
#include "I3dengine.h"
void CD3D8Renderer::PrepareOutSpaceTextures(CREOutSpace * pRE)
{
int arrnResult[2];
ScanOutSpaceCube(pRE->m_TexID, iSystem->GetViewCamera().GetPos(), arrnResult);
}
void CD3D8Renderer::DrawOutSpaceSide( const float *angle, const Vec3d & Pos, int tex_size, int offsetX, int offsetY)
{
if (!iSystem)
return;
CRenderer * renderer = gRenDev;
CCamera tmp_camera = renderer->GetCamera();
CCamera prevCamera = tmp_camera;
tmp_camera.Init(tex_size,tex_size);
tmp_camera.SetPos(Pos);
tmp_camera.SetAngle(Vec3d(angle[0], angle[1], angle[2]));
tmp_camera.Update();
iSystem->SetViewCamera(tmp_camera);
gRenDev->SetCamera(tmp_camera);
gRenDev->SetViewport(tex_size*offsetX, tex_size*offsetY, tex_size, tex_size);
I3DEngine *eng = (I3DEngine *)iSystem->GetIProcess();
eng->SetCamera(tmp_camera,false );
eng->DrawLowDetail(0);
iSystem->SetViewCamera(prevCamera);
gRenDev->SetCamera(prevCamera);
}
void CD3D8Renderer::ScanOutSpaceCube(uint & nTexID, const Vec3d & vPos, int * pResult)
{
}
bool CREOutSpace::mfDraw(SShader *ef, SShaderPass *sfm)
{
return true;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,88 @@
#ifndef _STATICIB_H_
#define _STATICIB_H_
/////////////////////////////
// D. Sim Dietrich Jr.
// sim.dietrich@nvidia.com
//////////////////////
template < class IndexType > class StaticIB
{
private :
LPDIRECT3DINDEXBUFFER8 mpIB;
uint mIndexCount;
bool mbLocked;
public :
unsigned int GetIndexCount() const
{
return mIndexCount;
}
StaticIB( const LPDIRECT3DDEVICE8 pD3D, const unsigned int& theIndexCount )
{
mpIB = 0;
mbLocked = false;
mIndexCount = theIndexCount;
HRESULT hr = pD3D->CreateIndexBuffer( mIndexCount * sizeof( IndexType ), 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &mpIB);
ASSERT( ( hr == D3D_OK ) && ( mpIB ) );
}
LPDIRECT3DINDEXBUFFER8 GetInterface() const { return mpIB; }
IndexType* Lock( const unsigned int& theLockCount, unsigned int& theStartIndex )
{
IndexType* pLockedData = 0;
// Ensure there is enough space in the IB for this data
ASSERT ( theLockCount <= mIndexCount )
if (mbLocked)
Unlock();
if ( mpIB )
{
DWORD dwFlags = 0;
DWORD dwSize = 0;
HRESULT hr = mpIB->Lock( 0, 0, reinterpret_cast< BYTE** >( &pLockedData ), dwFlags );
ASSERT( hr == D3D_OK );
ASSERT( pLockedData != 0 );
mbLocked = true;
theStartIndex = 0;
}
return pLockedData;
}
void Unlock()
{
if ( ( mbLocked ) && ( mpIB ) )
{
HRESULT hr = mpIB->Unlock();
ASSERT( hr == D3D_OK );
mbLocked = false;
}
}
~StaticIB()
{
Unlock();
if ( mpIB )
{
mpIB->Release();
}
}
};
typedef StaticIB< unsigned short > StaticIB16;
typedef StaticIB< unsigned int > StaticIB32;
#endif _STATICIB_H_

View File

@@ -0,0 +1,85 @@
#ifndef _StaticVB_H_
#define _StaticVB_H_
template <class VertexType> class StaticVB
{
private :
LPDIRECT3DVERTEXBUFFER8 mpVB;
uint mVertexCount;
bool mbLocked;
public :
uint GetVertexCount() const
{
return mVertexCount;
}
StaticVB( const LPDIRECT3DDEVICE8 pD3D, const DWORD& theFVF, const unsigned int& theVertexCount )
{
mpVB = 0;
mbLocked = false;
mVertexCount = theVertexCount;
HRESULT hr = pD3D->CreateVertexBuffer( mVertexCount * sizeof( VertexType ), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, theFVF, D3DPOOL_DEFAULT, &mpVB);
ASSERT( ( hr == D3D_OK ) && ( mpVB ) );
}
LPDIRECT3DVERTEXBUFFER8 GetInterface() const { return mpVB; }
VertexType* Lock( const unsigned int& theLockCount, unsigned int& theStartVertex )
{
theStartVertex = 0;
VertexType* pLockedData = 0;
// Ensure there is enough space in the VB for this data
ASSERT ( theLockCount <= mVertexCount );
if (mbLocked)
Unlock();
if ( mpVB )
{
#ifndef _XBOX
DWORD dwFlags = D3DLOCK_DISCARD;
#else
DWORD dwFlags = 0;
#endif
DWORD dwSize = 0;
HRESULT hr = mpVB->Lock( 0, 0, reinterpret_cast< BYTE** >( &pLockedData ), dwFlags );
ASSERT( hr == D3D_OK );
ASSERT( pLockedData != 0 );
mbLocked = true;
}
return pLockedData;
}
void Unlock()
{
if ( ( mbLocked ) && ( mpVB ) )
{
HRESULT hr = mpVB->Unlock();
ASSERT( hr == D3D_OK );
mbLocked = false;
}
}
~StaticVB()
{
Unlock();
if ( mpVB )
{
mpVB->Release();
}
}
};
#endif _StaticVB_H_

View File

@@ -0,0 +1,774 @@
<?xml version="1.0" encoding = "windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="XRenderD3D8"
ProjectGUID="{FBB51267-E44B-4202-942D-2118EEC30164}"
SccProjectName="&quot;$/Game01/RenderDll/XRenderD3D8&quot;, TKOAAAAA"
SccAuxPath=""
SccLocalPath="."
SccProvider="MSSCCI:Microsoft Visual SourceSafe">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OmitFramePointers="TRUE"
AdditionalIncludeDirectories="..\..\,..\..\FarCry,..\..\CryNetwork,..\..\CryCommon,..\..\CryCommon\Stl,..\..\CryPhysics"
PreprocessorDefinitions="_RELEASE;COMP_VC;DO_ASM;DIRECT3D8;OS_WIN32;PROC_INTEL;WIN32;NDEBUG;_WINDOWS;_USRDLL;XRENDERD3D8_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="2"
BufferSecurityCheck="FALSE"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Release/XRenderD3D8.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Winmm.lib d3dx8.lib d3d8.lib cg.lib cgD3D8.lib"
OutputFile=".\Release/XRenderD3D8.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="Libraries"
ProgramDatabaseFile=".\Release/XRenderD3D8.pdb"
ImportLibrary=".\Release/XRenderD3D8.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/XRenderD3D8.tlb"/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(TargetPath) C:\MasterCD"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Profile|Win32"
OutputDirectory="C:\MasterCD"
IntermediateDirectory=".\Profile"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OmitFramePointers="TRUE"
AdditionalIncludeDirectories="..\..\,..\..\FarCry,..\..\CryNetwork,..\..\CryCommon,..\..\CryCommon\Stl,..\..\CryPhysics"
PreprocessorDefinitions="COMP_VC;DO_ASM;DIRECT3D8;OS_WIN32;PROC_INTEL;WIN32;NDEBUG;_WINDOWS;_USRDLL;XRENDERD3D8_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Profile/XRenderD3D8.pch"
AssemblerListingLocation=".\Profile/"
ObjectFile=".\Profile/"
ProgramDataBaseFileName=".\Profile/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="3"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Winmm.lib d3dx8.lib d3d8.lib cg.lib cgD3D8.lib"
OutputFile="C:\MasterCD/XRenderD3D8.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="Libraries"
GenerateDebugInformation="TRUE"
GenerateMapFile="TRUE"
MapFileName=".\Profile/XRenderD3D8.map"
BaseAddress="0x40000000"
ImportLibrary="C:\MasterCD/XRenderD3D8.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName="C:\MasterCD/XRenderD3D8.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\,..\..\FarCry,..\..\CryNetwork,..\..\CryCommon,..\..\CryCommon\Stl"
PreprocessorDefinitions="COMP_VC;DO_ASM;DIRECT3D8;OS_WIN32;PROC_INTEL;WIN32;_DEBUG;_WINDOWS;_USRDLL;XRENDERD3D8_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
BufferSecurityCheck="TRUE"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Debug/XRenderD3D8.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(TargetFileName) to MasterCD"
CommandLine="copy $(TargetPath) C:\MasterCD
copy $(TargetDir)$(TargetName).pdb C:\MasterCD
"
Outputs="c:\MasterCD\$(TargetFileName)"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Winmm.lib d3dx8.lib d3d8.lib cg.lib cgD3D8.lib"
OutputFile=".\Debug/XRenderD3D8.dll"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="Libraries"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/XRenderD3D8.pdb"
ImportLibrary=".\Debug/XRenderD3D8.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/XRenderD3D8.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="D3DCGVProgram.cpp">
</File>
<File
RelativePath=".\D3DFont.cpp">
</File>
<File
RelativePath=".\D3DPShaders.cpp">
</File>
<File
RelativePath="D3DRendPipeline.cpp">
</File>
<File
RelativePath=".\D3DRenderRE.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="3"/>
</FileConfiguration>
</File>
<File
RelativePath="D3DShaders.cpp">
</File>
<File
RelativePath=".\D3DShadows.cpp">
</File>
<File
RelativePath=".\D3DTextures.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="4"/>
</FileConfiguration>
</File>
<File
RelativePath="D3DTexturesStreaming.cpp">
</File>
<File
RelativePath=".\D3D_OutSpace.cpp">
</File>
<File
RelativePath=".\DriverD3D8.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="4"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="4"/>
</FileConfiguration>
</File>
<Filter
Name="CG"
Filter="">
<File
RelativePath="CG\cg.h">
</File>
<File
RelativePath="CG\cgContextManager.h">
</File>
<File
RelativePath="CG\cgD3D.h">
</File>
<File
RelativePath="CG\cgGL_profiles.h">
</File>
<File
RelativePath="CG\cgProgramManager.h">
</File>
<File
RelativePath="CG\cgTemplates.h">
</File>
<File
RelativePath="CG\cg_bindlocations.h">
</File>
<File
RelativePath="CG\cg_datatypes.h">
</File>
<File
RelativePath="CG\cg_errors.h">
</File>
<File
RelativePath="CG\cg_profiles.h">
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="D3DCGPShader.h">
</File>
<File
RelativePath="D3DCGVProgram.h">
</File>
<File
RelativePath=".\D3DCubeMaps.h">
</File>
<File
RelativePath=".\D3DPShaders.h">
</File>
<File
RelativePath=".\D3DTexture.h">
</File>
<File
RelativePath=".\DriverD3D8.h">
</File>
<File
RelativePath=".\StaticIB.h">
</File>
<File
RelativePath=".\StaticVB.h">
</File>
</Filter>
<Filter
Name="Common"
Filter="">
<File
RelativePath="..\Common\CPUDetect.cpp">
</File>
<File
RelativePath="..\Common\EvalFuncs_C.cpp">
</File>
<File
RelativePath="..\Common\EvalFuncs_RE.cpp">
</File>
<File
RelativePath="..\Common\LightMaterial.cpp">
</File>
<File
RelativePath="..\Common\Names.cpp">
</File>
<File
RelativePath="..\Common\Renderer.cpp">
</File>
<File
RelativePath="..\Common\ResFile.cpp">
</File>
<File
RelativePath="..\Common\SimpleFrameProfiler.cpp">
</File>
<Filter
Name="Common_h"
Filter="">
<File
RelativePath="..\Common\CPUDetect.h">
</File>
<File
RelativePath="..\Common\CommonRender.h">
</File>
<File
RelativePath="..\Common\EvalFuncs.h">
</File>
<File
RelativePath="..\Common\FrameProfilers-list.h">
</File>
<File
RelativePath="..\Common\LZSS.H">
</File>
<File
RelativePath="..\Common\Names.int">
</File>
<File
RelativePath="..\Common\RenderPipeline.h">
</File>
<File
RelativePath="..\Common\Renderer.h">
</File>
<File
RelativePath="..\Common\Shadow_Renderer.h">
</File>
<File
RelativePath="..\Common\SimpleFrameProfiler.h">
</File>
</Filter>
<Filter
Name="RendElements"
Filter="">
<File
RelativePath="..\Common\RendElements\CRE2DQuad.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREBeam.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREClientPoly.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREClientPoly2D.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREDummy.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREFlares.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREFlashBang.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREGlare.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREOcLeaf.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREOcean.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="4"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\RendElements\CREOclusionQuery.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREParticleSpray.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREPolyBlend.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREPolyMesh.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREPrefabGeom.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CREShadowMap.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CRESky.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CRETempMesh.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CRETerrainSector.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CRETriMeshAdditionalShadow.cpp">
</File>
<File
RelativePath="..\Common\RendElements\CRETriMeshShadow.cpp">
</File>
<File
RelativePath="..\Common\RendElements\RendElement.cpp">
</File>
<Filter
Name="RendElements_h"
Filter="">
<File
RelativePath="..\Common\RendElements\CREBeam.h">
</File>
<File
RelativePath="..\Common\RendElements\CREClientPoly.h">
</File>
<File
RelativePath="..\Common\RendElements\CREClientPoly2D.h">
</File>
<File
RelativePath="..\Common\RendElements\CREFlares.h">
</File>
<File
RelativePath="..\Common\RendElements\CREGlare.h">
</File>
<File
RelativePath="..\Common\RendElements\CREOcean.h">
</File>
<File
RelativePath="..\Common\RendElements\CREParticleSpray.h">
</File>
<File
RelativePath="..\Common\RendElements\CREPolyBlend.h">
</File>
<File
RelativePath="..\Common\RendElements\CRESkyZone.h">
</File>
<File
RelativePath="..\Common\RendElements\CRETempMesh.h">
</File>
</Filter>
</Filter>
<Filter
Name="Textures"
Filter="">
<File
RelativePath="..\Common\Textures\TexMan.cpp">
</File>
<File
RelativePath="..\Common\Textures\TexManStreaming.cpp">
</File>
<File
RelativePath="..\Common\Textures\dxtlib.h">
</File>
<Filter
Name="Image"
Filter="">
<File
RelativePath="..\Common\Textures\Image\BmpImage.cpp">
</File>
<File
RelativePath="..\Common\Textures\Image\CCTImage.cpp">
</File>
<File
RelativePath="..\Common\Textures\Image\CCTImage.h">
</File>
<File
RelativePath="..\Common\Textures\Image\CImage.cpp">
</File>
<File
RelativePath="..\Common\Textures\Image\DDSImage.cpp">
</File>
<File
RelativePath="..\Common\Textures\Image\GifImage.cpp">
</File>
<File
RelativePath="..\Common\Textures\Image\JpgImage.cpp">
</File>
<File
RelativePath="..\Common\Textures\Image\PcxImage.cpp">
</File>
<File
RelativePath="..\Common\Textures\Image\Quantize.cpp">
</File>
<File
RelativePath="..\Common\Textures\Image\TgaImage.cpp">
</File>
<File
RelativePath="..\Common\Textures\Image\inv_cmap.cpp">
</File>
<Filter
Name="Image_h"
Filter="">
<File
RelativePath="..\Common\Textures\Image\BmpImage.h">
</File>
<File
RelativePath="..\Common\Textures\Image\CImage.h">
</File>
<File
RelativePath="..\Common\Textures\Image\DDSImage.h">
</File>
<File
RelativePath="..\Common\Textures\Image\GifImage.h">
</File>
<File
RelativePath="..\Common\Textures\Image\JpgImage.h">
</File>
<File
RelativePath="..\Common\Textures\Image\PcxImage.h">
</File>
<File
RelativePath="..\Common\Textures\Image\Quantize.h">
</File>
<File
RelativePath="..\Common\Textures\Image\SHendian.h">
</File>
<File
RelativePath="..\Common\Textures\Image\TgaImage.h">
</File>
<File
RelativePath="..\Common\Textures\Image\dds.h">
</File>
<File
RelativePath="..\Common\Textures\Image\ijl.h">
</File>
<File
RelativePath="..\Common\Textures\Image\inv_cmap.h">
</File>
</Filter>
<Filter
Name="zlib"
Filter="">
<File
RelativePath="..\Common\Textures\Image\zlib\zconf.h">
</File>
<File
RelativePath="..\Common\Textures\Image\zlib\zlib.h">
</File>
</Filter>
</Filter>
</Filter>
<Filter
Name="LeafBuffer"
Filter="">
<File
RelativePath="..\Common\LeafBufferCreate.cpp">
</File>
<File
RelativePath="..\Common\LeafBufferRender.cpp">
</File>
<File
RelativePath="..\Common\LeafBufferSerialize.cpp">
</File>
<File
RelativePath="..\Common\PBCloneMapDest.cpp">
</File>
<File
RelativePath="..\Common\PBCloneMapDest.h">
</File>
<File
RelativePath="..\Common\RGBPackedBase.h">
</File>
<File
RelativePath="..\Common\TGA.CPP">
</File>
<File
RelativePath="..\Common\pip_addons.cpp">
</File>
<File
RelativePath="..\Common\tangent_basis.cpp">
</File>
</Filter>
<Filter
Name="NvTriStrip"
Filter="">
<File
RelativePath="..\Common\NvTriStrip\NvTriStrip.cpp">
</File>
<File
RelativePath="..\Common\NvTriStrip\NvTriStrip.h">
</File>
<File
RelativePath="..\Common\NvTriStrip\NvTriStripObjects.cpp">
</File>
<File
RelativePath="..\Common\NvTriStrip\NvTriStripObjects.h">
</File>
<File
RelativePath="..\Common\NvTriStrip\VertexCache.h">
</File>
</Filter>
<Filter
Name="Mkl"
Filter="">
<File
RelativePath="..\Common\Mkl\mkl_c.lib">
</File>
<File
RelativePath="..\Common\Mkl\mkl_p3.lib">
</File>
<Filter
Name="Mkl_h"
Filter="">
<File
RelativePath="..\Common\Mkl\mkl.h">
</File>
<File
RelativePath="..\Common\Mkl\mkl_fft.h">
</File>
<File
RelativePath="..\Common\Mkl\mkl_types.h">
</File>
</Filter>
</Filter>
<Filter
Name="Shaders"
Filter="">
<File
RelativePath="..\Common\Shaders\CShader.h">
</File>
<File
RelativePath="..\Common\Shaders\Parser.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Profile|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\Shaders\Parser.h">
</File>
<File
RelativePath="..\Common\Shaders\Shader.h">
</File>
<File
RelativePath="..\Common\Shaders\ShaderComponents.cpp">
</File>
<File
RelativePath="..\Common\Shaders\ShaderCore.cpp">
</File>
<File
RelativePath="..\Common\Shaders\ShaderParse.cpp">
</File>
<File
RelativePath="..\Common\Shaders\ShaderScript.cpp">
</File>
<File
RelativePath="..\Common\Shaders\ShaderTemplate.cpp">
</File>
</Filter>
</Filter>
<Filter
Name="Libraries"
Filter="">
<File
RelativePath=".\Libraries\ijl15.lib">
</File>
<File
RelativePath="..\XRenderOGL\Libraries\nvDXTlib.lib">
</File>
</Filter>
<File
RelativePath="..\CrtOverrides.h">
</File>
<File
RelativePath="..\stdafx.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Profile|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\stdafx.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = "file:F:\\Crytek\\RenderDll\\XRenderD3D8\\XRenderD3D8.vcproj"
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = "file:D:\\PROGRAMMING\\Game01_XBPort\\RENDERDLL\\XRENDERD3D8\\XRenderD3D8_XBox.vcproj"
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
}