summaryrefslogtreecommitdiffstats
path: root/libs/rs
diff options
context:
space:
mode:
Diffstat (limited to 'libs/rs')
-rw-r--r--libs/rs/Allocation.cpp9
-rw-r--r--libs/rs/driver/rsdAllocation.cpp8
-rw-r--r--libs/rs/driver/rsdCore.cpp2
-rw-r--r--libs/rs/driver/rsdGL.cpp8
-rw-r--r--libs/rs/driver/rsdProgram.cpp18
-rw-r--r--libs/rs/driver/rsdShader.cpp126
-rw-r--r--libs/rs/driver/rsdShader.h35
-rw-r--r--libs/rs/driver/rsdShaderCache.cpp71
-rw-r--r--libs/rs/driver/rsdShaderCache.h6
-rw-r--r--libs/rs/rs.spec6
-rw-r--r--libs/rs/rsAllocation.cpp19
-rw-r--r--libs/rs/rsAllocation.h4
-rw-r--r--libs/rs/rsDefines.h7
-rw-r--r--libs/rs/scriptc/rs_allocation.rsh171
-rw-r--r--libs/rs/scriptc/rs_core.rsh31
-rw-r--r--libs/rs/scriptc/rs_element.rsh113
-rw-r--r--libs/rs/scriptc/rs_graphics.rsh150
-rw-r--r--libs/rs/scriptc/rs_mesh.rsh72
-rw-r--r--libs/rs/scriptc/rs_program.rsh129
-rw-r--r--libs/rs/scriptc/rs_sampler.rsh76
-rw-r--r--libs/rs/scriptc/rs_types.rsh6
21 files changed, 643 insertions, 424 deletions
diff --git a/libs/rs/Allocation.cpp b/libs/rs/Allocation.cpp
index d69c55f..e37d5de 100644
--- a/libs/rs/Allocation.cpp
+++ b/libs/rs/Allocation.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2012 The Android Open Source Project
+ * Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,17 +51,14 @@ Allocation::Allocation(void *id, RenderScript *rs, const Type *t, uint32_t usage
RS_ALLOCATION_USAGE_GRAPHICS_VERTEX |
RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS |
RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET |
- RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE |
RS_ALLOCATION_USAGE_IO_INPUT |
RS_ALLOCATION_USAGE_IO_OUTPUT)) != 0) {
ALOGE("Unknown usage specified.");
}
- if ((usage & (RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE |
- RS_ALLOCATION_USAGE_IO_INPUT)) != 0) {
+ if ((usage & RS_ALLOCATION_USAGE_IO_INPUT) != 0) {
mWriteAllowed = false;
- if ((usage & ~(RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE |
- RS_ALLOCATION_USAGE_IO_INPUT |
+ if ((usage & ~(RS_ALLOCATION_USAGE_IO_INPUT |
RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE |
RS_ALLOCATION_USAGE_SCRIPT)) != 0) {
ALOGE("Invalid usage combination.");
diff --git a/libs/rs/driver/rsdAllocation.cpp b/libs/rs/driver/rsdAllocation.cpp
index fb93d82..f358f93 100644
--- a/libs/rs/driver/rsdAllocation.cpp
+++ b/libs/rs/driver/rsdAllocation.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2011-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
#include "hardware/gralloc.h"
#include "ui/Rect.h"
#include "ui/GraphicBufferMapper.h"
+#include "gui/SurfaceTexture.h"
#include <GLES/gl.h>
#include <GLES2/gl2.h>
@@ -139,7 +140,7 @@ static void Upload2DTexture(const Context *rsc, const Allocation *alloc, bool is
static void UploadToTexture(const Context *rsc, const Allocation *alloc) {
DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE) {
+ if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_IO_INPUT) {
if (!drv->textureID) {
RSD_CALL_GL(glGenTextures, 1, &drv->textureID);
}
@@ -475,7 +476,8 @@ void rsdAllocationIoSend(const Context *rsc, Allocation *alloc) {
}
void rsdAllocationIoReceive(const Context *rsc, Allocation *alloc) {
- ALOGE("not implemented");
+ DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
+ alloc->mHal.state.surfaceTexture->updateTexImage();
}
diff --git a/libs/rs/driver/rsdCore.cpp b/libs/rs/driver/rsdCore.cpp
index 35a5c08..6a532e9 100644
--- a/libs/rs/driver/rsdCore.cpp
+++ b/libs/rs/driver/rsdCore.cpp
@@ -227,13 +227,13 @@ bool rsdHalInit(Context *rsc, uint32_t version_major, uint32_t version_minor) {
int cpu = sysconf(_SC_NPROCESSORS_ONLN);
- ALOGV("%p Launching thread(s), CPUs %i", rsc, cpu);
if(rsc->props.mDebugMaxThreads && (cpu > (int)rsc->props.mDebugMaxThreads)) {
cpu = rsc->props.mDebugMaxThreads;
}
if (cpu < 2) {
cpu = 0;
}
+ ALOGV("%p Launching thread(s), CPUs %i", rsc, cpu);
dc->mWorkers.mCount = (uint32_t)cpu;
dc->mWorkers.mThreadId = (pthread_t *) calloc(dc->mWorkers.mCount, sizeof(pthread_t));
diff --git a/libs/rs/driver/rsdGL.cpp b/libs/rs/driver/rsdGL.cpp
index fae602c..0860417 100644
--- a/libs/rs/driver/rsdGL.cpp
+++ b/libs/rs/driver/rsdGL.cpp
@@ -43,6 +43,7 @@
#include "rsdFrameBufferObj.h"
#include <gui/SurfaceTextureClient.h>
+#include <gui/DummyConsumer.h>
using namespace android;
using namespace android::renderscript;
@@ -326,8 +327,11 @@ bool rsdGLInit(const Context *rsc) {
}
gGLContextCount++;
- sp<SurfaceTexture> st(new SurfaceTexture(123));
- sp<SurfaceTextureClient> stc(new SurfaceTextureClient(st));
+ // Create a BufferQueue with a fake consumer
+ sp<BufferQueue> bq = new BufferQueue();
+ sp<DummyConsumer> dummy = new DummyConsumer(bq);
+ sp<SurfaceTextureClient> stc(new SurfaceTextureClient(static_cast<sp<ISurfaceTexture> >(bq)));
+
dc->gl.egl.surfaceDefault = eglCreateWindowSurface(dc->gl.egl.display, dc->gl.egl.config,
static_cast<ANativeWindow*>(stc.get()),
NULL);
diff --git a/libs/rs/driver/rsdProgram.cpp b/libs/rs/driver/rsdProgram.cpp
index fa4cb0f..a96a5f9 100644
--- a/libs/rs/driver/rsdProgram.cpp
+++ b/libs/rs/driver/rsdProgram.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2011-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ bool rsdProgramVertexInit(const Context *rsc, const ProgramVertex *pv,
textureNames, textureNamesCount, textureNamesLength);
pv->mHal.drv = drv;
- return drv->createShader();
+ return true;
}
static void SyncProgramConstants(const Context *rsc, const Program *p) {
@@ -71,10 +71,10 @@ void rsdProgramVertexDestroy(const Context *rsc, const ProgramVertex *pv) {
if(pv->mHal.drv) {
drv = (RsdShader*)pv->mHal.drv;
if (rsc->props.mLogShaders) {
- ALOGV("Destroying vertex shader with ID %u", drv->getShaderID());
+ ALOGV("Destroying vertex shader with ID %u", (uint32_t)pv);
}
- if (drv->getShaderID()) {
- dc->gl.shaderCache->cleanupVertex(drv->getShaderID());
+ if (drv->getStateBasedIDCount()) {
+ dc->gl.shaderCache->cleanupVertex(drv);
}
delete drv;
}
@@ -88,7 +88,7 @@ bool rsdProgramFragmentInit(const Context *rsc, const ProgramFragment *pf,
textureNames, textureNamesCount, textureNamesLength);
pf->mHal.drv = drv;
- return drv->createShader();
+ return true;
}
void rsdProgramFragmentSetActive(const Context *rsc, const ProgramFragment *pf) {
@@ -105,10 +105,10 @@ void rsdProgramFragmentDestroy(const Context *rsc, const ProgramFragment *pf) {
if(pf->mHal.drv) {
drv = (RsdShader*)pf->mHal.drv;
if (rsc->props.mLogShaders) {
- ALOGV("Destroying fragment shader with ID %u", drv->getShaderID());
+ ALOGV("Destroying fragment shader with ID %u", (uint32_t)pf);
}
- if (drv->getShaderID()) {
- dc->gl.shaderCache->cleanupFragment(drv->getShaderID());
+ if (drv->getStateBasedIDCount()) {
+ dc->gl.shaderCache->cleanupFragment(drv);
}
delete drv;
}
diff --git a/libs/rs/driver/rsdShader.cpp b/libs/rs/driver/rsdShader.cpp
index 1e73b95..6d9fa90 100644
--- a/libs/rs/driver/rsdShader.cpp
+++ b/libs/rs/driver/rsdShader.cpp
@@ -39,34 +39,81 @@ RsdShader::RsdShader(const Program *p, uint32_t type,
initMemberVars();
initAttribAndUniformArray();
init(textureNames, textureNamesCount, textureNamesLength);
- createTexturesString(textureNames, textureNamesCount, textureNamesLength);
+
+ for(size_t i=0; i < textureNamesCount; i++) {
+ mTextureNames.push(String8(textureNames[i], textureNamesLength[i]));
+ }
}
RsdShader::~RsdShader() {
- if (mShaderID) {
- glDeleteShader(mShaderID);
+ for (uint32_t i = 0; i < mStateBasedShaders.size(); i ++) {
+ StateBasedKey *state = mStateBasedShaders.itemAt(i);
+ if (state->mShaderID) {
+ glDeleteShader(state->mShaderID);
+ }
+ delete state;
}
delete[] mAttribNames;
delete[] mUniformNames;
delete[] mUniformArraySizes;
- delete[] mTextureTargets;
}
void RsdShader::initMemberVars() {
mDirty = true;
- mShaderID = 0;
mAttribCount = 0;
mUniformCount = 0;
mAttribNames = NULL;
mUniformNames = NULL;
mUniformArraySizes = NULL;
- mTextureTargets = NULL;
+ mCurrentState = NULL;
mIsValid = false;
}
+RsdShader::StateBasedKey *RsdShader::getExistingState() {
+ RsdShader::StateBasedKey *returnKey = NULL;
+
+ for (uint32_t i = 0; i < mStateBasedShaders.size(); i ++) {
+ returnKey = mStateBasedShaders.itemAt(i);
+
+ for (uint32_t ct = 0; ct < mRSProgram->mHal.state.texturesCount; ct ++) {
+ uint32_t texType = 0;
+ if (mRSProgram->mHal.state.textureTargets[ct] == RS_TEXTURE_2D) {
+ Allocation *a = mRSProgram->mHal.state.textures[ct];
+ if (a && a->mHal.state.surfaceTextureID) {
+ texType = GL_TEXTURE_EXTERNAL_OES;
+ } else {
+ texType = GL_TEXTURE_2D;
+ }
+ } else {
+ texType = GL_TEXTURE_CUBE_MAP;
+ }
+ if (texType != returnKey->mTextureTargets[ct]) {
+ returnKey = NULL;
+ break;
+ }
+ }
+ }
+ return returnKey;
+}
+
+uint32_t RsdShader::getStateBasedShaderID(const Context *rsc) {
+ StateBasedKey *state = getExistingState();
+ if (state != NULL) {
+ mCurrentState = state;
+ return mCurrentState->mShaderID;
+ }
+ // We have not created a shader for this particular state yet
+ state = new StateBasedKey(mTextureCount);
+ mCurrentState = state;
+ mStateBasedShaders.add(state);
+ createShader();
+ loadShader(rsc);
+ return mCurrentState->mShaderID;
+}
+
void RsdShader::init(const char** textureNames, size_t textureNamesCount,
const size_t *textureNamesLength) {
uint32_t attribCount = 0;
@@ -138,70 +185,80 @@ void RsdShader::appendAttributes() {
}
}
-void RsdShader::createTexturesString(const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength) {
- mShaderTextures.setTo("");
+void RsdShader::appendTextures() {
+
+ // TODO: this does not yet handle cases where the texture changes between IO
+ // input and local
+ bool appendUsing = true;
for (uint32_t ct = 0; ct < mRSProgram->mHal.state.texturesCount; ct ++) {
if (mRSProgram->mHal.state.textureTargets[ct] == RS_TEXTURE_2D) {
Allocation *a = mRSProgram->mHal.state.textures[ct];
if (a && a->mHal.state.surfaceTextureID) {
- mShaderTextures.append("uniform samplerExternalOES UNI_");
+ if(appendUsing) {
+ mShader.append("#extension GL_OES_EGL_image_external : require\n");
+ appendUsing = false;
+ }
+ mShader.append("uniform samplerExternalOES UNI_");
+ mCurrentState->mTextureTargets[ct] = GL_TEXTURE_EXTERNAL_OES;
} else {
- mShaderTextures.append("uniform sampler2D UNI_");
+ mShader.append("uniform sampler2D UNI_");
+ mCurrentState->mTextureTargets[ct] = GL_TEXTURE_2D;
}
- mTextureTargets[ct] = GL_TEXTURE_2D;
} else {
- mShaderTextures.append("uniform samplerCube UNI_");
- mTextureTargets[ct] = GL_TEXTURE_CUBE_MAP;
+ mShader.append("uniform samplerCube UNI_");
+ mCurrentState->mTextureTargets[ct] = GL_TEXTURE_CUBE_MAP;
}
- mShaderTextures.append(textureNames[ct], textureNamesLength[ct]);
- mShaderTextures.append(";\n");
+ mShader.append(mTextureNames[ct]);
+ mShader.append(";\n");
}
}
bool RsdShader::createShader() {
-
+ mShader.clear();
if (mType == GL_FRAGMENT_SHADER) {
mShader.append("precision mediump float;\n");
}
appendUserConstants();
appendAttributes();
- mShader.append(mShaderTextures);
-
+ appendTextures();
mShader.append(mUserShader);
return true;
}
bool RsdShader::loadShader(const Context *rsc) {
- mShaderID = glCreateShader(mType);
- rsAssert(mShaderID);
+ mCurrentState->mShaderID = glCreateShader(mType);
+ rsAssert(mCurrentState->mShaderID);
+
+ if(!mShader.length()) {
+ createShader();
+ }
if (rsc->props.mLogShaders) {
- ALOGV("Loading shader type %x, ID %i", mType, mShaderID);
+ ALOGV("Loading shader type %x, ID %i", mType, mCurrentState->mShaderID);
ALOGV("%s", mShader.string());
}
- if (mShaderID) {
+ if (mCurrentState->mShaderID) {
const char * ss = mShader.string();
- RSD_CALL_GL(glShaderSource, mShaderID, 1, &ss, NULL);
- RSD_CALL_GL(glCompileShader, mShaderID);
+ RSD_CALL_GL(glShaderSource, mCurrentState->mShaderID, 1, &ss, NULL);
+ RSD_CALL_GL(glCompileShader, mCurrentState->mShaderID);
GLint compiled = 0;
- RSD_CALL_GL(glGetShaderiv, mShaderID, GL_COMPILE_STATUS, &compiled);
+ RSD_CALL_GL(glGetShaderiv, mCurrentState->mShaderID, GL_COMPILE_STATUS, &compiled);
if (!compiled) {
GLint infoLen = 0;
- RSD_CALL_GL(glGetShaderiv, mShaderID, GL_INFO_LOG_LENGTH, &infoLen);
+ RSD_CALL_GL(glGetShaderiv, mCurrentState->mShaderID, GL_INFO_LOG_LENGTH, &infoLen);
if (infoLen) {
char* buf = (char*) malloc(infoLen);
if (buf) {
- RSD_CALL_GL(glGetShaderInfoLog, mShaderID, infoLen, NULL, buf);
+ RSD_CALL_GL(glGetShaderInfoLog, mCurrentState->mShaderID, infoLen, NULL, buf);
rsc->setError(RS_ERROR_FATAL_PROGRAM_LINK, buf);
free(buf);
}
- RSD_CALL_GL(glDeleteShader, mShaderID);
- mShaderID = 0;
+ RSD_CALL_GL(glDeleteShader, mCurrentState->mShaderID);
+ mCurrentState->mShaderID = 0;
return false;
}
}
@@ -418,12 +475,14 @@ void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) {
if (!mRSProgram->mHal.state.textures[ct]) {
// if nothing is bound, reset to default GL texture
- RSD_CALL_GL(glBindTexture, mTextureTargets[ct], 0);
+ RSD_CALL_GL(glBindTexture, mCurrentState->mTextureTargets[ct], 0);
continue;
}
DrvAllocation *drvTex = (DrvAllocation *)mRSProgram->mHal.state.textures[ct]->mHal.drv;
- if (drvTex->glTarget != GL_TEXTURE_2D && drvTex->glTarget != GL_TEXTURE_CUBE_MAP) {
+ if (drvTex->glTarget != GL_TEXTURE_2D &&
+ drvTex->glTarget != GL_TEXTURE_CUBE_MAP &&
+ drvTex->glTarget != GL_TEXTURE_EXTERNAL_OES) {
ALOGE("Attempting to bind unknown texture to shader id %u, texture unit %u",
(uint)this, ct);
rsc->setError(RS_ERROR_BAD_SHADER, "Non-texture allocation bound to a shader");
@@ -523,9 +582,6 @@ void RsdShader::initAttribAndUniformArray() {
}
mTextureCount = mRSProgram->mHal.state.texturesCount;
- if (mTextureCount) {
- mTextureTargets = new uint32_t[mTextureCount];
- }
}
void RsdShader::initAddUserElement(const Element *e, String8 *names, uint32_t *arrayLengths,
diff --git a/libs/rs/driver/rsdShader.h b/libs/rs/driver/rsdShader.h
index e32145f..2680b3e 100644
--- a/libs/rs/driver/rsdShader.h
+++ b/libs/rs/driver/rsdShader.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2011-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,9 +44,13 @@ public:
const size_t *textureNamesLength);
virtual ~RsdShader();
- bool createShader();
+ uint32_t getStateBasedShaderID(const android::renderscript::Context *);
- uint32_t getShaderID() const {return mShaderID;}
+ // Add ability to get all ID's to clean up the cached program objects
+ uint32_t getStateBasedIDCount() const { return mStateBasedShaders.size(); }
+ uint32_t getStateBasedID(uint32_t index) const {
+ return mStateBasedShaders.itemAt(index)->mShaderID;
+ }
uint32_t getAttribCount() const {return mAttribCount;}
uint32_t getUniformCount() const {return mUniformCount;}
@@ -64,6 +68,21 @@ public:
protected:
+ class StateBasedKey {
+ public:
+ StateBasedKey(uint32_t texCount) : mShaderID(0) {
+ mTextureTargets = new uint32_t[texCount];
+ }
+ ~StateBasedKey() {
+ delete[] mTextureTargets;
+ }
+ uint32_t mShaderID;
+ uint32_t *mTextureTargets;
+ };
+
+ bool createShader();
+ StateBasedKey *getExistingState();
+
const android::renderscript::Program *mRSProgram;
bool mIsValid;
@@ -81,26 +100,26 @@ protected:
void appendAttributes();
void appendTextures();
- void createTexturesString(const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength);
void initAttribAndUniformArray();
mutable bool mDirty;
android::String8 mShader;
android::String8 mUserShader;
- android::String8 mShaderTextures;
- uint32_t mShaderID;
uint32_t mType;
uint32_t mTextureCount;
- uint32_t *mTextureTargets;
+ StateBasedKey *mCurrentState;
uint32_t mAttribCount;
uint32_t mUniformCount;
android::String8 *mAttribNames;
android::String8 *mUniformNames;
uint32_t *mUniformArraySizes;
+ android::Vector<android::String8> mTextureNames;
+
+ android::Vector<StateBasedKey*> mStateBasedShaders;
+
int32_t mTextureUniformIndexStart;
void logUniform(const android::renderscript::Element *field,
diff --git a/libs/rs/driver/rsdShaderCache.cpp b/libs/rs/driver/rsdShaderCache.cpp
index 89d3c45..69b43fc 100644
--- a/libs/rs/driver/rsdShaderCache.cpp
+++ b/libs/rs/driver/rsdShaderCache.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2011-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -108,22 +108,17 @@ bool RsdShaderCache::link(const Context *rsc) {
RsdShader *vtx = mVertex;
RsdShader *frag = mFragment;
- if (!vtx->getShaderID()) {
- vtx->loadShader(rsc);
- }
- if (!frag->getShaderID()) {
- frag->loadShader(rsc);
- }
+
+ uint32_t vID = vtx->getStateBasedShaderID(rsc);
+ uint32_t fID = frag->getStateBasedShaderID(rsc);
// Don't try to cache if shaders failed to load
- if (!vtx->getShaderID() || !frag->getShaderID()) {
+ if (!vID || !fID) {
return false;
}
- //ALOGV("rsdShaderCache lookup vtx %i, frag %i", vtx->getShaderID(), frag->getShaderID());
uint32_t entryCount = mEntries.size();
for (uint32_t ct = 0; ct < entryCount; ct ++) {
- if ((mEntries[ct]->vtx == vtx->getShaderID()) &&
- (mEntries[ct]->frag == frag->getShaderID())) {
+ if ((mEntries[ct]->vtx == vID) && (mEntries[ct]->frag == fID)) {
//ALOGV("SC using program %i", mEntries[ct]->program);
glUseProgram(mEntries[ct]->program);
@@ -134,21 +129,19 @@ bool RsdShaderCache::link(const Context *rsc) {
}
}
- //ALOGV("RsdShaderCache miss");
- //ALOGE("e0 %x", glGetError());
ProgramEntry *e = new ProgramEntry(vtx->getAttribCount(),
vtx->getUniformCount(),
frag->getUniformCount());
mEntries.push(e);
mCurrent = e;
- e->vtx = vtx->getShaderID();
- e->frag = frag->getShaderID();
+ e->vtx = vID;
+ e->frag = fID;
e->program = glCreateProgram();
if (e->program) {
GLuint pgm = e->program;
- glAttachShader(pgm, vtx->getShaderID());
+ glAttachShader(pgm, vID);
//ALOGE("e1 %x", glGetError());
- glAttachShader(pgm, frag->getShaderID());
+ glAttachShader(pgm, fID);
glBindAttribLocation(pgm, 0, "ATTRIB_position");
glBindAttribLocation(pgm, 1, "ATTRIB_color");
@@ -244,30 +237,38 @@ int32_t RsdShaderCache::vtxAttribSlot(const String8 &attrName) const {
return -1;
}
-void RsdShaderCache::cleanupVertex(uint32_t id) {
+void RsdShaderCache::cleanupVertex(RsdShader *s) {
int32_t numEntries = (int32_t)mEntries.size();
- for (int32_t ct = 0; ct < numEntries; ct ++) {
- if (mEntries[ct]->vtx == id) {
- glDeleteProgram(mEntries[ct]->program);
-
- delete mEntries[ct];
- mEntries.removeAt(ct);
- numEntries = (int32_t)mEntries.size();
- ct --;
+ uint32_t numShaderIDs = s->getStateBasedIDCount();
+ for (uint32_t sId = 0; sId < numShaderIDs; sId ++) {
+ uint32_t id = s->getStateBasedID(sId);
+ for (int32_t ct = 0; ct < numEntries; ct ++) {
+ if (mEntries[ct]->vtx == id) {
+ glDeleteProgram(mEntries[ct]->program);
+
+ delete mEntries[ct];
+ mEntries.removeAt(ct);
+ numEntries = (int32_t)mEntries.size();
+ ct --;
+ }
}
}
}
-void RsdShaderCache::cleanupFragment(uint32_t id) {
+void RsdShaderCache::cleanupFragment(RsdShader *s) {
int32_t numEntries = (int32_t)mEntries.size();
- for (int32_t ct = 0; ct < numEntries; ct ++) {
- if (mEntries[ct]->frag == id) {
- glDeleteProgram(mEntries[ct]->program);
-
- delete mEntries[ct];
- mEntries.removeAt(ct);
- numEntries = (int32_t)mEntries.size();
- ct --;
+ uint32_t numShaderIDs = s->getStateBasedIDCount();
+ for (uint32_t sId = 0; sId < numShaderIDs; sId ++) {
+ uint32_t id = s->getStateBasedID(sId);
+ for (int32_t ct = 0; ct < numEntries; ct ++) {
+ if (mEntries[ct]->frag == id) {
+ glDeleteProgram(mEntries[ct]->program);
+
+ delete mEntries[ct];
+ mEntries.removeAt(ct);
+ numEntries = (int32_t)mEntries.size();
+ ct --;
+ }
}
}
}
diff --git a/libs/rs/driver/rsdShaderCache.h b/libs/rs/driver/rsdShaderCache.h
index 0beecae..88aa32d 100644
--- a/libs/rs/driver/rsdShaderCache.h
+++ b/libs/rs/driver/rsdShaderCache.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2011-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,8 +49,8 @@ public:
bool setup(const android::renderscript::Context *rsc);
- void cleanupVertex(uint32_t id);
- void cleanupFragment(uint32_t id);
+ void cleanupVertex(RsdShader *s);
+ void cleanupFragment(RsdShader *s);
void cleanupAll();
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index cf4a391..b373056 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -69,6 +69,12 @@ AllocationGetSurfaceTextureID {
ret int32_t
}
+AllocationGetSurfaceTextureID2 {
+ param RsAllocation alloc
+ param void *st
+ sync
+}
+
AllocationSetSurface {
param RsAllocation alloc
param RsNativeWindow sur
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index a404c49..cdff49c 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -20,6 +20,7 @@
#include "rs_hal.h"
#include "system/window.h"
+#include "gui/SurfaceTexture.h"
using namespace android;
using namespace android::renderscript;
@@ -64,6 +65,7 @@ void Allocation::updateCache() {
Allocation::~Allocation() {
freeChildrenUnlocked();
+ setSurfaceTexture(mRSC, NULL);
mRSC->mHal.funcs.allocation.destroy(mRSC, this);
}
@@ -424,6 +426,18 @@ int32_t Allocation::getSurfaceTextureID(const Context *rsc) {
return id;
}
+void Allocation::setSurfaceTexture(const Context *rsc, SurfaceTexture *st) {
+ if(st != mHal.state.surfaceTexture) {
+ if(mHal.state.surfaceTexture != NULL) {
+ mHal.state.surfaceTexture->decStrong(NULL);
+ }
+ mHal.state.surfaceTexture = st;
+ if(mHal.state.surfaceTexture != NULL) {
+ mHal.state.surfaceTexture->incStrong(NULL);
+ }
+ }
+}
+
void Allocation::setSurface(const Context *rsc, RsNativeWindow sur) {
ANativeWindow *nw = (ANativeWindow *)sur;
ANativeWindow *old = mHal.state.wndSurface;
@@ -696,6 +710,11 @@ int32_t rsi_AllocationGetSurfaceTextureID(Context *rsc, RsAllocation valloc) {
return alloc->getSurfaceTextureID(rsc);
}
+void rsi_AllocationGetSurfaceTextureID2(Context *rsc, RsAllocation valloc, void *vst, size_t len) {
+ Allocation *alloc = static_cast<Allocation *>(valloc);
+ alloc->setSurfaceTexture(rsc, static_cast<SurfaceTexture *>(vst));
+}
+
void rsi_AllocationSetSurface(Context *rsc, RsAllocation valloc, RsNativeWindow sur) {
Allocation *alloc = static_cast<Allocation *>(valloc);
alloc->setSurface(rsc, sur);
diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h
index 58a6fca..e2783d2 100644
--- a/libs/rs/rsAllocation.h
+++ b/libs/rs/rsAllocation.h
@@ -23,6 +23,8 @@ struct ANativeWindow;
// ---------------------------------------------------------------------------
namespace android {
+class SurfaceTexture;
+
namespace renderscript {
class Program;
@@ -60,6 +62,7 @@ public:
void * usrPtr;
int32_t surfaceTextureID;
ANativeWindow *wndSurface;
+ SurfaceTexture *surfaceTexture;
};
State state;
@@ -130,6 +133,7 @@ public:
}
int32_t getSurfaceTextureID(const Context *rsc);
+ void setSurfaceTexture(const Context *rsc, SurfaceTexture *st);
void setSurface(const Context *rsc, RsNativeWindow sur);
void ioSend(const Context *rsc);
void ioReceive(const Context *rsc);
diff --git a/libs/rs/rsDefines.h b/libs/rs/rsDefines.h
index 990ef26..0e0cd8d 100644
--- a/libs/rs/rsDefines.h
+++ b/libs/rs/rsDefines.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 The Android Open Source Project
+ * Copyright (C) 2007-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -100,9 +100,8 @@ enum RsAllocationUsageType {
RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010,
- RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE = 0x0020,
- RS_ALLOCATION_USAGE_IO_INPUT = 0x0040,
- RS_ALLOCATION_USAGE_IO_OUTPUT = 0x0080,
+ RS_ALLOCATION_USAGE_IO_INPUT = 0x0020,
+ RS_ALLOCATION_USAGE_IO_OUTPUT = 0x0040,
RS_ALLOCATION_USAGE_ALL = 0x00FF
};
diff --git a/libs/rs/scriptc/rs_allocation.rsh b/libs/rs/scriptc/rs_allocation.rsh
index 89696b8..b0840a0 100644
--- a/libs/rs/scriptc/rs_allocation.rsh
+++ b/libs/rs/scriptc/rs_allocation.rsh
@@ -14,31 +14,6 @@
* limitations under the License.
*/
-/*! \mainpage notitle
- *
- * Renderscript is a high-performance runtime that provides graphics rendering and
- * compute operations at the native level. Renderscript code is compiled on devices
- * at runtime to allow platform-independence as well.
- * This reference documentation describes the Renderscript runtime APIs, which you
- * can utilize to write Renderscript code in C99. The Renderscript header
- * files are automatically included for you, except for the rs_graphics.rsh header. If
- * you are doing graphics rendering, include the graphics header file like this:
- *
- * <code>#include "rs_graphics.rsh"</code>
- *
- * To use Renderscript, you need to utilize the Renderscript runtime APIs documented here
- * as well as the Android framework APIs for Renderscript.
- * For documentation on the Android framework APIs, see the <a target="_parent" href=
- * "http://developer.android.com/reference/android/renderscript/package-summary.html">
- * android.renderscript</a> package reference.
- * For more information on how to develop with Renderscript and how the runtime and
- * Android framework APIs interact, see the <a target="_parent" href=
- * "http://developer.android.com/guide/topics/renderscript/index.html">Renderscript
- * developer guide</a> and the <a target="_parent" href=
- * "http://developer.android.com/resources/samples/RenderScript/index.html">
- * Renderscript samples</a>.
- */
-
/** @file rs_allocation.rsh
* \brief Allocation routines
*
@@ -168,6 +143,8 @@ extern const void * __attribute__((overloadable))
extern const void * __attribute__((overloadable))
rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+
/**
* @param a allocation to get data from
* @return element describing allocation layout
@@ -176,129 +153,6 @@ extern rs_element __attribute__((overloadable))
rsAllocationGetElement(rs_allocation a);
/**
- * @param m mesh to get data from
- * @return number of allocations in the mesh that contain vertex
- * data
- */
-extern uint32_t __attribute__((overloadable))
- rsMeshGetVertexAllocationCount(rs_mesh m);
-
-/**
- * @param m mesh to get data from
- * @return number of primitive groups in the mesh. This would
- * include simple primitives as well as allocations
- * containing index data
- */
-extern uint32_t __attribute__((overloadable))
- rsMeshGetPrimitiveCount(rs_mesh m);
-
-/**
- * @param m mesh to get data from
- * @param index index of the vertex allocation
- * @return allocation containing vertex data
- */
-extern rs_allocation __attribute__((overloadable))
- rsMeshGetVertexAllocation(rs_mesh m, uint32_t index);
-
-/**
- * @param m mesh to get data from
- * @param index index of the index allocation
- * @return allocation containing index data
- */
-extern rs_allocation __attribute__((overloadable))
- rsMeshGetIndexAllocation(rs_mesh m, uint32_t index);
-
-/**
- * @param m mesh to get data from
- * @param index index of the primitive
- * @return primitive describing how the mesh is rendered
- */
-extern rs_primitive __attribute__((overloadable))
- rsMeshGetPrimitive(rs_mesh m, uint32_t index);
-
-/**
- * @param e element to get data from
- * @return number of sub-elements in this element
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementCount(rs_element e);
-
-/**
- * @param e element to get data from
- * @param index index of the sub-element to return
- * @return sub-element in this element at given index
- */
-extern rs_element __attribute__((overloadable))
- rsElementGetSubElement(rs_element, uint32_t index);
-
-/**
- * @param e element to get data from
- * @param index index of the sub-element to return
- * @return length of the sub-element name including the null
- * terminator (size of buffer needed to write the name)
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementNameLength(rs_element e, uint32_t index);
-
-/**
- * @param e element to get data from
- * @param index index of the sub-element
- * @param name array to store the name into
- * @param nameLength length of the provided name array
- * @return number of characters actually written, excluding the
- * null terminator
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementName(rs_element e, uint32_t index, char *name, uint32_t nameLength);
-
-/**
- * @param e element to get data from
- * @param index index of the sub-element
- * @return array size of sub-element in this element at given
- * index
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementArraySize(rs_element e, uint32_t index);
-
-/**
- * @param e element to get data from
- * @param index index of the sub-element
- * @return offset in bytes of sub-element in this element at
- * given index
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementOffsetBytes(rs_element e, uint32_t index);
-
-/**
- * @param e element to get data from
- * @return total size of the element in bytes
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSizeBytes(rs_element e);
-
-/**
- * @param e element to get data from
- * @return element's data type
- */
-extern rs_data_type __attribute__((overloadable))
- rsElementGetDataType(rs_element e);
-
-/**
- * @param e element to get data from
- * @return element's data size
- */
-extern rs_data_kind __attribute__((overloadable))
- rsElementGetDataKind(rs_element e);
-
-/**
- * @param e element to get data from
- * @return length of the element vector (for float2, float3,
- * etc.)
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetVectorSize(rs_element e);
-
-/**
* Fetch allocation in a way described by the sampler
* @param a 1D allocation to sample from
* @param s sampler state
@@ -339,26 +193,7 @@ extern const float4 __attribute__((overloadable))
extern const float4 __attribute__((overloadable))
rsSample(rs_allocation a, rs_sampler s, float2 location, float lod);
-/**
- * Fetch allocation in a way described by the sampler
- * @param a 3D allocation to sample from
- * @param s sampler state
- * @param location to sample from
- */
-extern const float4 __attribute__((overloadable))
- rsSample(rs_allocation a, rs_sampler s, float3 location);
-
-/**
- * Fetch allocation in a way described by the sampler
- * @param a 3D allocation to sample from
- * @param s sampler state
- * @param location to sample from
- * @param lod mip level to sample from, for fractional values
- * mip levels will be interpolated if
- * RS_SAMPLER_LINEAR_MIP_LINEAR is used
- */
-extern const float4 __attribute__((overloadable))
- rsSample(rs_allocation a, rs_sampler s, float3 location, float lod);
+#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
#endif
diff --git a/libs/rs/scriptc/rs_core.rsh b/libs/rs/scriptc/rs_core.rsh
index be900cb..1b0f9db 100644
--- a/libs/rs/scriptc/rs_core.rsh
+++ b/libs/rs/scriptc/rs_core.rsh
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2011-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,6 +14,31 @@
* limitations under the License.
*/
+ /*! \mainpage notitle
+ *
+ * Renderscript is a high-performance runtime that provides graphics rendering and
+ * compute operations at the native level. Renderscript code is compiled on devices
+ * at runtime to allow platform-independence as well.
+ * This reference documentation describes the Renderscript runtime APIs, which you
+ * can utilize to write Renderscript code in C99. The Renderscript header
+ * files are automatically included for you, except for the rs_graphics.rsh header. If
+ * you are doing graphics rendering, include the graphics header file like this:
+ *
+ * <code>#include "rs_graphics.rsh"</code>
+ *
+ * To use Renderscript, you need to utilize the Renderscript runtime APIs documented here
+ * as well as the Android framework APIs for Renderscript.
+ * For documentation on the Android framework APIs, see the <a target="_parent" href=
+ * "http://developer.android.com/reference/android/renderscript/package-summary.html">
+ * android.renderscript</a> package reference.
+ * For more information on how to develop with Renderscript and how the runtime and
+ * Android framework APIs interact, see the <a target="_parent" href=
+ * "http://developer.android.com/guide/topics/renderscript/index.html">Renderscript
+ * developer guide</a> and the <a target="_parent" href=
+ * "http://developer.android.com/resources/samples/RenderScript/index.html">
+ * Renderscript samples</a>.
+ */
+
/** @file rs_core.rsh
* \brief todo-jsams
*
@@ -31,14 +56,14 @@
#include "rs_atomic.rsh"
#include "rs_cl.rsh"
#include "rs_debug.rsh"
+#include "rs_element.rsh"
#include "rs_math.rsh"
#include "rs_matrix.rsh"
#include "rs_object.rsh"
#include "rs_quaternion.rsh"
+#include "rs_sampler.rsh"
#include "rs_time.rsh"
-
-
/**
* Send a message back to the client. Will not block and returns true
* if the message was sendable and false if the fifo was full.
diff --git a/libs/rs/scriptc/rs_element.rsh b/libs/rs/scriptc/rs_element.rsh
new file mode 100644
index 0000000..1a4cdb75
--- /dev/null
+++ b/libs/rs/scriptc/rs_element.rsh
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_element.rsh
+ * \brief Element routines
+ *
+ *
+ */
+
+#ifndef __RS_ELEMENT_RSH__
+#define __RS_ELEMENT_RSH__
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+
+/**
+ * @param e element to get data from
+ * @return number of sub-elements in this element
+ */
+extern uint32_t __attribute__((overloadable))
+ rsElementGetSubElementCount(rs_element e);
+
+/**
+ * @param e element to get data from
+ * @param index index of the sub-element to return
+ * @return sub-element in this element at given index
+ */
+extern rs_element __attribute__((overloadable))
+ rsElementGetSubElement(rs_element, uint32_t index);
+
+/**
+ * @param e element to get data from
+ * @param index index of the sub-element to return
+ * @return length of the sub-element name including the null
+ * terminator (size of buffer needed to write the name)
+ */
+extern uint32_t __attribute__((overloadable))
+ rsElementGetSubElementNameLength(rs_element e, uint32_t index);
+
+/**
+ * @param e element to get data from
+ * @param index index of the sub-element
+ * @param name array to store the name into
+ * @param nameLength length of the provided name array
+ * @return number of characters actually written, excluding the
+ * null terminator
+ */
+extern uint32_t __attribute__((overloadable))
+ rsElementGetSubElementName(rs_element e, uint32_t index, char *name, uint32_t nameLength);
+
+/**
+ * @param e element to get data from
+ * @param index index of the sub-element
+ * @return array size of sub-element in this element at given
+ * index
+ */
+extern uint32_t __attribute__((overloadable))
+ rsElementGetSubElementArraySize(rs_element e, uint32_t index);
+
+/**
+ * @param e element to get data from
+ * @param index index of the sub-element
+ * @return offset in bytes of sub-element in this element at
+ * given index
+ */
+extern uint32_t __attribute__((overloadable))
+ rsElementGetSubElementOffsetBytes(rs_element e, uint32_t index);
+
+/**
+ * @param e element to get data from
+ * @return total size of the element in bytes
+ */
+extern uint32_t __attribute__((overloadable))
+ rsElementGetSizeBytes(rs_element e);
+
+/**
+ * @param e element to get data from
+ * @return element's data type
+ */
+extern rs_data_type __attribute__((overloadable))
+ rsElementGetDataType(rs_element e);
+
+/**
+ * @param e element to get data from
+ * @return element's data size
+ */
+extern rs_data_kind __attribute__((overloadable))
+ rsElementGetDataKind(rs_element e);
+
+/**
+ * @param e element to get data from
+ * @return length of the element vector (for float2, float3,
+ * etc.)
+ */
+extern uint32_t __attribute__((overloadable))
+ rsElementGetVectorSize(rs_element e);
+
+#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
+
+#endif // __RS_ELEMENT_RSH__
+
diff --git a/libs/rs/scriptc/rs_graphics.rsh b/libs/rs/scriptc/rs_graphics.rsh
index e3fde82..44ee99f 100644
--- a/libs/rs/scriptc/rs_graphics.rsh
+++ b/libs/rs/scriptc/rs_graphics.rsh
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2011-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,9 @@
#ifndef __RS_GRAPHICS_RSH__
#define __RS_GRAPHICS_RSH__
+#include "rs_mesh.rsh"
+#include "rs_program.rsh"
+
#if (defined(RS_VERSION) && (RS_VERSION >= 14))
/**
* Set the color target used for all subsequent rendering calls
@@ -83,88 +86,6 @@ extern void __attribute__((overloadable))
extern void __attribute__((overloadable))
rsgBindProgramStore(rs_program_store ps);
-
-/**
- * @hide
- * Get program store depth function
- *
- * @param ps
- */
-extern rs_depth_func __attribute__((overloadable))
- rsgProgramStoreGetDepthFunc(rs_program_store ps);
-
-/**
- * @hide
- * Get program store depth mask
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetDepthMask(rs_program_store ps);
-/**
- * @hide
- * Get program store red component color mask
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetColorMaskR(rs_program_store ps);
-
-/**
- * @hide
- * Get program store green component color mask
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetColorMaskG(rs_program_store ps);
-
-/**
- * @hide
- * Get program store blur component color mask
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetColorMaskB(rs_program_store ps);
-
-/**
- * @hide
- * Get program store alpha component color mask
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetColorMaskA(rs_program_store ps);
-
-/**
- * @hide
- * Get program store blend source function
- *
- * @param ps
- */
-extern rs_blend_src_func __attribute__((overloadable))
- rsgProgramStoreGetBlendSrcFunc(rs_program_store ps);
-
-/**
- * @hide
- * Get program store blend destination function
- *
- * @param ps
- */
-extern rs_blend_dst_func __attribute__((overloadable))
- rsgProgramStoreGetBlendDstFunc(rs_program_store ps);
-
-/**
- * @hide
- * Get program store dither state
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetDitherEnabled(rs_program_store ps);
-
-
/**
* Bind a new ProgramVertex to the rendering context.
*
@@ -182,24 +103,6 @@ extern void __attribute__((overloadable))
rsgBindProgramRaster(rs_program_raster pr);
/**
- * @hide
- * Get program raster point sprite state
- *
- * @param pr
- */
-extern bool __attribute__((overloadable))
- rsgProgramRasterGetPointSpriteEnabled(rs_program_raster pr);
-
-/**
- * @hide
- * Get program raster cull mode
- *
- * @param pr
- */
-extern rs_cull_mode __attribute__((overloadable))
- rsgProgramRasterGetCullMode(rs_program_raster pr);
-
-/**
* Bind a new Sampler object to a ProgramFragment. The sampler will
* operate on the texture bound at the matching slot.
*
@@ -209,51 +112,6 @@ extern void __attribute__((overloadable))
rsgBindSampler(rs_program_fragment, uint slot, rs_sampler);
/**
- * @hide
- * Get sampler minification value
- *
- * @param pr
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsgSamplerGetMinification(rs_sampler s);
-
-/**
- * @hide
- * Get sampler magnification value
- *
- * @param pr
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsgSamplerGetMagnification(rs_sampler s);
-
-/**
- * @hide
- * Get sampler wrap S value
- *
- * @param pr
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsgSamplerGetWrapS(rs_sampler s);
-
-/**
- * @hide
- * Get sampler wrap T value
- *
- * @param pr
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsgSamplerGetWrapT(rs_sampler s);
-
-/**
- * @hide
- * Get sampler anisotropy
- *
- * @param pr
- */
-extern float __attribute__((overloadable))
- rsgSamplerGetAnisotropy(rs_sampler s);
-
-/**
* Bind a new Allocation object to a ProgramFragment. The
* Allocation must be a valid texture for the Program. The sampling
* of the texture will be controled by the Sampler bound at the
diff --git a/libs/rs/scriptc/rs_mesh.rsh b/libs/rs/scriptc/rs_mesh.rsh
new file mode 100644
index 0000000..87ffd33
--- /dev/null
+++ b/libs/rs/scriptc/rs_mesh.rsh
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_mesh.rsh
+ * \brief Mesh routines
+ *
+ *
+ */
+
+#ifndef __RS_MESH_RSH__
+#define __RS_MESH_RSH__
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+
+/**
+ * @param m mesh to get data from
+ * @return number of allocations in the mesh that contain vertex
+ * data
+ */
+extern uint32_t __attribute__((overloadable))
+ rsgMeshGetVertexAllocationCount(rs_mesh m);
+
+/**
+ * @param m mesh to get data from
+ * @return number of primitive groups in the mesh. This would
+ * include simple primitives as well as allocations
+ * containing index data
+ */
+extern uint32_t __attribute__((overloadable))
+ rsgMeshGetPrimitiveCount(rs_mesh m);
+
+/**
+ * @param m mesh to get data from
+ * @param index index of the vertex allocation
+ * @return allocation containing vertex data
+ */
+extern rs_allocation __attribute__((overloadable))
+ rsgMeshGetVertexAllocation(rs_mesh m, uint32_t index);
+
+/**
+ * @param m mesh to get data from
+ * @param index index of the index allocation
+ * @return allocation containing index data
+ */
+extern rs_allocation __attribute__((overloadable))
+ rsgMeshGetIndexAllocation(rs_mesh m, uint32_t index);
+
+/**
+ * @param m mesh to get data from
+ * @param index index of the primitive
+ * @return primitive describing how the mesh is rendered
+ */
+extern rs_primitive __attribute__((overloadable))
+ rsgMeshGetPrimitive(rs_mesh m, uint32_t index);
+
+#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
+
+#endif // __RS_MESH_RSH__
+
diff --git a/libs/rs/scriptc/rs_program.rsh b/libs/rs/scriptc/rs_program.rsh
new file mode 100644
index 0000000..6a9929e
--- /dev/null
+++ b/libs/rs/scriptc/rs_program.rsh
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_program.rsh
+ * \brief Program object routines
+ *
+ *
+ */
+
+#ifndef __RS_PROGRAM_RSH__
+#define __RS_PROGRAM_RSH__
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+
+/**
+ * @hide
+ * Get program store depth function
+ *
+ * @param ps
+ */
+extern rs_depth_func __attribute__((overloadable))
+ rsgProgramStoreGetDepthFunc(rs_program_store ps);
+
+/**
+ * @hide
+ * Get program store depth mask
+ *
+ * @param ps
+ */
+extern bool __attribute__((overloadable))
+ rsgProgramStoreGetDepthMask(rs_program_store ps);
+/**
+ * @hide
+ * Get program store red component color mask
+ *
+ * @param ps
+ */
+extern bool __attribute__((overloadable))
+ rsgProgramStoreGetColorMaskR(rs_program_store ps);
+
+/**
+ * @hide
+ * Get program store green component color mask
+ *
+ * @param ps
+ */
+extern bool __attribute__((overloadable))
+ rsgProgramStoreGetColorMaskG(rs_program_store ps);
+
+/**
+ * @hide
+ * Get program store blur component color mask
+ *
+ * @param ps
+ */
+extern bool __attribute__((overloadable))
+ rsgProgramStoreGetColorMaskB(rs_program_store ps);
+
+/**
+ * @hide
+ * Get program store alpha component color mask
+ *
+ * @param ps
+ */
+extern bool __attribute__((overloadable))
+ rsgProgramStoreGetColorMaskA(rs_program_store ps);
+
+/**
+ * @hide
+ * Get program store blend source function
+ *
+ * @param ps
+ */
+extern rs_blend_src_func __attribute__((overloadable))
+ rsgProgramStoreGetBlendSrcFunc(rs_program_store ps);
+
+/**
+ * @hide
+ * Get program store blend destination function
+ *
+ * @param ps
+ */
+extern rs_blend_dst_func __attribute__((overloadable))
+ rsgProgramStoreGetBlendDstFunc(rs_program_store ps);
+
+/**
+ * @hide
+ * Get program store dither state
+ *
+ * @param ps
+ */
+extern bool __attribute__((overloadable))
+ rsgProgramStoreGetDitherEnabled(rs_program_store ps);
+
+/**
+ * @hide
+ * Get program raster point sprite state
+ *
+ * @param pr
+ */
+extern bool __attribute__((overloadable))
+ rsgProgramRasterGetPointSpriteEnabled(rs_program_raster pr);
+
+/**
+ * @hide
+ * Get program raster cull mode
+ *
+ * @param pr
+ */
+extern rs_cull_mode __attribute__((overloadable))
+ rsgProgramRasterGetCullMode(rs_program_raster pr);
+
+#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
+
+#endif // __RS_PROGRAM_RSH__
+
diff --git a/libs/rs/scriptc/rs_sampler.rsh b/libs/rs/scriptc/rs_sampler.rsh
new file mode 100644
index 0000000..c8948c7
--- /dev/null
+++ b/libs/rs/scriptc/rs_sampler.rsh
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_sampler.rsh
+ * \brief Sampler routines
+ *
+ *
+ */
+
+#ifndef __RS_SAMPLER_RSH__
+#define __RS_SAMPLER_RSH__
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+
+/**
+ * @hide
+ * Get sampler minification value
+ *
+ * @param pr
+ */
+extern rs_sampler_value __attribute__((overloadable))
+ rsSamplerGetMinification(rs_sampler s);
+
+/**
+ * @hide
+ * Get sampler magnification value
+ *
+ * @param pr
+ */
+extern rs_sampler_value __attribute__((overloadable))
+ rsSamplerGetMagnification(rs_sampler s);
+
+/**
+ * @hide
+ * Get sampler wrap S value
+ *
+ * @param pr
+ */
+extern rs_sampler_value __attribute__((overloadable))
+ rsSamplerGetWrapS(rs_sampler s);
+
+/**
+ * @hide
+ * Get sampler wrap T value
+ *
+ * @param pr
+ */
+extern rs_sampler_value __attribute__((overloadable))
+ rsSamplerGetWrapT(rs_sampler s);
+
+/**
+ * @hide
+ * Get sampler anisotropy
+ *
+ * @param pr
+ */
+extern float __attribute__((overloadable))
+ rsSamplerGetAnisotropy(rs_sampler s);
+
+#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
+
+#endif // __RS_SAMPLER_RSH__
+
diff --git a/libs/rs/scriptc/rs_types.rsh b/libs/rs/scriptc/rs_types.rsh
index f8c2657..10617d8 100644
--- a/libs/rs/scriptc/rs_types.rsh
+++ b/libs/rs/scriptc/rs_types.rsh
@@ -402,6 +402,8 @@ typedef enum {
#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+
/**
* Describes the way mesh vertex data is interpreted when rendering
*
@@ -552,4 +554,6 @@ typedef enum {
RS_SAMPLER_INVALID = 100,
} rs_sampler_value;
-#endif
+#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
+
+#endif // __RS_TYPES_RSH__