mirror of https://github.com/snes9xgit/snes9x.git
win32: add float_framebuffer to cg shaders
This commit is contained in:
parent
157e2f51d4
commit
555f5110fb
|
@ -278,6 +278,9 @@ bool CCGShader::LoadShader(const char *path)
|
|||
sprintf(keyName,"::frame_count_mod%u",i);
|
||||
pass.frameCounterMod = conf.GetInt(keyName,0);
|
||||
|
||||
sprintf(keyName,"::float_framebuffer%u",i);
|
||||
pass.floatFbo = conf.GetBool(keyName);
|
||||
|
||||
shaderPasses.push_back(pass);
|
||||
}
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ public:
|
|||
cgScaleParams scaleParams;
|
||||
bool linearFilter;
|
||||
bool filterSet;
|
||||
bool floatFbo;
|
||||
unsigned frameCounterMod;
|
||||
char cgShaderFile[PATH_MAX];
|
||||
} shaderPass;
|
||||
|
|
|
@ -334,6 +334,8 @@ bool CD3DCG::LoadShader(const TCHAR *shaderFile)
|
|||
|
||||
pass.frameCounterMod = it->frameCounterMod;
|
||||
|
||||
pass.useFloatTex = it->floatFbo;
|
||||
|
||||
// paths in the meta file can be relative
|
||||
_tfullpath(tempPath,_tFromChar(it->cgShaderFile),MAX_PATH);
|
||||
char *fileContents = ReadShaderFileContents(tempPath);
|
||||
|
@ -415,7 +417,7 @@ bool CD3DCG::LoadShader(const TCHAR *shaderFile)
|
|||
}
|
||||
|
||||
void CD3DCG::ensureTextureSize(LPDIRECT3DTEXTURE9 &tex, D3DXVECTOR2 &texSize,
|
||||
D3DXVECTOR2 wantedSize,bool renderTarget)
|
||||
D3DXVECTOR2 wantedSize,bool renderTarget,bool useFloat)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -427,7 +429,7 @@ void CD3DCG::ensureTextureSize(LPDIRECT3DTEXTURE9 &tex, D3DXVECTOR2 &texSize,
|
|||
wantedSize.x, wantedSize.y,
|
||||
1, // 1 level, no mipmaps
|
||||
renderTarget?D3DUSAGE_RENDERTARGET:0,
|
||||
renderTarget?D3DFMT_X8R8G8B8:D3DFMT_R5G6B5,
|
||||
renderTarget?(useFloat?D3DFMT_A32B32G32R32F:D3DFMT_X8R8G8B8):D3DFMT_R5G6B5,
|
||||
renderTarget?D3DPOOL_DEFAULT:D3DPOOL_MANAGED, // render targets cannot be managed
|
||||
&tex,
|
||||
NULL );
|
||||
|
@ -536,7 +538,7 @@ void CD3DCG::Render(LPDIRECT3DTEXTURE9 &origTex, D3DXVECTOR2 textureSize,
|
|||
/* make sure the render target exists and has an appropriate size,
|
||||
then set as current render target with last pass as source
|
||||
*/
|
||||
ensureTextureSize(shaderPasses[i].tex,shaderPasses[i].textureSize,D3DXVECTOR2(texSize,texSize),true);
|
||||
ensureTextureSize(shaderPasses[i].tex,shaderPasses[i].textureSize,D3DXVECTOR2(texSize,texSize),true,shaderPasses[i].useFloatTex);
|
||||
shaderPasses[i].tex->GetSurfaceLevel(0,&pRenderSurface);
|
||||
pDevice->SetTexture(0, shaderPasses[i-1].tex);
|
||||
pDevice->SetRenderTarget(0,pRenderSurface);
|
||||
|
|
|
@ -197,6 +197,7 @@ private:
|
|||
typedef struct _shaderPass {
|
||||
cgScaleParams scaleParams;
|
||||
bool linearFilter;
|
||||
bool useFloatTex;
|
||||
unsigned int frameCounterMod;
|
||||
CGprogram cgVertexProgram, cgFragmentProgram;
|
||||
LPDIRECT3DTEXTURE9 tex;
|
||||
|
@ -241,7 +242,7 @@ private:
|
|||
void setVertexStream(IDirect3DVertexBuffer9 *vertexBuffer,D3DXVECTOR2 inputSize,D3DXVECTOR2 textureSize,D3DXVECTOR2 outputSize);
|
||||
void setViewport(DWORD x, DWORD y, DWORD width, DWORD height);
|
||||
void setShaderVars(int pass);
|
||||
void ensureTextureSize(LPDIRECT3DTEXTURE9 &tex, D3DXVECTOR2 &texSize, D3DXVECTOR2 wantedSize,bool renderTarget);
|
||||
void ensureTextureSize(LPDIRECT3DTEXTURE9 &tex, D3DXVECTOR2 &texSize, D3DXVECTOR2 wantedSize,bool renderTarget, bool useFloat = false);
|
||||
void fillParameterMap(std::vector<parameterEntry> &map, CGparameter param);
|
||||
void setupVertexDeclaration(shaderPass &pass);
|
||||
void calculateMatrix();
|
||||
|
|
|
@ -346,6 +346,8 @@ bool CGLCG::LoadShader(const TCHAR *shaderFile)
|
|||
|
||||
pass.frameCounterMod = it->frameCounterMod;
|
||||
|
||||
pass.floatFbo = it->floatFbo;
|
||||
|
||||
// paths in the meta file can be relative
|
||||
_tfullpath(tempPath,_tFromChar(it->cgShaderFile),MAX_PATH);
|
||||
char *fileContents = ReadShaderFileContents(tempPath);
|
||||
|
@ -533,7 +535,7 @@ void CGLCG::Render(GLuint &origTex, xySize textureSize, xySize inputSize, xySize
|
|||
/* set size of output texture
|
||||
*/
|
||||
glBindTexture(GL_TEXTURE_2D,shaderPasses[i].tex);
|
||||
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,(unsigned int)shaderPasses[i].textureSize.x,
|
||||
glTexImage2D(GL_TEXTURE_2D,0,(shaderPasses[i].floatFbo?GL_RGBA32F:GL_RGBA),(unsigned int)shaderPasses[i].textureSize.x,
|
||||
(unsigned int)shaderPasses[i].textureSize.y,0,GL_RGBA,GL_UNSIGNED_INT_8_8_8_8,NULL);
|
||||
|
||||
/* viewport determines the area we render into the output texture
|
||||
|
|
|
@ -213,6 +213,7 @@ private:
|
|||
cgScaleParams scaleParams;
|
||||
bool linearFilter;
|
||||
unsigned frameCounterMod;
|
||||
bool floatFbo;
|
||||
CGprogram cgVertexProgram, cgFragmentProgram;
|
||||
GLuint tex;
|
||||
GLuint fbo;
|
||||
|
|
Loading…
Reference in New Issue