Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 581cc640 authored by Alex Sakhartchouk's avatar Alex Sakhartchouk
Browse files

Adding nvidia extension for limited npot support.

Updating a3d loading to be async.

Change-Id: I4be71d2002b9ad6ab8896d63e625f031e6b7ea6c
parent 0424d69d
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -141,9 +141,11 @@ public class FileA3D extends BaseObj {
    }

    IndexEntry[] mFileEntries;
    InputStream mInputStream;

    FileA3D(int id, RenderScript rs) {
    FileA3D(int id, RenderScript rs, InputStream stream) {
        super(id, rs);
        mInputStream = stream;
    }

    private void initEntries() {
@@ -193,20 +195,12 @@ public class FileA3D extends BaseObj {
            if(fileId == 0) {
                throw new IllegalStateException("Load failed.");
            }
            FileA3D fa3d = new FileA3D(fileId, rs);
            FileA3D fa3d = new FileA3D(fileId, rs, is);
            fa3d.initEntries();
            return fa3d;

        } catch (Exception e) {
            // Ignore
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    // Ignore
                }
            }
        }

        return null;
+16 −13
Original line number Diff line number Diff line
@@ -104,7 +104,10 @@ nGetName(JNIEnv *_env, jobject _this, RsContext con, jint obj)
{
    LOG_API("nGetName, con(%p), obj(%p)", con, (void *)obj);
    const char *name = NULL;
    rsGetName(con, (void *)obj, &name);
    rsaGetName(con, (void *)obj, &name);
    if(name == NULL || strlen(name) == 0) {
        return NULL;
    }
    return _env->NewStringUTF(name);
}

