Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4db4cd57 authored by Chia-I Wu's avatar Chia-I Wu Committed by android-build-merger
Browse files

Merge "vulkan: do not use exported functions internally" into nyc-dev

am: e6759c3d

* commit 'e6759c3d':
  vulkan: do not use exported functions internally

Change-Id: I69b3e94ae15ddce28a9e864893ea16caa5b886c5
parents 23878133 e6759c3d
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ LOCAL_SANITIZE := integer


LOCAL_CFLAGS := -DLOG_TAG=\"vulkan\" \
LOCAL_CFLAGS := -DLOG_TAG=\"vulkan\" \
	-DVK_USE_PLATFORM_ANDROID_KHR \
	-DVK_USE_PLATFORM_ANDROID_KHR \
	-DVK_NO_PROTOTYPES \
	-std=c99 -fvisibility=hidden -fstrict-aliasing \
	-std=c99 -fvisibility=hidden -fstrict-aliasing \
	-Weverything -Werror \
	-Weverything -Werror \
	-Wno-padded \
	-Wno-padded \
+1009 −304

File changed.

Preview size limit exceeded, changes collapsed.

+44 −21
Original line number Original line Diff line number Diff line
@@ -94,6 +94,8 @@ bool InitDispatchTable(
#include <algorithm>
#include <algorithm>
#include <log/log.h>
#include <log/log.h>


// to catch mismatches between vulkan.h and this file
#undef VK_NO_PROTOTYPES
#include "api.h"
#include "api.h"


namespace vulkan {«
namespace vulkan {«
@@ -150,15 +152,20 @@ bool InitDispatchTable(
    return success;
    return success;
}
}


»} // namespace api
»} // namespace vulkan

// clang-format off
// clang-format off


namespace {«

// forward declarations needed by GetInstanceProcAddr and GetDeviceProcAddr
{{range $f := AllCommands $}}
{{range $f := AllCommands $}}
  {{if (Macro "IsFunctionExported" $f)}}
  {{if and (Macro "IsFunctionExported" $f) (not (Macro "api.IsIntercepted" $f))}}
    __attribute__((visibility("default")))
    VKAPI_ATTR {{Node "Type" $f.Return}} {{Macro "BaseName" $f}}({{Macro "Parameters" $f}});
    VKAPI_ATTR {{Node "Type" $f.Return}} {{$f.Name}}({{Macro "Parameters" $f}}) {
  {{end}}
{{end}}

{{range $f := AllCommands $}}
  {{if and (Macro "IsFunctionExported" $f) (not (Macro "api.IsIntercepted" $f))}}
    VKAPI_ATTR {{Node "Type" $f.Return}} {{Macro "BaseName" $f}}({{Macro "Parameters" $f}}) {
      {{     if eq $f.Name "vkGetInstanceProcAddr"}}
      {{     if eq $f.Name "vkGetInstanceProcAddr"}}
        {{Macro "api.C++.InterceptInstanceProcAddr" $}}
        {{Macro "api.C++.InterceptInstanceProcAddr" $}}
      {{else if eq $f.Name "vkGetDeviceProcAddr"}}
      {{else if eq $f.Name "vkGetDeviceProcAddr"}}
@@ -171,6 +178,26 @@ bool InitDispatchTable(
  {{end}}
  {{end}}
{{end}}
{{end}}


»}  // anonymous namespace

// clang-format on

»} // namespace api
»} // namespace vulkan

// clang-format off

{{range $f := AllCommands $}}
  {{if (Macro "IsFunctionExported" $f)}}
    __attribute__((visibility("default")))
    VKAPI_ATTR {{Node "Type" $f.Return}} {{$f.Name}}({{Macro "Parameters" $f}}) {
      {{if not (IsVoid $f.Return.Type)}}return §{{end}}
      vulkan::api::{{Macro "BaseName" $f}}({{Macro "Arguments" $f}});
    }

