summaryrefslogtreecommitdiff
path: root/Runtime/GfxDevice/opengles20/GpuProgramsGLES20.h
blob: a9a14d2b7b36392204d8146e47459eca05d5a80b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef GPUPROGRAMSGLES20_H
#define GPUPROGRAMSGLES20_H


#if !GFX_SUPPORTS_OPENGLES20
#error "Should not include GpuProgramsGLES20 on this platform"
#endif


#include "Runtime/GfxDevice/GpuProgram.h"
#include "Runtime/GfxDevice/GfxDeviceTypes.h"
#include "Runtime/GfxDevice/ChannelAssigns.h"
#include "Runtime/Utilities/GLSLUtilities.h"
#include "IncludesGLES20.h"
#include "GpuProgramsGLES20_UniformCache.h"

class GlslGpuProgramGLES20 : public GpuProgramGL
{
public:
	GlslGpuProgramGLES20 (const std::string& source, CreateGpuProgramOutput& output);
	~GlslGpuProgramGLES20();

	virtual void ApplyGpuProgram (const GpuProgramParameters& params, const UInt8* buffer) { Assert(!"Should not be used"); }

	// Returns the permutation index used
	int ApplyGpuProgramES20 (const GpuProgramParameters& params, const UInt8 *buffer);
	int	GetGLProgram (FogMode fog, GpuProgramParameters& outParams, ChannelAssigns& channels);

	static bool	InitBinaryShadersSupport();


	UniformCacheGLES20	m_UniformCache[kFogModeCount];

private:
	static void FillParams (unsigned int programID, GpuProgramParameters& params, PropertyNamesSet* outNames);

	bool		Create (const std::string& source, ChannelAssigns& channels);

	bool		CompileProgram(unsigned index, const std::string& vprog, const std::string& fshader, ChannelAssigns& channels);

private:
	std::string m_VertexShaderSourceForFog;
	GLShaderID m_GLSLVertexShader[kFogModeCount];
	GLShaderID m_GLSLFragmentShader[kFogModeCount];
	int		m_FogColorIndex[kFogModeCount];
	int		m_FogParamsIndex[kFogModeCount];
	bool	m_FogFailed[kFogModeCount];
	
	static std::string					_CachePath;
	static glGetProgramBinaryOESFunc	_glGetProgramBinaryOES;
	static glProgramBinaryOESFunc		_glProgramBinaryOES;
};


class FixedFunctionProgramGLES20
{
public:
	FixedFunctionProgramGLES20(GLShaderID vertexShader, GLShaderID fragmentShader);
	~FixedFunctionProgramGLES20();

	void ApplyFFGpuProgram(const BuiltinShaderParamValues& values) const;
	const BuiltinShaderParamIndices& GetBuiltinParams() const { return m_Params.GetBuiltinParams(); }

	mutable UniformCacheGLES20 		m_UniformCache;

protected:
	GLShaderID Create(GLShaderID vertexShader, GLShaderID fragmentShader);

private:
	GLShaderID				m_GLSLProgram;
	GLShaderID				m_GLSLVertexShader, m_GLSLFragmentShader;

	GpuProgramParameters	m_Params;
};

bool CompileGlslShader(GLShaderID shader, GLSLErrorType type, const char* source);

#endif