Graphics

Reply

VertexBuffer の要望です

英語書けないので google で翻訳してください :Stupid:

 

特に不具合もなく動作していますが、要望があります。

VertexFormat を持たない VertexBuffer がないので不便です。

寿命の短い頂点をまとめて格納するために使用したいので
VertexBuffer を以下のように拡張するか、新しく class を追加してください。

----------------------------
class VertexBuffer
{
    public VertexBuffer( int vertexByteSize, int indexByteSize );
    public SetVertexSubData( int byteOffset, int byteSize, byte[] data );
    public SetIndexSubData( int byteOffset, int byteSize, byte[] data );
}
----------------------------

VertexFormat を持たない VertexBuffer を bind するために
GraphicsContext にも以下のような method の追加が必要になります。

----------------------------
class GraphicsContext
{
    public void SetVertexBuffer( int index, VertexBuffer vertexBuffer, VertexFormat[] formats, int byteOffset );
}
----------------------------

また、 ShaderProgram のコンストラクタで、以下のように attribute binding を渡した方が良いと思います。

こちらの方がコンストラクタ内で、 glLinkProgram() まで呼び出せるため
内部的に program を確定することができます。

----------------------------

class ShaderProgram
{
    public ShaderProgram( string strShaderPath, AttributeBindingDesc[] attributrBindings );
}

class AttributeBindingDesc
{
    public int Index;
    public string AttributeName;
}

----------------------------
# VITA を考慮すると、 glLinkProgram() の呼び出しにはあまり意味がないかもしれませんが…。


Please use plain text.
PSM Dev Team
sawadax
Posts: 8
Registered: ‎22-11-2011
Message 2 of 3 (373 Views)

Re: VertexBuffer の要望です

貴重なご意見ありがとうございます。

頂点バッファは任意のバイト列のように格納でき、
頂点フォーマットは使用時に指定できるようにしたい、
というご要望と理解しました。参考にさせていただきます。

現在の仕様は、メモリレイアウトを隠ぺいするという目的があり、
単純に実装できるという理由から、このような仕様になりました。
ご不便おかけしますが、現在のところはご了承ください。

また attribute binding は、glBindAttribLocation に似ていますが、
実際には OpenGL を呼び出さず、内部的な番号の変更で処理します。
ある程度の負荷がありますが、glLinkProgram は実行されません。

 

Please use plain text.

Re: VertexBuffer の要望です

> 現在の仕様は、メモリレイアウトを隠ぺいするという目的があり、
> 単純に実装できるという理由から、このような仕様になりました。
> ご不便おかけしますが、現在のところはご了承ください。

たしかに PS3 対応も考えると頂点書き込み時に頂点フォーマットが分かっていた方が良さそうなので、
# GraphicsContext.DrawArrays() 時にフォーマット変換する手もありますが…。

# ちなみに OpenGL にあって、GPU にないアトリビュートフォーマットに関しては

# どうやら Draw 時にドライバ内で変換しているっぽいです。

----------
class VertexBuffer
{
    public void SetVertexSubData( int byteOffset, VertexFormat[] formats, Array vertices );
}
----------

として、頂点バッファ設定時にフォーマットを一緒に指定した方が良さそうです。

もしくは互換性を考慮して

----------
class VertexBuffer
{
    public void SetVertexFormats( VertexFormat[] formats );
    public void SetByteOffset( int byteOffset );

    //. 直前の SetVertexFormats() / SetByteOffset() に従って、vertices を書き込む.
    public void SetVertices( Array vertices );
}
----------

のような実装の方が良いかもしれません。

この実装の場合、GraphicsContext.SetVertexBuffer() も引数を増やす必要がなく、
直前の SetVertexFormats() / SetByteOffset() で設定された状態で
VertexBuffer を設定すれば良いことになります。

また、 SetVertices() 時に設定された vertex format と byte offset で
SetVertexBuffer() を呼び出す必要があることについては
通常このような使い方をする場合、アプリ側の Render() 内で

VertexBuffer.SetVertexFormats()
VertexBuffer.SetByteOffset()
VertexBuffer.SetVertices()
GraphicsContext.SetVertexBuffer()
GraphicsContext.DrawArrays()

の順で呼び出されることが多いと思われるため、
SDK 側はあまり気にする必要はないと思います。

あと現状 little endian なバイナリファイルを無加工で byte[] に読み込んで
それを SetVertices() に渡すと正常に描画されてしまうのですが、
PS3 対応を考えるのであれば、何かしら endian ヒントのようなものが必要かもしれません。



Please use plain text.
This widget could not be displayed.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

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を一度ログアウトし、再度ログインしてください。






Recent News