diff mbox series

radv: Allow physical device interfaces to be included in device extensions

Message ID 20181012203844.29891-1-keithp@keithp.com (mailing list archive)
State New, archived
Headers show
Series radv: Allow physical device interfaces to be included in device extensions | expand

Commit Message

Keith Packard Oct. 12, 2018, 8:38 p.m. UTC
According to the Vulkan spec:

"Vulkan 1.0 initially required all new physical-device-level extension
 functionality to be structured within an instance extension. In order
 to avoid using an instance extension, which often requires loader
 support, physical-device-level extension functionality may be
 implemented within device extensions"

The code that checks for enabled extension APIs currently only passes
functions with VkDevice or VkCommandBuffer as their first
argument. This patch extends that to also allow functions with
VkPhysicalDevice parameters, in support of the above quote from the
Vulkan spec.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 src/amd/vulkan/radv_entrypoints_gen.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bas Nieuwenhuizen Oct. 13, 2018, 3:57 p.m. UTC | #1
On Fri, Oct 12, 2018 at 10:38 PM Keith Packard <keithp@keithp.com> wrote:
>
> According to the Vulkan spec:
>
> "Vulkan 1.0 initially required all new physical-device-level extension
>  functionality to be structured within an instance extension. In order
>  to avoid using an instance extension, which often requires loader
>  support, physical-device-level extension functionality may be
>  implemented within device extensions"
>
> The code that checks for enabled extension APIs currently only passes
> functions with VkDevice or VkCommandBuffer as their first
> argument. This patch extends that to also allow functions with
> VkPhysicalDevice parameters, in support of the above quote from the
> Vulkan spec.
>

Also "To obtain a function pointer for a physical-device-level command
from a device extension, an application can use vkGetInstanceProcAddr.
"

As far as I can tell the device_command member is only to make sure we
return NULL from vkGetDeviceProcAddr, and per the spec (3.1 table 2)
we still have to return NULL there for functions which take
VkPhysicalDevice? So the old behavior seems correct to me.

> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
>  src/amd/vulkan/radv_entrypoints_gen.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/amd/vulkan/radv_entrypoints_gen.py b/src/amd/vulkan/radv_entrypoints_gen.py
> index 377b544c2aa..69e6fc3e0eb 100644
> --- a/src/amd/vulkan/radv_entrypoints_gen.py
> +++ b/src/amd/vulkan/radv_entrypoints_gen.py
> @@ -352,7 +352,7 @@ class Entrypoint(EntrypointBase):
>          self.return_type = return_type
>          self.params = params
>          self.guard = guard
> -        self.device_command = len(params) > 0 and (params[0].type == 'VkDevice' or params[0].type == 'VkQueue' or params[0].type == 'VkCommandBuffer')
> +        self.device_command = len(params) > 0 and (params[0].type == 'VkPhysicalDevice' or params[0].type == 'VkDevice' or params[0].type == 'VkQueue' or params[0].type == 'VkCommandBuffer')
>
>      def prefixed_name(self, prefix):
>          assert self.name.startswith('vk')
> --
> 2.19.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Jason Ekstrand Oct. 13, 2018, 4:12 p.m. UTC | #2
On Sat, Oct 13, 2018 at 10:58 AM Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
wrote:

> On Fri, Oct 12, 2018 at 10:38 PM Keith Packard <keithp@keithp.com> wrote:
> >
> > According to the Vulkan spec:
> >
> > "Vulkan 1.0 initially required all new physical-device-level extension
> >  functionality to be structured within an instance extension. In order
> >  to avoid using an instance extension, which often requires loader
> >  support, physical-device-level extension functionality may be
> >  implemented within device extensions"
> >
> > The code that checks for enabled extension APIs currently only passes
> > functions with VkDevice or VkCommandBuffer as their first
> > argument. This patch extends that to also allow functions with
> > VkPhysicalDevice parameters, in support of the above quote from the
> > Vulkan spec.
> >
>
> Also "To obtain a function pointer for a physical-device-level command
> from a device extension, an application can use vkGetInstanceProcAddr.
> "
>
> As far as I can tell the device_command member is only to make sure we
> return NULL from vkGetDeviceProcAddr, and per the spec (3.1 table 2)
> we still have to return NULL there for functions which take
> VkPhysicalDevice? So the old behavior seems correct to me.
>

