2017-10-29 10:28:14 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2015 Dimok
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef FETCH_SHADER_H
|
|
|
|
#define FETCH_SHADER_H
|
|
|
|
|
2019-08-14 23:24:55 +02:00
|
|
|
#include <gui/video/shaders/Shader.h>
|
2017-10-29 10:28:14 +01:00
|
|
|
|
2018-06-21 20:44:58 +02:00
|
|
|
class FetchShader : public Shader {
|
2017-10-29 10:28:14 +01:00
|
|
|
public:
|
2020-08-13 12:38:07 +02:00
|
|
|
FetchShader(GX2AttribStream *attributes, uint32_t attrCount, GX2FetchShaderType type = GX2_FETCH_SHADER_TESSELLATION_NONE, GX2TessellationMode tess = GX2_TESSELLATION_MODE_DISCRETE)
|
2022-02-05 14:28:08 +01:00
|
|
|
: fetchShader(NULL), fetchShaderProgramm(NULL) {
|
2018-06-21 20:44:58 +02:00
|
|
|
uint32_t shaderSize = GX2CalcFetchShaderSizeEx(attrCount, type, tess);
|
2020-08-13 12:38:07 +02:00
|
|
|
fetchShaderProgramm = (uint8_t *) memalign(GX2_SHADER_PROGRAM_ALIGNMENT, shaderSize);
|
|
|
|
if (fetchShaderProgramm) {
|
2017-10-29 10:28:14 +01:00
|
|
|
fetchShader = new GX2FetchShader;
|
|
|
|
GX2InitFetchShaderEx(fetchShader, fetchShaderProgramm, attrCount, attributes, type, tess);
|
2018-06-21 20:44:58 +02:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, fetchShaderProgramm, shaderSize);
|
2017-10-29 10:28:14 +01:00
|
|
|
}
|
|
|
|
}
|
2020-08-13 12:38:07 +02:00
|
|
|
|
2017-10-29 10:28:14 +01:00
|
|
|
virtual ~FetchShader() {
|
2020-08-13 12:58:19 +02:00
|
|
|
if (fetchShaderProgramm) {
|
2017-10-29 10:28:14 +01:00
|
|
|
free(fetchShaderProgramm);
|
2020-08-13 12:58:19 +02:00
|
|
|
}
|
|
|
|
if (fetchShader) {
|
2017-10-29 10:28:14 +01:00
|
|
|
delete fetchShader;
|
2020-08-13 12:58:19 +02:00
|
|
|
}
|
2017-10-29 10:28:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GX2FetchShader *getFetchShader() const {
|
|
|
|
return fetchShader;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setShader(void) const {
|
|
|
|
GX2SetFetchShader(fetchShader);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GX2FetchShader *fetchShader;
|
2018-06-21 20:44:58 +02:00
|
|
|
uint8_t *fetchShaderProgramm;
|
2017-10-29 10:28:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FETCH_SHADER_H
|