<p>I see two kinds of passing Instance Data to <strong>Vertex Shader</strong> in different Examples.</p>

<p><strong>1</strong> .Using a <strong>Uniform Buffer</strong> and filling in an array, like below</p>

<pre><code>struct UniformBlock
{
    mat4 mProjectView;
    mat4 mToWorldMat[MAX_INSTANCE];
    vec4 mColor[MAX_INSTANCES];
};
</code></pre>

<p><strong>2</strong>. Filling in buffers, and then define the buffer as <strong>RATE_PER_INSTANCE</strong>  in vertex layout description (I assume this is the more usual way)</p>

<ul>
<li><p>My Question is :</p>

<ul>
<li>How do these differ from <strong>hardware</strong> or <strong>memory access</strong> Point of View?</li>
<li>Are there any cases which one is considered "better" or "faster" than the other?</li>
</ul></li>
</ul>

CC BY-SA 4.0
2019-08-23T13:53:06.893Z
Are you asking about Vulkan or D3D12? Because Vulkan doesn't have "rate per instance"; are you talking about instanced vertex arrays?
Nicol Bolas
CC BY-SA 4.0
2019-08-23T16:59:22.947Z
I meant VK_VERTEX_INPUT_RATE_INSTANCE @NicolBolas
Erfan Ahmadi
<vulkan><directx12>
Difference between Passing Instance Data to Vertex Shader methods
Erfan Ahmadi
# Difference between Passing Instance Data to Vertex Shader methods

(Asked by: username_0 on 2019-08-22)

I see two kinds of passing Instance Data to **Vertex Shader** in different Examples.

**1** .Using a **Uniform Buffer** and filling in an array, like below

```
struct UniformBlock
{
    mat4 mProjectView;
    mat4 mToWorldMat[MAX_INSTANCE];
    vec4 mColor[MAX_INSTANCES];
};

```

**2**. Filling in buffers, and then define the buffer as **RATE\_PER\_INSTANCE** in vertex layout description (I assume this is the more usual way)

* My Question is :

  + How do these differ from **hardware** or **memory access** Point of View?
  + Are there any cases which one is considered "better" or "faster" than the other?

**Tags:** vulkan, directx12

> **Comments:**
> **username_1**: Are you asking about Vulkan or D3D12? Because Vulkan doesn't have "rate per instance"; are you talking about instanced vertex arrays?  
> **username_0**: I meant VK_VERTEX_INPUT_RATE_INSTANCE @username_1  

---

## 0 answers