I think anv is ignoring that line in the table which is why it works for
us.  If only someone wrote tests for these things...

I think the correct interpretation would be that any physical device
functions that are part of a core version or instance extension should
yield NULL but any physical device functions from a device extension should
return a valid function pointer.  Sadly, that behavior is kind-of a pain to
implement. :-(


> > Signed-off-by: Keith Packard <keithp@keithp.com>
> > ---
> >  src/amd/vulkan/radv_entrypoints_gen.py | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/amd/vulkan/radv_entrypoints_gen.py
> b/src/amd/vulkan/radv_entrypoints_gen.py
> > index 377b544c2aa..69e6fc3e0eb 100644
> > --- a/src/amd/vulkan/radv_entrypoints_gen.py
> > +++ b/src/amd/vulkan/radv_entrypoints_gen.py
> > @@ -352,7 +352,7 @@ class Entrypoint(EntrypointBase):
> >          self.return_type = return_type
> >          self.params = params
> >          self.guard = guard
> > -        self.device_command = len(params) > 0 and (params[0].type ==
> 'VkDevice' or params[0].type == 'VkQueue' or params[0].type ==
> 'VkCommandBuffer')
> > +        self.device_command = len(params) > 0 and (params[0].type ==
> 'VkPhysicalDevice' or params[0].type == 'VkDevice' or params[0].type ==
> 'VkQueue' or params[0].type == 'VkCommandBuffer')
> >
> >      def prefixed_name(self, prefix):
> >          assert self.name.startswith('vk')
> > --
> > 2.19.1
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sat, Oct 13, 2018 at 10:58 AM Bas Nieuwenhuizen &lt;<a href="mailto:bas@basnieuwenhuizen.nl">bas@basnieuwenhuizen.nl</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Oct 12, 2018 at 10:38 PM Keith Packard &lt;<a href="mailto:keithp@keithp.com" target="_blank">keithp@keithp.com</a>&gt; wrote:<br>
&gt;<br>
&gt; According to the Vulkan spec:<br>
&gt;<br>
&gt; &quot;Vulkan 1.0 initially required all new physical-device-level extension<br>
&gt;  functionality to be structured within an instance extension. In order<br>
&gt;  to avoid using an instance extension, which often requires loader<br>
&gt;  support, physical-device-level extension functionality may be<br>
&gt;  implemented within device extensions&quot;<br>
&gt;<br>
&gt; The code that checks for enabled extension APIs currently only passes<br>
&gt; functions with VkDevice or VkCommandBuffer as their first<br>
&gt; argument. This patch extends that to also allow functions with<br>
&gt; VkPhysicalDevice parameters, in support of the above quote from the<br>
&gt; Vulkan spec.<br>
&gt;<br>
<br>
Also &quot;To obtain a function pointer for a physical-device-level command<br>
from a device extension, an application can use vkGetInstanceProcAddr.<br>
&quot;<br>
<br>
As far as I can tell the device_command member is only to make sure we<br>
return NULL from vkGetDeviceProcAddr, and per the spec (3.1 table 2)<br>
we still have to return NULL there for functions which take<br>
VkPhysicalDevice? So the old behavior seems correct to me.<br></blockquote><div><br></div><div>I think anv is ignoring that line in the table which is why it works for us.  If only someone wrote tests for these things...</div><div><br></div><div>I think the correct interpretation would be that any physical device functions that are part of a core version or instance extension should yield NULL but any physical device functions from a device extension should return a valid function pointer.  Sadly, that behavior is kind-of a pain to implement. :-(<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
&gt; Signed-off-by: Keith Packard &lt;<a href="mailto:keithp@keithp.com" target="_blank">keithp@keithp.com</a>&gt;<br>
&gt; ---<br>
&gt;  src/amd/vulkan/radv_entrypoints_gen.py | 2 +-<br>
&gt;  1 file changed, 1 insertion(+), 1 deletion(-)<br>
&gt;<br>
&gt; diff --git a/src/amd/vulkan/radv_entrypoints_gen.py b/src/amd/vulkan/radv_entrypoints_gen.py<br>
&gt; index 377b544c2aa..69e6fc3e0eb 100644<br>
&gt; --- a/src/amd/vulkan/radv_entrypoints_gen.py<br>
&gt; +++ b/src/amd/vulkan/radv_entrypoints_gen.py<br>
&gt; @@ -352,7 +352,7 @@ class Entrypoint(EntrypointBase):<br>
&gt;          self.return_type = return_type<br>
&gt;          self.params = params<br>
&gt;          self.guard = guard<br>
&gt; -        self.device_command = len(params) &gt; 0 and (params[0].type == &#39;VkDevice&#39; or params[0].type == &#39;VkQueue&#39; or params[0].type == &#39;VkCommandBuffer&#39;)<br>
&gt; +        self.device_command = len(params) &gt; 0 and (params[0].type == &#39;VkPhysicalDevice&#39; or params[0].type == &#39;VkDevice&#39; or params[0].type == &#39;VkQueue&#39; or params[0].type == &#39;VkCommandBuffer&#39;)<br>
&gt;<br>
&gt;      def prefixed_name(self, prefix):<br>
&gt;          assert self.name.startswith(&#39;vk&#39;)<br>
&gt; --<br>
&gt; 2.19.1<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; mesa-dev mailing list<br>
&gt; <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
&gt; <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>
Bas Nieuwenhuizen Oct. 13, 2018, 4:23 p.m. UTC | #3
On Sat, Oct 13, 2018 at 6:12 PM Jason Ekstrand <jason@jlekstrand.net> wrote:
>
> On Sat, Oct 13, 2018 at 10:58 AM Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> wrote:
>>
>> On Fri, Oct 12, 2018 at 10:38 PM Keith Packard <keithp@keithp.com> wrote:
>> >
>> > According to the Vulkan spec:
>> >
>> > "Vulkan 1.0 initially required all new physical-device-level extension
>> >  functionality to be structured within an instance extension. In order
>> >  to avoid using an instance extension, which often requires loader
>> >  support, physical-device-level extension functionality may be
>> >  implemented within device extensions"
>> >
>> > The code that checks for enabled extension APIs currently only passes
>> > functions with VkDevice or VkCommandBuffer as their first
>> > argument. This patch extends that to also allow functions with
>> > VkPhysicalDevice parameters, in support of the above quote from the
>> > Vulkan spec.
>> >
>>
>> Also "To obtain a function pointer for a physical-device-level command
>> from a device extension, an application can use vkGetInstanceProcAddr.
>> "
>>
>> As far as I can tell the device_command member is only to make sure we
>> return NULL from vkGetDeviceProcAddr, and per the spec (3.1 table 2)
>> we still have to return NULL there for functions which take
>> VkPhysicalDevice? So the old behavior seems correct to me.
>
>
> I think anv is ignoring that line in the table which is why it works for us.  If only someone wrote tests for these things...
>
> I think the correct interpretation would be that any physical device functions that are part of a core version or instance extension should yield NULL but any physical device functions from a device extension should return a valid function pointer.  Sadly, that behavior is kind-of a pain to implement. :-(

How would you read that into the spec? As quoted above it explicitly
tells you to use vkGetInstanceProcAddr for VkPhysicalDevice functions,
even if they are based on a device extension. (And you cannot really
use vkGetDeviceProcAddr anyway as the typical usecase is before you've
created a device).
>
>>
>> > Signed-off-by: Keith Packard <keithp@keithp.com>
>> > ---
>> >  src/amd/vulkan/radv_entrypoints_gen.py | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/src/amd/vulkan/radv_entrypoints_gen.py b/src/amd/vulkan/radv_entrypoints_gen.py
>> > index 377b544c2aa..69e6fc3e0eb 100644
>> > --- a/src/amd/vulkan/radv_entrypoints_gen.py
>> > +++ b/src/amd/vulkan/radv_entrypoints_gen.py
>> > @@ -352,7 +352,7 @@ class Entrypoint(EntrypointBase):
>> >          self.return_type = return_type
>> >          self.params = params
>> >          self.guard = guard
>> > -        self.device_command = len(params) > 0 and (params[0].type == 'VkDevice' or params[0].type == 'VkQueue' or params[0].type == 'VkCommandBuffer')
>> > +        self.device_command = len(params) > 0 and (params[0].type == 'VkPhysicalDevice' or params[0].type == 'VkDevice' or params[0].type == 'VkQueue' or params[0].type == 'VkCommandBuffer')
>> >
>> >      def prefixed_name(self, prefix):
>> >          assert self.name.startswith('vk')
>> > --
>> > 2.19.1
>> >
>> > _______________________________________________
>> > mesa-dev mailing list
>> > mesa-dev@lists.freedesktop.org
>> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Jason Ekstrand Oct. 13, 2018, 4:27 p.m. UTC | #4
On Sat, Oct 13, 2018 at 11:24 AM Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
wrote:

> On Sat, Oct 13, 2018 at 6:12 PM Jason Ekstrand <jason@jlekstrand.net>
> wrote:
> >
> > On Sat, Oct 13, 2018 at 10:58 AM Bas Nieuwenhuizen <
> bas@basnieuwenhuizen.nl> wrote:
> >>
> >> On Fri, Oct 12, 2018 at 10:38 PM Keith Packard <keithp@keithp.com>
> wrote:
> >> >
> >> > According to the Vulkan spec:
> >> >
> >> > "Vulkan 1.0 initially required all new physical-device-level extension
> >> >  functionality to be structured within an instance extension. In order
> >> >  to avoid using an instance extension, which often requires loader
> >> >  support, physical-device-level extension functionality may be
> >> >  implemented within device extensions"
> >> >
> >> > The code that checks for enabled extension APIs currently only passes
> >> > functions with VkDevice or VkCommandBuffer as their first
> >> > argument. This patch extends that to also allow functions with
> >> > VkPhysicalDevice parameters, in support of the above quote from the
> >> > Vulkan spec.
> >> >
> >>
> >> Also "To obtain a function pointer for a physical-device-level command
> >> from a device extension, an application can use vkGetInstanceProcAddr.
> >> "
> >>
> >> As far as I can tell the device_command member is only to make sure we
> >> return NULL from vkGetDeviceProcAddr, and per the spec (3.1 table 2)
> >> we still have to return NULL there for functions which take
> >> VkPhysicalDevice? So the old behavior seems correct to me.
> >
> >
> > I think anv is ignoring that line in the table which is why it works for
> us.  If only someone wrote tests for these things...
> >
> > I think the correct interpretation would be that any physical device
> functions that are part of a core version or instance extension should
> yield NULL but any physical device functions from a device extension should
> return a valid function pointer.  Sadly, that behavior is kind-of a pain to
> implement. :-(
>
> How would you read that into the spec? As quoted above it explicitly
> tells you to use vkGetInstanceProcAddr for VkPhysicalDevice functions,
> even if they are based on a device extension. (And you cannot really
> use vkGetDeviceProcAddr anyway as the typical usecase is before you've
> created a device).
>

Because I was reading the wrong chunk of spec. :-(  You are correct and
radv is like doing the right thing and anv is doing the wrong thing.

--Jason


> >
> >>
> >> > Signed-off-by: Keith Packard <keithp@keithp.com>
> >> > ---
> >> >  src/amd/vulkan/radv_entrypoints_gen.py | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/src/amd/vulkan/radv_entrypoints_gen.py
> b/src/amd/vulkan/radv_entrypoints_gen.py
> >> > index 377b544c2aa..69e6fc3e0eb 100644
> >> > --- a/src/amd/vulkan/radv_entrypoints_gen.py
> >> > +++ b/src/amd/vulkan/radv_entrypoints_gen.py
> >> > @@ -352,7 +352,7 @@ class Entrypoint(EntrypointBase):
> >> >          self.return_type = return_type
> >> >          self.params = params
> >> >          self.guard = guard
> >> > -        self.device_command = len(params) > 0 and (params[0].type ==
> 'VkDevice' or params[0].type == 'VkQueue' or params[0].type ==
> 'VkCommandBuffer')
> >> > +        self.device_command = len(params) > 0 and (params[0].type ==
> 'VkPhysicalDevice' or params[0].type == 'VkDevice' or params[0].type ==
> 'VkQueue' or params[0].type == 'VkCommandBuffer')
> >> >
> >> >      def prefixed_name(self, prefix):
> >> >          assert self.name.startswith('vk')
> >> > --
> >> > 2.19.1
> >> >
> >> > _______________________________________________
> >> > mesa-dev mailing list
> >> > mesa-dev@lists.freedesktop.org
> >> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >> _______________________________________________
> >> mesa-dev mailing list
> >> mesa-dev@lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sat, Oct 13, 2018 at 11:24 AM Bas Nieuwenhuizen &lt;<a href="mailto:bas@basnieuwenhuizen.nl">bas@basnieuwenhuizen.nl</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Oct 13, 2018 at 6:12 PM Jason Ekstrand &lt;<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>&gt; wrote:<br>
&gt;<br>
&gt; On Sat, Oct 13, 2018 at 10:58 AM Bas Nieuwenhuizen &lt;<a href="mailto:bas@basnieuwenhuizen.nl" target="_blank">bas@basnieuwenhuizen.nl</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Fri, Oct 12, 2018 at 10:38 PM Keith Packard &lt;<a href="mailto:keithp@keithp.com" target="_blank">keithp@keithp.com</a>&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; According to the Vulkan spec:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; &quot;Vulkan 1.0 initially required all new physical-device-level extension<br>
&gt;&gt; &gt;  functionality to be structured within an instance extension. In order<br>
&gt;&gt; &gt;  to avoid using an instance extension, which often requires loader<br>
&gt;&gt; &gt;  support, physical-device-level extension functionality may be<br>
&gt;&gt; &gt;  implemented within device extensions&quot;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; The code that checks for enabled extension APIs currently only passes<br>
&gt;&gt; &gt; functions with VkDevice or VkCommandBuffer as their first<br>
&gt;&gt; &gt; argument. This patch extends that to also allow functions with<br>
&gt;&gt; &gt; VkPhysicalDevice parameters, in support of the above quote from the<br>
&gt;&gt; &gt; Vulkan spec.<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; Also &quot;To obtain a function pointer for a physical-device-level command<br>
&gt;&gt; from a device extension, an application can use vkGetInstanceProcAddr.<br>
&gt;&gt; &quot;<br>
&gt;&gt;<br>
&gt;&gt; As far as I can tell the device_command member is only to make sure we<br>
&gt;&gt; return NULL from vkGetDeviceProcAddr, and per the spec (3.1 table 2)<br>
&gt;&gt; we still have to return NULL there for functions which take<br>
&gt;&gt; VkPhysicalDevice? So the old behavior seems correct to me.<br>
&gt;<br>
&gt;<br>
&gt; I think anv is ignoring that line in the table which is why it works for us.  If only someone wrote tests for these things...<br>
&gt;<br>
&gt; I think the correct interpretation would be that any physical device functions that are part of a core version or instance extension should yield NULL but any physical device functions from a device extension should return a valid function pointer.  Sadly, that behavior is kind-of a pain to implement. :-(<br>
<br>
How would you read that into the spec? As quoted above it explicitly<br>
tells you to use vkGetInstanceProcAddr for VkPhysicalDevice functions,<br>
even if they are based on a device extension. (And you cannot really<br>
use vkGetDeviceProcAddr anyway as the typical usecase is before you&#39;ve<br>
created a device).<br></blockquote><div><br></div><div>Because I was reading the wrong chunk of spec. :-(  You are correct and radv is like doing the right thing and anv is doing the wrong thing.</div><div><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
&gt;<br>
&gt;&gt;<br>
&gt;&gt; &gt; Signed-off-by: Keith Packard &lt;<a href="mailto:keithp@keithp.com" target="_blank">keithp@keithp.com</a>&gt;<br>
&gt;&gt; &gt; ---<br>
&gt;&gt; &gt;  src/amd/vulkan/radv_entrypoints_gen.py | 2 +-<br>
&gt;&gt; &gt;  1 file changed, 1 insertion(+), 1 deletion(-)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; diff --git a/src/amd/vulkan/radv_entrypoints_gen.py b/src/amd/vulkan/radv_entrypoints_gen.py<br>
&gt;&gt; &gt; index 377b544c2aa..69e6fc3e0eb 100644<br>
&gt;&gt; &gt; --- a/src/amd/vulkan/radv_entrypoints_gen.py<br>
&gt;&gt; &gt; +++ b/src/amd/vulkan/radv_entrypoints_gen.py<br>
&gt;&gt; &gt; @@ -352,7 +352,7 @@ class Entrypoint(EntrypointBase):<br>
&gt;&gt; &gt;          self.return_type = return_type<br>
&gt;&gt; &gt;          self.params = params<br>
&gt;&gt; &gt;          self.guard = guard<br>
&gt;&gt; &gt; -        self.device_command = len(params) &gt; 0 and (params[0].type == &#39;VkDevice&#39; or params[0].type == &#39;VkQueue&#39; or params[0].type == &#39;VkCommandBuffer&#39;)<br>
&gt;&gt; &gt; +        self.device_command = len(params) &gt; 0 and (params[0].type == &#39;VkPhysicalDevice&#39; or params[0].type == &#39;VkDevice&#39; or params[0].type == &#39;VkQueue&#39; or params[0].type == &#39;VkCommandBuffer&#39;)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;      def prefixed_name(self, prefix):<br>
&gt;&gt; &gt;          assert self.name.startswith(&#39;vk&#39;)<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt; 2.19.1<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; mesa-dev mailing list<br>
&gt;&gt; &gt; <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
&gt;&gt; &gt; <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; mesa-dev mailing list<br>
&gt;&gt; <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
&gt;&gt; <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>
Jason Ekstrand Oct. 13, 2018, 5:36 p.m. UTC | #5
On Sat, Oct 13, 2018 at 11:27 AM Jason Ekstrand <jason@jlekstrand.net>
wrote:

> On Sat, Oct 13, 2018 at 11:24 AM Bas Nieuwenhuizen <
> bas@basnieuwenhuizen.nl> wrote:
>
>> On Sat, Oct 13, 2018 at 6:12 PM Jason Ekstrand <jason@jlekstrand.net>
>> wrote:
>> >
>> > On Sat, Oct 13, 2018 at 10:58 AM Bas Nieuwenhuizen <
>> bas@basnieuwenhuizen.nl> wrote:
>> >>
>> >> On Fri, Oct 12, 2018 at 10:38 PM Keith Packard <keithp@keithp.com>
>> wrote:
>> >> >
>> >> > According to the Vulkan spec:
>> >> >
>> >> > "Vulkan 1.0 initially required all new physical-device-level
>> extension
>> >> >  functionality to be structured within an instance extension. In
>> order
>> >> >  to avoid using an instance extension, which often requires loader
>> >> >  support, physical-device-level extension functionality may be
>> >> >  implemented within device extensions"
>> >> >
>> >> > The code that checks for enabled extension APIs currently only passes
>> >> > functions with VkDevice or VkCommandBuffer as their first
>> >> > argument. This patch extends that to also allow functions with
>> >> > VkPhysicalDevice parameters, in support of the above quote from the
>> >> > Vulkan spec.
>> >> >
>> >>
>> >> Also "To obtain a function pointer for a physical-device-level command
>> >> from a device extension, an application can use vkGetInstanceProcAddr.
>> >> "
>> >>
>> >> As far as I can tell the device_command member is only to make sure we
>> >> return NULL from vkGetDeviceProcAddr, and per the spec (3.1 table 2)
>> >> we still have to return NULL there for functions which take
>> >> VkPhysicalDevice? So the old behavior seems correct to me.
>> >
>> >
>> > I think anv is ignoring that line in the table which is why it works
>> for us.  If only someone wrote tests for these things...
>> >
>> > I think the correct interpretation would be that any physical device
>> functions that are part of a core version or instance extension should
>> yield NULL but any physical device functions from a device extension should
>> return a valid function pointer.  Sadly, that behavior is kind-of a pain to
>> implement. :-(
>>
>> How would you read that into the spec? As quoted above it explicitly
>> tells you to use vkGetInstanceProcAddr for VkPhysicalDevice functions,
>> even if they are based on a device extension. (And you cannot really
>> use vkGetDeviceProcAddr anyway as the typical usecase is before you've
>> created a device).
>>
>
> Because I was reading the wrong chunk of spec. :-(  You are correct and
> radv is like doing the right thing and anv is doing the wrong thing.
>

Actually, I think anv is doing the right thing too.  Now I have no idea why
Keith was having problems.

--Jason



>
>
>> >
>> >>
>> >> > Signed-off-by: Keith Packard <keithp@keithp.com>
>> >> > ---
>> >> >  src/amd/vulkan/radv_entrypoints_gen.py | 2 +-
>> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >> >
>> >> > diff --git a/src/amd/vulkan/radv_entrypoints_gen.py
>> b/src/amd/vulkan/radv_entrypoints_gen.py
>> >> > index 377b544c2aa..69e6fc3e0eb 100644
>> >> > --- a/src/amd/vulkan/radv_entrypoints_gen.py
>> >> > +++ b/src/amd/vulkan/radv_entrypoints_gen.py
>> >> > @@ -352,7 +352,7 @@ class Entrypoint(EntrypointBase):
>> >> >          self.return_type = return_type
>> >> >          self.params = params
>> >> >          self.guard = guard
>> >> > -        self.device_command = len(params) > 0 and (params[0].type
>> == 'VkDevice' or params[0].type == 'VkQueue' or params[0].type ==
>> 'VkCommandBuffer')
>> >> > +        self.device_command = len(params) > 0 and (params[0].type
>> == 'VkPhysicalDevice' or params[0].type == 'VkDevice' or params[0].type ==
>> 'VkQueue' or params[0].type == 'VkCommandBuffer')
>> >> >
>> >> >      def prefixed_name(self, prefix):
>> >> >          assert self.name.startswith('vk')
>> >> > --
>> >> > 2.19.1
>> >> >
>> >> > _______________________________________________
>> >> > mesa-dev mailing list
>> >> > mesa-dev@lists.freedesktop.org
>> >> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> >> _______________________________________________
>> >> mesa-dev mailing list
>> >> mesa-dev@lists.freedesktop.org
>> >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
>
<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sat, Oct 13, 2018 at 11:27 AM Jason Ekstrand &lt;<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sat, Oct 13, 2018 at 11:24 AM Bas Nieuwenhuizen &lt;<a href="mailto:bas@basnieuwenhuizen.nl" target="_blank">bas@basnieuwenhuizen.nl</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Oct 13, 2018 at 6:12 PM Jason Ekstrand &lt;<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>&gt; wrote:<br>
&gt;<br>
&gt; On Sat, Oct 13, 2018 at 10:58 AM Bas Nieuwenhuizen &lt;<a href="mailto:bas@basnieuwenhuizen.nl" target="_blank">bas@basnieuwenhuizen.nl</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Fri, Oct 12, 2018 at 10:38 PM Keith Packard &lt;<a href="mailto:keithp@keithp.com" target="_blank">keithp@keithp.com</a>&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; According to the Vulkan spec:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; &quot;Vulkan 1.0 initially required all new physical-device-level extension<br>
&gt;&gt; &gt;  functionality to be structured within an instance extension. In order<br>
&gt;&gt; &gt;  to avoid using an instance extension, which often requires loader<br>
&gt;&gt; &gt;  support, physical-device-level extension functionality may be<br>
&gt;&gt; &gt;  implemented within device extensions&quot;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; The code that checks for enabled extension APIs currently only passes<br>
&gt;&gt; &gt; functions with VkDevice or VkCommandBuffer as their first<br>
&gt;&gt; &gt; argument. This patch extends that to also allow functions with<br>
&gt;&gt; &gt; VkPhysicalDevice parameters, in support of the above quote from the<br>
&gt;&gt; &gt; Vulkan spec.<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; Also &quot;To obtain a function pointer for a physical-device-level command<br>
&gt;&gt; from a device extension, an application can use vkGetInstanceProcAddr.<br>
&gt;&gt; &quot;<br>
&gt;&gt;<br>
&gt;&gt; As far as I can tell the device_command member is only to make sure we<br>
&gt;&gt; return NULL from vkGetDeviceProcAddr, and per the spec (3.1 table 2)<br>
&gt;&gt; we still have to return NULL there for functions which take<br>
&gt;&gt; VkPhysicalDevice? So the old behavior seems correct to me.<br>
&gt;<br>
&gt;<br>
&gt; I think anv is ignoring that line in the table which is why it works for us.  If only someone wrote tests for these things...<br>
&gt;<br>
&gt; I think the correct interpretation would be that any physical device functions that are part of a core version or instance extension should yield NULL but any physical device functions from a device extension should return a valid function pointer.  Sadly, that behavior is kind-of a pain to implement. :-(<br>
<br>
How would you read that into the spec? As quoted above it explicitly<br>
tells you to use vkGetInstanceProcAddr for VkPhysicalDevice functions,<br>
even if they are based on a device extension. (And you cannot really<br>
use vkGetDeviceProcAddr anyway as the typical usecase is before you&#39;ve<br>
created a device).<br></blockquote><div><br></div><div>Because I was reading the wrong chunk of spec. :-(  You are correct and radv is like doing the right thing and anv is doing the wrong thing.</div></div></div></blockquote><div><br></div><div>Actually, I think anv is doing the right thing too.  Now I have no idea why Keith was having problems.</div><div><br></div><div>--Jason</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
&gt;<br>
&gt;&gt;<br>
&gt;&gt; &gt; Signed-off-by: Keith Packard &lt;<a href="mailto:keithp@keithp.com" target="_blank">keithp@keithp.com</a>&gt;<br>
&gt;&gt; &gt; ---<br>
&gt;&gt; &gt;  src/amd/vulkan/radv_entrypoints_gen.py | 2 +-<br>
&gt;&gt; &gt;  1 file changed, 1 insertion(+), 1 deletion(-)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; diff --git a/src/amd/vulkan/radv_entrypoints_gen.py b/src/amd/vulkan/radv_entrypoints_gen.py<br>
&gt;&gt; &gt; index 377b544c2aa..69e6fc3e0eb 100644<br>
&gt;&gt; &gt; --- a/src/amd/vulkan/radv_entrypoints_gen.py<br>
&gt;&gt; &gt; +++ b/src/amd/vulkan/radv_entrypoints_gen.py<br>
&gt;&gt; &gt; @@ -352,7 +352,7 @@ class Entrypoint(EntrypointBase):<br>
&gt;&gt; &gt;          self.return_type = return_type<br>
&gt;&gt; &gt;          self.params = params<br>
&gt;&gt; &gt;          self.guard = guard<br>
&gt;&gt; &gt; -        self.device_command = len(params) &gt; 0 and (params[0].type == &#39;VkDevice&#39; or params[0].type == &#39;VkQueue&#39; or params[0].type == &#39;VkCommandBuffer&#39;)<br>
&gt;&gt; &gt; +        self.device_command = len(params) &gt; 0 and (params[0].type == &#39;VkPhysicalDevice&#39; or params[0].type == &#39;VkDevice&#39; or params[0].type == &#39;VkQueue&#39; or params[0].type == &#39;VkCommandBuffer&#39;)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;      def prefixed_name(self, prefix):<br>
&gt;&gt; &gt;          assert self.name.startswith(&#39;vk&#39;)<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt; 2.19.1<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; mesa-dev mailing list<br>
&gt;&gt; &gt; <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
&gt;&gt; &gt; <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; mesa-dev mailing list<br>
&gt;&gt; <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
&gt;&gt; <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>
</blockquote></div></div>
Keith Packard Oct. 14, 2018, 12:49 a.m. UTC | #6
Jason Ekstrand <jason@jlekstrand.net> writes:

> Actually, I think anv is doing the right thing too.  Now I have no idea why
> Keith was having problems.

anv is happily returning a valid pointer and radv is not?

In any case, I've switched to using vkGetInstanceProcAddr for the
VkPhysicalDevice function and it works fine with both drivers.
Jason Ekstrand Oct. 14, 2018, 2:11 a.m. UTC | #7
On October 13, 2018 19:50:00 "Keith Packard" <keithp@keithp.com> wrote:

> Jason Ekstrand <jason@jlekstrand.net> writes:
>
>> Actually, I think anv is doing the right thing too.  Now I have no idea why
>> Keith was having problems.
>
> anv is happily returning a valid pointer and radv is not?
>
> In any case, I've switched to using vkGetInstanceProcAddr for the
> VkPhysicalDevice function and it works fine with both drivers.

Using vkGetInstanceProcAddr is the right thing to do. The fact that anv 
allows you to is a bug which should be investigated and fixed.  I looked at 
it a bit today and I'm still not sure how it's happening.

--Jason
diff mbox series

Patch

diff --git a/src/amd/vulkan/radv_entrypoints_gen.py b/src/amd/vulkan/radv_entrypoints_gen.py
index 377b544c2aa..69e6fc3e0eb 100644
--- a/src/amd/vulkan/radv_entrypoints_gen.py
+++ b/src/amd/vulkan/radv_entrypoints_gen.py
@@ -352,7 +352,7 @@  class Entrypoint(EntrypointBase):
         self.return_type = return_type
         self.params = params
         self.guard = guard
-        self.device_command = len(params) > 0 and (params[0].type == 'VkDevice' or params[0].type == 'VkQueue' or params[0].type == 'VkCommandBuffer')
+        self.device_command = len(params) > 0 and (params[0].type == 'VkPhysicalDevice' or params[0].type == 'VkDevice' or params[0].type == 'VkQueue' or params[0].type == 'VkCommandBuffer')
 
     def prefixed_name(self, prefix):
         assert self.name.startswith('vk')