public void uploadToTexture(int baseMipLevel) {
mRS.validate();
- mRS.validateSurface();
mRS.nAllocationUploadToTexture(mID, baseMipLevel);
}
public void uploadToBufferObject() {
mRS.validate();
- mRS.validateSurface();
mRS.nAllocationUploadToBufferObject(mID);
}
}
}
- void validateSurface() {
- //if (mSurface == null) {
- //throw new IllegalStateException("Uploading data to GL with no surface.");
- //}
- }
-
public void contextSetPriority(Priority p) {
+ validate();
nContextSetPriority(p.mID);
}
mSurface = sur;
mWidth = w;
mHeight = h;
+ validate();
nContextSetSurface(w, h, mSurface);
}
public void contextDump(int bits) {
+ validate();
nContextDump(bits);
}
public void destroy() {
+ validate();
nContextDeinitToClient();
mMessageThread.mRun = false;
}
void pause() {
+ validate();
nContextPause();
}
void resume() {
+ validate();
nContextResume();
}
}
public void contextBindRootScript(Script s) {
+ validate();
nContextBindRootScript(safeID(s));
}
public void contextBindProgramFragmentStore(ProgramStore p) {
+ validate();
nContextBindProgramFragmentStore(safeID(p));
}
public void contextBindProgramFragment(ProgramFragment p) {
+ validate();
nContextBindProgramFragment(safeID(p));
}
public void contextBindProgramRaster(ProgramRaster p) {
+ validate();
nContextBindProgramRaster(safeID(p));
}
public void contextBindProgramVertex(ProgramVertex p) {
+ validate();
nContextBindProgramVertex(safeID(p));
}
}
if (mSamplers[ct].get()) {
- mSamplers[ct]->setupGL();
+ mSamplers[ct]->setupGL(rsc);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
void ProgramFragment::setupGL2(const Context *rsc, ProgramFragmentState *state, ShaderCache *sc)
{
+
//LOGE("sgl2 frag1 %x", glGetError());
if ((state->mLast.get() == this) && !mDirty) {
//return;
}
state->mLast.set(this);
+ rsc->checkError("ProgramFragment::setupGL2 start");
for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) {
glActiveTexture(GL_TEXTURE0 + ct);
if (!(mTextureEnableMask & (1 << ct)) || !mTextures[ct].get()) {
- glDisable(GL_TEXTURE_2D);
continue;
}
mTextures[ct]->uploadCheck(rsc);
glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID());
+ rsc->checkError("ProgramFragment::setupGL2 tex bind");
if (mSamplers[ct].get()) {
- mSamplers[ct]->setupGL();
+ mSamplers[ct]->setupGL(rsc);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ rsc->checkError("ProgramFragment::setupGL2 tex env");
}
- glEnable(GL_TEXTURE_2D);
glUniform1i(sc->fragUniformSlot(ct), ct);
+ rsc->checkError("ProgramFragment::setupGL2 uniforms");
}
glActiveTexture(GL_TEXTURE0);
//return;
}
+ rsc->checkError("ProgramVertex::setupGL2 start");
glVertexAttrib4f(1, state->color[0], state->color[1], state->color[2], state->color[3]);
const float *f = static_cast<const float *>(mConstants[0]->getPtr());
&f[RS_PROGRAM_VERTEX_TEXTURE_OFFSET]);
}
+ rsc->checkError("ProgramVertex::setupGL2 begin uniforms");
uint32_t uidx = 1;
for (uint32_t ct=0; ct < mConstantCount; ct++) {
Allocation *alloc = mConstants[ct+1].get();
{
}
-void Sampler::setupGL()
+void Sampler::setupGL(const Context *rsc)
{
GLenum trans[] = {
GL_NEAREST, //RS_SAMPLER_NEAREST,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, trans[mWrapS]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, trans[mWrapT]);
+ rsc->checkError("ProgramFragment::setupGL2 tex env");
}
void Sampler::bindToContext(SamplerState *ss, uint32_t slot)
mBoundSlot = -1;
ss->mSamplers[slot].clear();
}
-
+/*
void SamplerState::setupGL()
{
for (uint32_t ct=0; ct < RS_MAX_SAMPLER_SLOT; ct++) {
Sampler *s = mSamplers[ct].get();
if (s) {
- s->setupGL();
+ s->setupGL(rsc);
} else {
glBindTexture(GL_TEXTURE_2D, 0);
}
}
-}
+}*/
////////////////////////////////
virtual ~Sampler();
void bind(Allocation *);
- void setupGL();
+ void setupGL(const Context *);
void bindToContext(SamplerState *, uint32_t slot);
void unbindFromContext(SamplerState *);
ObjectBaseRef<Sampler> mSamplers[RS_MAX_SAMPLER_SLOT];
- void setupGL();
+ //void setupGL();
};
va.setActiveBuffer(mVertexBuffers[ct]->getBufferObjectID());
mVertexTypes[ct]->enableGLVertexBuffer2(&va);
}
- va.setupGL2(rsc, 0, &rsc->mShaderCache);
+ va.setupGL2(rsc, &rsc->mStateVertexArray, &rsc->mShaderCache);
} else {
for (uint32_t ct=0; ct < mVertexTypeCount; ct++) {
mVertexBuffers[ct]->uploadCheck(rsc);
void VertexArray::setupGL2(const Context *rsc, class VertexArrayState *state, ShaderCache *sc) const
{
- for (int ct=1; ct < RS_MAX_ATTRIBS; ct++) {
+ rsc->checkError("VertexArray::setupGL2 start");
+ for (uint32_t ct=1; ct <= state->mLastEnableCount; ct++) {
glDisableVertexAttribArray(ct);
}
+ rsc->checkError("VertexArray::setupGL2 disabled");
for (uint32_t ct=0; ct < mCount; ct++) {
uint32_t slot = 0;
if (sc->isUserVertexProgram()) {
mAttribs[ct].stride,
(void *)mAttribs[ct].offset);
}
- rsc->checkError("VertexArray::setupGL2");
+ state->mLastEnableCount = mCount;
+ rsc->checkError("VertexArray::setupGL2 done");
}
////////////////////////////////////////////
void VertexArrayState::init(Context *) {
+ mLastEnableCount = 0;
}
public:
void init(Context *);
+ uint32_t mLastEnableCount;
//VertexArray::Attrib mAttribs[VertexArray::_LAST];
};