@@ -306,7 +309,7 @@ nElementGetNativeData(JNIEnv *_env, jobject _this, RsContext con, jint id, jintA
    assert(dataSize == 5);

    uint32_t elementData[5];
    rsElementGetNativeData(con, (RsElement)id, elementData, dataSize);
    rsaElementGetNativeData(con, (RsElement)id, elementData, dataSize);

    for(jint i = 0; i < dataSize; i ++) {
        _env->SetIntArrayRegion(_elementData, i, 1, (const jint*)&elementData[i]);
@@ -323,7 +326,7 @@ nElementGetSubElements(JNIEnv *_env, jobject _this, RsContext con, jint id, jint
    uint32_t *ids = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t));
    const char **names = (const char **)malloc((uint32_t)dataSize * sizeof(const char *));

    rsElementGetSubElements(con, (RsElement)id, ids, names, (uint32_t)dataSize);
    rsaElementGetSubElements(con, (RsElement)id, ids, names, (uint32_t)dataSize);

    for(jint i = 0; i < dataSize; i++) {
        _env->SetObjectArrayElement(_names, i, _env->NewStringUTF(names[i]));
@@ -364,7 +367,7 @@ nTypeGetNativeData(JNIEnv *_env, jobject _this, RsContext con, jint id, jintArra
    LOG_API("nTypeCreate, con(%p)", con);

    uint32_t typeData[6];
    rsTypeGetNativeData(con, (RsType)id, typeData, 6);
    rsaTypeGetNativeData(con, (RsType)id, typeData, 6);

    for(jint i = 0; i < elementCount; i ++) {
        _env->SetIntArrayRegion(_typeData, i, 1, (const jint*)&typeData[i]);
@@ -590,7 +593,7 @@ static jint
nAllocationGetType(JNIEnv *_env, jobject _this, RsContext con, jint a)
{
    LOG_API("nAllocationGetType, con(%p), a(%p)", con, (RsAllocation)a);
    return (jint) rsAllocationGetType(con, (RsAllocation)a);
    return (jint) rsaAllocationGetType(con, (RsAllocation)a);
}

static void
@@ -616,7 +619,7 @@ nFileA3DCreateFromAssetStream(JNIEnv *_env, jobject _this, RsContext con, jint n

    Asset* asset = reinterpret_cast<Asset*>(native_asset);

    jint id = (jint)rsFileA3DCreateFromAssetStream(con, asset->getBuffer(false), asset->getLength());
    jint id = (jint)rsaFileA3DCreateFromAssetStream(con, asset->getBuffer(false), asset->getLength());
    return id;
}

@@ -624,7 +627,7 @@ static int
nFileA3DGetNumIndexEntries(JNIEnv *_env, jobject _this, RsContext con, jint fileA3D)
{
    int32_t numEntries = 0;
    rsFileA3DGetNumIndexEntries(con, &numEntries, (RsFile)fileA3D);
    rsaFileA3DGetNumIndexEntries(con, &numEntries, (RsFile)fileA3D);
    return numEntries;
}

@@ -634,7 +637,7 @@ nFileA3DGetIndexEntries(JNIEnv *_env, jobject _this, RsContext con, jint fileA3D
    LOGV("______nFileA3D %u", (uint32_t) fileA3D);
    RsFileIndexEntry *fileEntries = (RsFileIndexEntry*)malloc((uint32_t)numEntries * sizeof(RsFileIndexEntry));

    rsFileA3DGetIndexEntries(con, fileEntries, (uint32_t)numEntries, (RsFile)fileA3D);
    rsaFileA3DGetIndexEntries(con, fileEntries, (uint32_t)numEntries, (RsFile)fileA3D);

    for(jint i = 0; i < numEntries; i ++) {
        _env->SetObjectArrayElement(_entries, i, _env->NewStringUTF(fileEntries[i].objectName));
@@ -648,7 +651,7 @@ static int
nFileA3DGetEntryByIndex(JNIEnv *_env, jobject _this, RsContext con, jint fileA3D, jint index)
{
    LOGV("______nFileA3D %u", (uint32_t) fileA3D);
    jint id = (jint)rsFileA3DGetEntryByIndex(con, (uint32_t)index, (RsFile)fileA3D);
    jint id = (jint)rsaFileA3DGetEntryByIndex(con, (uint32_t)index, (RsFile)fileA3D);
    return id;
}

@@ -1166,7 +1169,7 @@ nMeshGetVertexBufferCount(JNIEnv *_env, jobject _this, RsContext con, jint mesh)
{
    LOG_API("nMeshGetVertexBufferCount, con(%p), Mesh(%p)", con, (RsMesh)mesh);
    jint vtxCount = 0;
    rsMeshGetVertexBufferCount(con, (RsMesh)mesh, &vtxCount);
    rsaMeshGetVertexBufferCount(con, (RsMesh)mesh, &vtxCount);
    return vtxCount;
}

@@ -1175,7 +1178,7 @@ nMeshGetIndexCount(JNIEnv *_env, jobject _this, RsContext con, jint mesh)
{
    LOG_API("nMeshGetIndexCount, con(%p), Mesh(%p)", con, (RsMesh)mesh);
    jint idxCount = 0;
    rsMeshGetIndexCount(con, (RsMesh)mesh, &idxCount);
    rsaMeshGetIndexCount(con, (RsMesh)mesh, &idxCount);
    return idxCount;
}

@@ -1185,7 +1188,7 @@ nMeshGetVertices(JNIEnv *_env, jobject _this, RsContext con, jint mesh, jintArra
    LOG_API("nMeshGetVertices, con(%p), Mesh(%p)", con, (RsMesh)mesh);

    RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numVtxIDs * sizeof(RsAllocation));
    rsMeshGetVertices(con, (RsMesh)mesh, allocs, (uint32_t)numVtxIDs);
    rsaMeshGetVertices(con, (RsMesh)mesh, allocs, (uint32_t)numVtxIDs);

    for(jint i = 0; i < numVtxIDs; i ++) {
        _env->SetIntArrayRegion(_ids, i, 1, (const jint*)&allocs[i]);
@@ -1202,7 +1205,7 @@ nMeshGetIndices(JNIEnv *_env, jobject _this, RsContext con, jint mesh, jintArray
    RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numIndices * sizeof(RsAllocation));
    uint32_t *prims= (uint32_t*)malloc((uint32_t)numIndices * sizeof(uint32_t));

    rsMeshGetIndices(con, (RsMesh)mesh, allocs, prims, (uint32_t)numIndices);
    rsaMeshGetIndices(con, (RsMesh)mesh, allocs, prims, (uint32_t)numIndices);

    for(jint i = 0; i < numIndices; i ++) {
        _env->SetIntArrayRegion(_idxIds, i, 1, (const jint*)&allocs[i]);
+19 −1
Original line number Diff line number Diff line
@@ -286,6 +286,25 @@ typedef struct {

} RsScriptCall;

// A3D loading and object update code.
// Should only be called at object creation, not thread safe
RsObjectBase rsaFileA3DGetEntryByIndex(RsContext, uint32_t idx, RsFile);
RsFile rsaFileA3DCreateFromAssetStream(RsContext, const void *data, uint32_t len);
void rsaFileA3DGetNumIndexEntries(RsContext, int32_t *numEntries, RsFile);
void rsaFileA3DGetIndexEntries(RsContext, RsFileIndexEntry *fileEntries,uint32_t numEntries, RsFile);
void rsaGetName(RsContext, void * obj, const char **name);
// Mesh update functions
void rsaMeshGetVertexBufferCount(RsContext, RsMesh, int32_t *vtxCount);
void rsaMeshGetIndexCount(RsContext, RsMesh, int32_t *idxCount);
void rsaMeshGetVertices(RsContext, RsMesh, RsAllocation *vtxData, uint32_t vtxDataCount);
void rsaMeshGetIndices(RsContext, RsMesh, RsAllocation *va, uint32_t *primType, uint32_t idxDataCount);
// Allocation update
const void* rsaAllocationGetType(RsContext con, RsAllocation va);
// Type update
void rsaTypeGetNativeData(RsContext, RsType, uint32_t *typeData, uint32_t typeDataSize);
// Element update
void rsaElementGetNativeData(RsContext, RsElement, uint32_t *elemData, uint32_t elemDataSize);
void rsaElementGetSubElements(RsContext, RsElement, uint32_t *ids, const char **names, uint32_t dataSize);

// Async commands for returning new IDS
RsType rsaTypeCreate(RsContext, RsElement, uint32_t dimCount,
@@ -293,7 +312,6 @@ RsType rsaTypeCreate(RsContext, RsElement, uint32_t dimCount,
RsAllocation rsaAllocationCreateTyped(RsContext rsc, RsType vtype);
RsAllocation rsaAllocationCreateFromBitmap(RsContext con, uint32_t w, uint32_t h, RsElement _dst, RsElement _src,  bool genMips, const void *data);


#ifndef NO_RS_FUNCS
#include "rsgApiFuncDecl.h"
#endif
+0 −76
Original line number Diff line number Diff line
@@ -58,11 +58,6 @@ AssignName {
	param size_t len
	}

GetName {
	param void *obj
	param const char **name
	}

ObjDestroy {
	param RsAsyncVoidPtr objPtr
	}
@@ -84,26 +79,6 @@ ElementCreate2 {
	ret RsElement
	}

ElementGetNativeData {
	param RsElement elem
	param uint32_t *elemData
	param uint32_t elemDataSize
	}

ElementGetSubElements {
	param RsElement elem
	param uint32_t *ids
	param const char **names
	param uint32_t dataSize
	}


TypeGetNativeData {
	param RsType type
	param uint32_t * typeData
	param uint32_t typeDataSize
	}

AllocationUpdateFromBitmap {
	param RsAllocation alloc
	param RsElement srcFmt
@@ -237,11 +212,6 @@ Adapter2DSubData {
	param const void *data
	}

AllocationGetType {
	param RsAllocation va
	ret const void*
	}

AllocationResize1D {
	param RsAllocation va
	param uint32_t dimX
@@ -433,35 +403,12 @@ ProgramVertexCreate {
	ret RsProgramVertex
	}

FileA3DCreateFromAssetStream {
	param const void * data
	param size_t len
	ret RsFile
	}

FileOpen {
	ret RsFile
	param const char *name
	param size_t len
	}

FileA3DGetNumIndexEntries {
	param int32_t * numEntries
	param RsFile file
	}

FileA3DGetIndexEntries {
	param RsFileIndexEntry * fileEntries
	param uint32_t numEntries
	param RsFile fileA3D
	}

FileA3DGetEntryByIndex {
	param uint32_t index
	param RsFile file
	ret RsObjectBase
	}

FontCreateFromFile {
	param const char *name
	param uint32_t fontSize
@@ -488,29 +435,6 @@ MeshBindVertex {
	param uint32_t slot
	}

MeshGetVertexBufferCount {
	param RsMesh mesh
	param int32_t *numVtx
	}

MeshGetIndexCount {
	param RsMesh mesh
	param int32_t *numIdx
	}

MeshGetVertices {
	param RsMesh mv
	param RsAllocation *vtxData
	param uint32_t vtxDataCount
	}

MeshGetIndices {
	param RsMesh mv
	param RsAllocation *va
	param uint32_t *primType
	param uint32_t idxDataCount
	}

AnimationCreate {
	param const float *inValues
	param const float *outValues
+6 −7
Original line number Diff line number Diff line
@@ -816,7 +816,12 @@ void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32
    a->resize2D(rsc, dimX, dimY);
}

const void* rsi_AllocationGetType(Context *rsc, RsAllocation va)
#endif //ANDROID_RS_BUILD_FOR_HOST

}
}

const void * rsaAllocationGetType(RsContext con, RsAllocation va)
{
    Allocation *a = static_cast<Allocation *>(va);
    a->getType()->incUserRef();
@@ -824,11 +829,6 @@ const void* rsi_AllocationGetType(Context *rsc, RsAllocation va)
    return a->getType();
}

#endif //ANDROID_RS_BUILD_FOR_HOST

}
}

RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype)
{
    Context *rsc = static_cast<Context *>(con);
@@ -873,4 +873,3 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, uint32_t w, uint32_t h

    return texAlloc;
}
Loading