This repository has been archived by the owner on Aug 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
unreal426_on_rpi4.patch
245 lines (233 loc) · 8.82 KB
/
unreal426_on_rpi4.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
diff --git a/Engine/Source/Developer/Linux/LinuxTargetPlatform/Classes/LinuxTargetSettings.h b/Engine/Source/Developer/Linux/LinuxTargetPlatform/Classes/LinuxTargetSettings.h
index d8ae37eec2e..74777b463d7 100644
--- a/Engine/Source/Developer/Linux/LinuxTargetPlatform/Classes/LinuxTargetSettings.h
+++ b/Engine/Source/Developer/Linux/LinuxTargetPlatform/Classes/LinuxTargetSettings.h
@@ -45,4 +45,13 @@ public:
*/
UPROPERTY(EditAnywhere, config, Category=Rendering)
TArray<FString> TargetedRHIs;
+
+ UPROPERTY(EditAnywhere, config, Category = Textures, meta = (DisplayName = "Cook DXT Textures"))
+ bool bCookDXTTextures;
+
+ UPROPERTY(EditAnywhere, config, Category = Textures, meta = (DisplayName = "Cook BC Textures"))
+ bool bCookBCTextures;
+
+ UPROPERTY(EditAnywhere, config, Category = Textures, meta = (DisplayName = "Cook ETC2 Textures"))
+ bool bCookETC2Textures;
};
diff --git a/Engine/Source/Developer/Linux/LinuxTargetPlatform/Private/LinuxTargetPlatform.h b/Engine/Source/Developer/Linux/LinuxTargetPlatform/Private/LinuxTargetPlatform.h
index fc6f3e45eaa..fca6c4971c7 100644
--- a/Engine/Source/Developer/Linux/LinuxTargetPlatform/Private/LinuxTargetPlatform.h
+++ b/Engine/Source/Developer/Linux/LinuxTargetPlatform/Private/LinuxTargetPlatform.h
@@ -28,6 +28,13 @@
class UTextureLODSettings;
+namespace LinuxTextureFormats
+{
+ static FName NameETC2RGB(TEXT("ETC2_RGB"));
+ static FName NameETC2RGBA(TEXT("ETC2_RGBA"));
+ static FName NameBGRA8(TEXT("BGRA8"));
+}
+
/**
* Template for Linux target platforms
*/
@@ -296,6 +303,55 @@ public:
{
// just use the standard texture format name for this texture
GetDefaultTextureFormatNamePerLayer(OutFormats.AddDefaulted_GetRef(), this, InTexture, EngineSettings, true);
+ bool bCookDXTTextures = true;
+ GConfig->GetBool(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("bCookDXTTextures"), bCookDXTTextures, GEngineIni);
+ bool bCookBCTextures = true;
+ GConfig->GetBool(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("bCookBCTextures"), bCookBCTextures, GEngineIni);
+ bool bCookETC2Textures = false;
+ GConfig->GetBool(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("bCookETC2Textures"), bCookETC2Textures, GEngineIni);
+
+ for (TArray<FName>& LayerNames : OutFormats)
+ {
+ for (int32 NameIndex = LayerNames.Num() - 1; NameIndex >= 0; NameIndex--)
+ {
+ const FString Name = LayerNames[NameIndex].ToString();
+ if (Name.Contains("DXT"))
+ {
+ if (!bCookDXTTextures)
+ {
+ if (bCookETC2Textures)
+ {
+ if (Name == "DXT1")
+ {
+ LayerNames[NameIndex] = LinuxTextureFormats::NameETC2RGB;
+ }
+ else
+ {
+ LayerNames[NameIndex] = LinuxTextureFormats::NameETC2RGBA;
+ }
+ }
+ else
+ {
+ LayerNames[NameIndex] = LinuxTextureFormats::NameBGRA8;
+ }
+ }
+ }
+ else if (Name.StartsWith("BC"))
+ {
+ if (!bCookBCTextures)
+ {
+ if (bCookETC2Textures)
+ {
+ LayerNames[NameIndex] = LinuxTextureFormats::NameETC2RGB;
+ }
+ else
+ {
+ LayerNames[NameIndex] = LinuxTextureFormats::NameBGRA8;
+ }
+ }
+ }
+ }
+ }
}
}
@@ -306,6 +362,54 @@ public:
{
// just use the standard texture format name for this texture
GetAllDefaultTextureFormats(this, OutFormats, true);
+ bool bCookDXTTextures = true;
+ GConfig->GetBool(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("bCookDXTTextures"), bCookDXTTextures, GEngineIni);
+ bool bCookBCTextures = true;
+ GConfig->GetBool(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("bCookBCTextures"), bCookBCTextures, GEngineIni);
+ bool bCookETC2Textures = false;
+ GConfig->GetBool(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("bCookETC2Textures"), bCookETC2Textures, GEngineIni);
+
+ for (int32 NameIndex = OutFormats.Num() - 1; NameIndex >= 0; NameIndex--)
+ {
+ const FString Name = OutFormats[NameIndex].ToString();
+ if (Name.Contains("DXT"))
+ {
+ if (!bCookDXTTextures)
+ {
+ if (bCookETC2Textures)
+ {
+ if (Name == "DXT1")
+ {
+ OutFormats[NameIndex] = LinuxTextureFormats::NameETC2RGB;
+ }
+ else
+ {
+ OutFormats[NameIndex] = LinuxTextureFormats::NameETC2RGBA;
+ }
+ }
+ else
+ {
+ OutFormats.RemoveAt(NameIndex);
+ }
+
+ }
+
+ }
+ else if (Name.StartsWith("BC"))
+ {
+ if (!bCookBCTextures)
+ {
+ if (bCookETC2Textures)
+ {
+ OutFormats[NameIndex] = LinuxTextureFormats::NameETC2RGB;
+ }
+ else
+ {
+ OutFormats.RemoveAt(NameIndex);
+ }
+ }
+ }
+ }
}
}
diff --git a/Engine/Source/Developer/Linux/LinuxTargetPlatform/Private/LinuxTargetPlatformModule.cpp b/Engine/Source/Developer/Linux/LinuxTargetPlatform/Private/LinuxTargetPlatformModule.cpp
index 9919559e3f9..9c1a8ef54bc 100644
--- a/Engine/Source/Developer/Linux/LinuxTargetPlatform/Private/LinuxTargetPlatformModule.cpp
+++ b/Engine/Source/Developer/Linux/LinuxTargetPlatform/Private/LinuxTargetPlatformModule.cpp
@@ -63,6 +63,21 @@ public:
GConfig->GetArray(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("TargetedRHIs"), TargetSettings->TargetedRHIs, GEngineIni);
TargetSettings->AddToRoot();
+ if (!GConfig->GetBool(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("bCookDXTTextures"), TargetSettings->bCookDXTTextures, GEngineIni))
+ {
+ TargetSettings->bCookDXTTextures = true;
+ }
+
+ if (!GConfig->GetBool(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("bCookBCTextures"), TargetSettings->bCookBCTextures, GEngineIni))
+ {
+ TargetSettings->bCookBCTextures = true;
+ }
+
+ if (!GConfig->GetBool(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("bCookETC2Textures"), TargetSettings->bCookETC2Textures, GEngineIni))
+ {
+ TargetSettings->bCookETC2Textures = true;
+ }
+
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
if (SettingsModule != nullptr)
diff --git a/Engine/Source/Runtime/RHI/Public/RHIDefinitions.h b/Engine/Source/Runtime/RHI/Public/RHIDefinitions.h
index 5283f726dd2..6e8c5fc953f 100644
--- a/Engine/Source/Runtime/RHI/Public/RHIDefinitions.h
+++ b/Engine/Source/Runtime/RHI/Public/RHIDefinitions.h
@@ -1180,6 +1180,7 @@ enum class EGpuVendorId
Arm = 0x13B5,
Qualcomm = 0x5143,
Intel = 0x8086,
+ Broadcom = 0x14e4,
};
/** An enumeration of the different RHI reference types. */
@@ -1771,6 +1772,7 @@ inline EGpuVendorId RHIConvertToGpuVendorId(uint32 VendorId)
case EGpuVendorId::Arm:
case EGpuVendorId::Qualcomm:
case EGpuVendorId::Intel:
+ case EGpuVendorId::Broadcom:
return (EGpuVendorId)VendorId;
default:
diff --git a/Engine/Source/Runtime/VulkanRHI/Private/Linux/VulkanLinuxPlatform.cpp b/Engine/Source/Runtime/VulkanRHI/Private/Linux/VulkanLinuxPlatform.cpp
index 061e8f11aba..09c048d2691 100644
--- a/Engine/Source/Runtime/VulkanRHI/Private/Linux/VulkanLinuxPlatform.cpp
+++ b/Engine/Source/Runtime/VulkanRHI/Private/Linux/VulkanLinuxPlatform.cpp
@@ -18,6 +18,9 @@ static bool GForceEnableDebugMarkers = false;
void* FVulkanLinuxPlatform::VulkanLib = nullptr;
bool FVulkanLinuxPlatform::bAttemptedLoad = false;
+bool FVulkanLinuxPlatform::bHasBCTextures = true;
+bool FVulkanLinuxPlatform::bHasASTCTextures = false;
+
bool FVulkanLinuxPlatform::IsSupported()
{
@@ -252,3 +255,13 @@ void FVulkanLinuxPlatform::WriteCrashMarker(const FOptionalVulkanDeviceExtension
}
}
}
+
+void FVulkanLinuxPlatform::CheckDeviceDriver(uint32 DeviceIndex, EGpuVendorId VendorId, const VkPhysicalDeviceProperties& Props)
+{
+ // RPI4B does not support BC Textures
+ if (VendorId == EGpuVendorId::Broadcom)
+ {
+ bHasBCTextures = false;
+ bHasASTCTextures = true;
+ }
+}
diff --git a/Engine/Source/Runtime/VulkanRHI/Private/Linux/VulkanLinuxPlatform.h b/Engine/Source/Runtime/VulkanRHI/Private/Linux/VulkanLinuxPlatform.h
index 62a7570aba6..0e082a25933 100644
--- a/Engine/Source/Runtime/VulkanRHI/Private/Linux/VulkanLinuxPlatform.h
+++ b/Engine/Source/Runtime/VulkanRHI/Private/Linux/VulkanLinuxPlatform.h
@@ -38,6 +38,10 @@ class FVulkanLinuxPlatform : public FVulkanGenericPlatform
public:
static bool IsSupported();
+ static void CheckDeviceDriver(uint32 DeviceIndex, EGpuVendorId VendorId, const VkPhysicalDeviceProperties& Props);
+ static bool SupportsBCTextureFormats() { return bHasBCTextures; }
+ static bool SupportsASTCTextureFormats() { return bHasASTCTextures; }
+
static bool LoadVulkanLibrary();
static bool LoadVulkanInstanceFunctions(VkInstance inInstance);
static void FreeVulkanLibrary();
@@ -76,6 +80,8 @@ public:
protected:
static void* VulkanLib;
static bool bAttemptedLoad;
+ static bool bHasBCTextures;
+ static bool bHasASTCTextures;
};
typedef FVulkanLinuxPlatform FVulkanPlatform;