<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <br>
    <br>
    <div class="moz-cite-prefix">On 4/29/22 09:50, Ziqing Hui wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:644f2f06-a134-7e1b-73b5-17e386f72161@codeweavers.com">
      <pre class="moz-quote-pre" wrap="">

On 4/29/22 2:02 PM, Nikolay Sivov wrote:
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">

On 4/28/22 13:40, Ziqing Hui wrote:
</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">+struct d2d_shader
+{
+    const GUID *id;
+    void *shader;
+};
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap="">This could at least use IUnknown, you can probably use a union later to avoid casts.

</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">+    effect_context->shader_count++;
+    if (effect_context->shaders_size < effect_context->shader_count)
+    {
+        if (!d2d_array_reserve((void **)&effect_context->shaders, &effect_context->shaders_size,
+                effect_context->shader_count, sizeof(*effect_context->shaders)))
+        {
+            ERR("Failed to resize shaders array.\n");
+            ID3D11VertexShader_Release(vertex_shader);
+            return E_OUTOFMEMORY;
+        }
+    }
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap="">You should call this to reserve "effect_context->shader_count + 1", no need to check size < count explicitly.

Since this is using GUIDs for keys, I suspect it should check for duplicates? IsShaderLoaded() takes just a GUID, so that implies all shader types are in the same list most likely.

By the way, have you figured out how shader objects are used later?

</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
Shader objects will be used in ID2D1DrawTransform to create custom transforms which have custom shaders.

ID2D1DrawTransfrom use ID2D1DrawInfo that has functions like SetPixelShader() which accept shader GUID as an input argument.
And that's where the loaded shader objects are used.

</pre>
    </blockquote>
    I see, thanks. Maybe it is a good idea to have dummy custom effect
    in our tests to see how these methods work. Specifically calling
    with same (or null) GUID, and where you can reuse GUID across shader
    types (I suspect you can't).<br>
    <br>
    Later for SetPixelShader() we'll see if it returns meaningful error
    code if you set e.g. compute shader to it, or only forwards d3d
    error. But anyway, IUnknown* should be good for now, instead of
    void*. <span style="color: rgb(0, 104, 129); font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(242, 242, 242); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"></span>
  </body>
</html>