on 09-01-2012 09:19 PM
Hi all,
I'm trying to batch my draw calls for my 2D game into fewer, larger calls to optimise my code.
I'm running into an issue where the indices I pass in my call to SetIndices seem to be being ignored. Has anyone else experienced this? Is there a workaround? If any further information is required please let me know.
Steve
on 16-01-2012 05:54 PM
16-01-2012 09:41 PM - edited 16-01-2012 09:44 PM
on 17-01-2012 11:50 AM
Hello, MingooX,
Have you tried using a constructor with indexCount param, such as:
_vertexBuffer = new VertexBuffer(_maxVertexCount,
on 17-01-2012 06:20 PM
on 18-01-2012 12:51 PM
As for now, I cannot find any methods that manipulate vectors stored in a float[] .
We can write such methods easily but that sort of methods should be standardized,
so that we can expect hardware acceleration.
As all ARM processors in PS Certified devices have SIMD vector processing instructions...
on 20-01-2012 05:10 PM
Hi Guys,
Actually, you can declare the float arrays that used to pass in for vertexbuffer.SetVertices as Vector3s.
static VertexBuffer CreateQuad()
{
VertexBuffer vertexbuffer = new VertexBuffer( 4,
6,
VertexFormat.Float3,
VertexFormat.Float2 );
// vertexbuffer
//Vector3 positions[4];
Vector3[] positions;
positions = new Vector3[4];
positions[0].X = -1.0f;
positions[0].Y = -1.0f;
positions[0].Z = 0.0f;
positions[1].X = 1.0f;
positions[1].Y = -1.0f;
positions[1].Z = 0.0f;
positions[2].X = 2.0f;
positions[2].Y = 1.0f;
positions[2].Z = 0.0f;
positions[3].X = -1.0f;
positions[3].Y = 1.0f;
positions[3].Z = 0.0f;
/*
float[] positions = {
// front
-1.0f, -1.0f, 0.0f, // 0
1.0f, -1.0f, 0.0f, // 1
1.0f, 1.0f, 0.0f, // 2
-1.0f, 1.0f, 0.0f, // 3
};
*/
float[] texcoords = {
// front
0.0f, 1.0f, // 0
1.0f, 1.0f, // 1
1.0f, 0.0f, // 2
0.0f, 0.0f, // 3
};
ushort[] indices = {
// front
0, 1, 2,
0, 2, 3
};
vertexbuffer.SetVertices( 0, positions );
vertexbuffer.SetVertices( 1, texcoords );
vertexbuffer.SetIndices( indices );
return vertexbuffer;
}
for math purpos, then you can use Matrix4 class to perform rotation and such on these vector3s.
nagata_kobo wrote:As for now, I cannot find any methods that manipulate vectors stored in a float[] .
We can write such methods easily but that sort of methods should be standardized,
so that we can expect hardware acceleration.
As all ARM processors in PS Certified devices have SIMD vector processing instructions...
As it is in C#, I would assume that by using the built in Matrix4/Vector3/Vecotr4 math operations , it will try to translated into SIMD instructions if possible after compile to take HW advantage.
Thanks,
Jay
on 21-01-2012 01:01 AM
Hello, Jay,
Thank you for your suggestions.
Frankly, I could not have found that VertexBuffer's SetIndices methods accept Vector2/3/4 arrays till now...
The SDK Documents should refer to this.
on 28-01-2012 12:51 AM
nagata_kobo wrote:Hello, Jay,
Thank you for your suggestions.
Frankly, I could not have found that VertexBuffer's SetIndices methods accept Vector2/3/4 arrays till now...
The SDK Documents should refer to this.
Agree, I will reflect this to the internal team.
Cheers,
Jay
on 24-04-2012 06:10 AM
Just thought I'd mention I had a similar issue to this on Vita HW.
I was initially using 2 vertex buffers - 1 with pos/color, and the other with uv/tri-index.
Setup was like this:
[code]
//pos/color buffer...
_vertBuf=new VertexBuffer( MAX_VERTS,VertexFormat.Float2,VertexFormat.UByte4N );
//uv/index buffer
_quadBuf=new VertexBuffer( MAX_QUADS*4,MAX_QUADS*6,VertexFormat.Float2 );
ushort[] idxs=new ushort[MAX_QUADS*6];
for( int i=0;i<MAX_QUADS;++i ){
idxs[i*6+0]=(ushort)(i*4);
idxs[i*6+1]=(ushort)(i*4+1);
idxs[i*6+2]=(ushort)(i*4+2);
idxs[i*6+3]=(ushort)(i*4);
idxs[i*6+4]=(ushort)(i*4+2);
idxs[i*6+5]=(ushort)(i*4+3);
}
_quadBuf.SetIndices( idxs );
_gc.SetVertexBuffer( 0,_vertBuf );
_gc.SetVertexBuffer( 1,_quadBuf );
[/code]
According to my reading of the docs, this should work - and it did on the emulator but not on the Vita. At a guess, it looked like the indices were being completely ignored on the Vita.
Moving to a single vertex/index buffer fixed it.
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870