summaryrefslogtreecommitdiff
path: root/Runtime/GfxDevice/opengles30/GpuProgramsGLES30.h
blob: 73bd469a714bdcda176046e314b9da8d635b4a4b (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
79
80
81
82
83
84
85
86
87
88
#ifndef GPUPROGRAMSGLES30_H
#define GPUPROGRAMSGLES30_H


#if !GFX_SUPPORTS_OPENGLES30 && !GFX_SUPPORTS_OPENGLES
#error "Should not include GpuProgramsGLES30 on this platform"
#endif


#include "Runtime/GfxDevice/GpuProgram.h"
#include "Runtime/GfxDevice/GfxDeviceTypes.h"
#include "Runtime/GfxDevice/ChannelAssigns.h"
#include "IncludesGLES30.h"
#include "GpuProgramsGLES30_UniformCache.h"

class ConstantBuffersGLES30;

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

	~GlslGpuProgramGLES30();

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

	// Returns the permutation index used
	int ApplyGpuProgramES30 (const GpuProgramParameters& params, const UInt8 *buffer);

	static bool	InitBinaryShadersSupport();


	UniformCacheGLES30	m_UniformCache[kFogModeCount];

	static bool CompileGlslShader(GLShaderID shader, const char* source);
	int 		GetGLProgram (FogMode fog, GpuProgramParameters& outParams, ChannelAssigns& channels);

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 FixedFunctionProgramGLES30
{
public:
	static const ShaderLab::FastPropertyName kSLPropTransformBlock;
	static const ShaderLab::FastPropertyName kSLPropUVTransformBlock;

public:
	FixedFunctionProgramGLES30(GLShaderID vertexShader, GLShaderID fragmentShader);
	~FixedFunctionProgramGLES30();

	void ApplyFFGpuProgram(const BuiltinShaderParamValues& values, ConstantBuffersGLES30& cbs) const;

	const BuiltinShaderParamIndices& GetBuiltinParams() const { return m_Params.GetBuiltinParams(); }
	const GpuProgramParameters::ConstantBufferList& GetConstantBuffers() const { return m_Params.GetConstantBuffers(); }

	mutable UniformCacheGLES30 		m_UniformCache;

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

private:
	GLShaderID				m_GLSLProgram;
	GLShaderID				m_GLSLVertexShader, m_GLSLFragmentShader;

	GpuProgramParameters	m_Params;
};


#endif