  {{end}}
{{end}}

// clang-format on
// clang-format on
¶{{end}}
¶{{end}}


@@ -512,8 +539,7 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
    {{range $f := AllCommands $}}
    {{range $f := AllCommands $}}
      {{if (Macro "IsGloballyDispatched" $f)}}
      {{if (Macro "IsGloballyDispatched" $f)}}
        if (strcmp(pName, "{{$f.Name}}") == 0) return §
        if (strcmp(pName, "{{$f.Name}}") == 0) return §
          reinterpret_cast<PFN_vkVoidFunction>(§
          reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}});
            vulkan::api::{{Macro "BaseName" $f}});
      {{end}}
      {{end}}
    {{end}}
    {{end}}


@@ -534,16 +560,16 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
        {{/* redirect intercepted functions */}}
        {{/* redirect intercepted functions */}}
        {{else if (Macro "api.IsIntercepted" $f)}}
        {{else if (Macro "api.IsIntercepted" $f)}}
          { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>(§
          { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>(§
            vulkan::api::{{Macro "BaseName" $f}}) },
            {{Macro "BaseName" $f}}) },


        {{/* redirect vkGetInstanceProcAddr to itself */}}
        {{/* redirect vkGetInstanceProcAddr to itself */}}
        {{else if eq $f.Name "vkGetInstanceProcAddr"}}
        {{else if eq $f.Name "vkGetInstanceProcAddr"}}
          { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{$f.Name}}) },
          { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}}) },


        {{/* redirect device functions to themselves as a workaround for
        {{/* redirect device functions to themselves as a workaround for
             layers that do not intercept in their vkGetInstanceProcAddr */}}
             layers that do not intercept in their vkGetInstanceProcAddr */}}
        {{else if (Macro "IsDeviceDispatched" $f)}}
        {{else if (Macro "IsDeviceDispatched" $f)}}
          { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{$f.Name}}) },
          { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}}) },


        {{end}}
        {{end}}
      {{end}}
      {{end}}
@@ -608,11 +634,11 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
      {{     if (Macro "api.IsIntercepted" $f)}}
      {{     if (Macro "api.IsIntercepted" $f)}}
        if (strcmp(pName, "{{$f.Name}}") == 0) return §
        if (strcmp(pName, "{{$f.Name}}") == 0) return §
          reinterpret_cast<PFN_vkVoidFunction>(§
          reinterpret_cast<PFN_vkVoidFunction>(§
            vulkan::api::{{Macro "BaseName" $f}});
            {{Macro "BaseName" $f}});
      {{else if eq $f.Name "vkGetDeviceProcAddr"}}
      {{else if eq $f.Name "vkGetDeviceProcAddr"}}
        if (strcmp(pName, "{{$f.Name}}") == 0) return §
        if (strcmp(pName, "{{$f.Name}}") == 0) return §
          reinterpret_cast<PFN_vkVoidFunction>(§
          reinterpret_cast<PFN_vkVoidFunction>(§
            {{$f.Name}});
            {{Macro "BaseName" $f}});
      {{end}}
      {{end}}
    {{end}}
    {{end}}
  {{end}}
  {{end}}
@@ -627,17 +653,14 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
*/}}
*/}}
{{define "api.C++.Dispatch"}}
{{define "api.C++.Dispatch"}}
  {{AssertType $ "Function"}}
  {{AssertType $ "Function"}}
  {{if (Macro "api.IsIntercepted" $)}}
    {{Error "$.Name should not be generated"}}
  {{end}}


  {{if (Macro "api.IsIntercepted" $)}}// call into api.cpp{{end}}
  {{if not (IsVoid $.Return.Type)}}return §{{end}}
  {{if not (IsVoid $.Return.Type)}}return §{{end}}


  {{if (Macro "api.IsIntercepted" $)}}
    vulkan::api::§
  {{else}}
  {{$p0 := index $.CallParameters 0}}
  {{$p0 := index $.CallParameters 0}}
    vulkan::api::GetData({{$p0.Name}}).dispatch.§
  GetData({{$p0.Name}}).dispatch.§
  {{end}}

  {{Macro "BaseName" $}}({{Macro "Arguments" $}});
  {{Macro "BaseName" $}}({{Macro "Arguments" $}});
{{end}}
{{end}}