diff options
author | Alex Sakhartchouk <alexst@google.com> | 2011-04-29 16:49:08 -0700 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2011-04-29 16:49:08 -0700 |
commit | a04e30dbb5ab11592b03666bb3d102070759c58e (patch) | |
tree | 7db6cf06de3d034d8bc8b8f7f7e4a2ed212556e4 /rsMesh.h | |
parent | 609201dadcf408cf6246f48a752b8ffbb49d41c3 (diff) | |
download | rs-a04e30dbb5ab11592b03666bb3d102070759c58e.tar.gz |
Moving renderscript GL code into the HAL
This change affects
- shaders
- meshes
- fonts
- quad rendering
Change-Id: I2a53acb4cd1fa8f4c6e67668f6ee969f3d7f7aa1
Diffstat (limited to 'rsMesh.h')
-rw-r--r-- | rsMesh.h | 64 |
1 files changed, 36 insertions, 28 deletions
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2011 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. @@ -29,57 +29,65 @@ namespace renderscript { class Mesh : public ObjectBase { public: Mesh(Context *); + Mesh(Context *, uint32_t vertexBuffersCount, uint32_t primitivesCount); ~Mesh(); - // Contains vertex data - // Position, normal, texcoord, etc could either be strided in one allocation - // of provided separetely in multiple ones - ObjectBaseRef<Allocation> *mVertexBuffers; - uint32_t mVertexBufferCount; - // Either mIndexBuffer, mPrimitiveBuffer or both could have a NULL reference // If both are null, mPrimitive only would be used to render the mesh - struct Primitive_t - { + struct Primitive_t { ObjectBaseRef<Allocation> mIndexBuffer; - RsPrimitive mPrimitive; - uint32_t mGLPrimitive; }; + // compatibility to not break the build + ObjectBaseRef<Allocation> *mVertexBuffers; + uint32_t mVertexBufferCount; Primitive_t ** mPrimitives; uint32_t mPrimitivesCount; + // end compatibility virtual void serialize(OStream *stream) const; virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; } static Mesh *createFromStream(Context *rsc, IStream *stream); + void init(); + + struct Hal { + mutable void *drv; + + struct State { + // Contains vertex data + // Position, normal, texcoord, etc could either be strided in one allocation + // of provided separetely in multiple ones + ObjectBaseRef<Allocation> *vertexBuffers; + uint32_t vertexBuffersCount; + + Primitive_t ** primitives; + uint32_t primitivesCount; + }; + State state; + }; + Hal mHal; + + void setVertexBuffer(Allocation *vb, uint32_t index) { + mHal.state.vertexBuffers[index].set(vb); + } + + void setPrimitive(Allocation *idx, RsPrimitive prim, uint32_t index) { + mHal.state.primitives[index]->mIndexBuffer.set(idx); + mHal.state.primitives[index]->mPrimitive = prim; + } -#ifndef ANDROID_RS_SERIALIZE void render(Context *) const; void renderPrimitive(Context *, uint32_t primIndex) const; void renderPrimitiveRange(Context *, uint32_t primIndex, uint32_t start, uint32_t len) const; void uploadAll(Context *); - void updateGLPrimitives(); - - // Bounding volumes float mBBoxMin[3]; float mBBoxMax[3]; void computeBBox(); - - void initVertexAttribs(); - protected: - bool isValidGLComponent(const Element *elem, uint32_t fieldIdx); - // Attribues that allow us to map to GL - VertexArray::Attrib *mAttribs; - // This allows us to figure out which allocation the attribute - // belongs to. In the event the allocation is uploaded to GL - // buffer, it lets us properly map it - uint32_t *mAttribAllocationIndex; - uint32_t mAttribCount; -#endif + bool mInitialized; }; class MeshContext { @@ -92,7 +100,7 @@ public: } } -#endif //ANDROID_RS_TRIANGLE_MESH_H +#endif //ANDROID_RS_MESH_H |