{"action":"created","issue":{"url":"https://api.github.com/repos/mono/MonoGame/issues/4195","labels_url":"https://api.github.com/repos/mono/MonoGame/issues/4195/labels{/name}","comments_url":"https://api.github.com/repos/mono/MonoGame/issues/4195/comments","events_url":"https://api.github.com/repos/mono/MonoGame/issues/4195/events","html_url":"https://github.com/mono/MonoGame/pull/4195","id":112423845,"number":4195,"title":"Implemented DrawInstancedPrimitives(), SetVertexBuffers() and improved input layout caching for DirectX.","user":{"login":"Helikin","id":3626369,"avatar_url":"https://avatars.githubusercontent.com/u/3626369?v=3","gravatar_id":"","url":"https://api.github.com/users/Helikin","html_url":"https://github.com/Helikin","followers_url":"https://api.github.com/users/Helikin/followers","following_url":"https://api.github.com/users/Helikin/following{/other_user}","gists_url":"https://api.github.com/users/Helikin/gists{/gist_id}","starred_url":"https://api.github.com/users/Helikin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Helikin/subscriptions","organizations_url":"https://api.github.com/users/Helikin/orgs","repos_url":"https://api.github.com/users/Helikin/repos","events_url":"https://api.github.com/users/Helikin/events{/privacy}","received_events_url":"https://api.github.com/users/Helikin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-10-20T17:53:43Z","updated_at":"2015-11-24T18:36:56Z","closed_at":"2015-10-22T12:12:40Z","pull_request":{"url":"https://api.github.com/repos/mono/MonoGame/pulls/4195","html_url":"https://github.com/mono/MonoGame/pull/4195","diff_url":"https://github.com/mono/MonoGame/pull/4195.diff","patch_url":"https://github.com/mono/MonoGame/pull/4195.patch"},"body":"This PR adds the DirectX implementation for **DrawInstancedPrimitives** and **SetVertexBuffers**. The hashing and caching of vertex input layouts is also fixed/improved.\r\n\r\nBefore writing this code, we have reviewed the related issues for these topics:\r\n- GraphicsDevice.DrawInstancedPrimitives API not yet implemented. #913\r\n- GraphicsDevice.SetVertexBuffers API is not yet implemented #914\r\n- Implemented GraphicsDevice.SetVertexBuffers(...) #3276\r\n\r\nThis implementation is used successfully in the DigitalRune Engine for mesh instancing and morph target animation. We have also added some simple unit tests.\r\n\r\nThere is one important change regarding the vertex attribute semantics **SV_Position** and **POSITION** in shaders:\r\nThe recommended semantic for the vertex input element which describes the vertex position is **POSITION**. However, the XNA stock effects use **SV_Position**. This is allowed in DirectX but it is better to use **SV_Position** (\"system-value position\") only for the vertex shader output and pixel shader input. \r\nThis is important when using morph targets. Each morph target mesh has a **POSITION0** element. At runtime the morph target vertex streams are matched and combined to a single input layout with **POSITION0/1/2/3**. This is not possible with **SV_Position** because **SV_Position1/2/3** is not a valid semantic.\r\nTherefore, we have changed the C# code and shaders to use **POSITION** for vertex inputs. \r\nThe new code contains a fallback to handle shaders with **SV_Position**, but we recommend to only use **POSITION** for vertex shader input for all future MonoGame shaders.\r\n\r\nThe vertex input type for BLENDINDICES has been changed from int4 to uint4. This prevents SharpDX warnings when run on debug device. (The problem is that the MonoGame content pipeline outputs Byte4 for BLENDINDICES. MonoGame does not have a signed integer format that matches int4.)\r\n\r\nThis PR also fixes a minor bug in the GraphicsDevice OpenGL code: The flag **_vertexBufferDirty** was never reset to false."},"comment":{"url":"https://api.github.com/repos/mono/MonoGame/issues/comments/159366846","html_url":"https://github.com/mono/MonoGame/pull/4195#issuecomment-159366846","issue_url":"https://api.github.com/repos/mono/MonoGame/issues/4195","id":159366846,"user":{"login":"kvenkateshan","id":11383753,"avatar_url":"https://avatars.githubusercontent.com/u/11383753?v=3","gravatar_id":"","url":"https://api.github.com/users/kvenkateshan","html_url":"https://github.com/kvenkateshan","followers_url":"https://api.github.com/users/kvenkateshan/followers","following_url":"https://api.github.com/users/kvenkateshan/following{/other_user}","gists_url":"https://api.github.com/users/kvenkateshan/gists{/gist_id}","starred_url":"https://api.github.com/users/kvenkateshan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kvenkateshan/subscriptions","organizations_url":"https://api.github.com/users/kvenkateshan/orgs","repos_url":"https://api.github.com/users/kvenkateshan/repos","events_url":"https://api.github.com/users/kvenkateshan/events{/privacy}","received_events_url":"https://api.github.com/users/kvenkateshan/received_events","type":"User","site_admin":false},"created_at":"2015-11-24T18:36:56Z","updated_at":"2015-11-24T18:36:56Z","body":"Helikin, any chance you are also working on bringing this over to PS4? We have major features relating to instanced based rendering and are curious to know about any timelines around this feature making it over to PS4. Thanks for your help!"}}