Added check of atalas size texture before created
This commit is contained in:
parent
67b9d7d0d2
commit
2430559d8c
|
@ -16,6 +16,7 @@
|
||||||
#include <compiler/enable-ue4-macros.h>
|
#include <compiler/enable-ue4-macros.h>
|
||||||
|
|
||||||
#include "Async/ParallelFor.h"
|
#include "Async/ParallelFor.h"
|
||||||
|
#include "DynamicRHI.h"
|
||||||
|
|
||||||
#include "DrawDebugHelpers.h"
|
#include "DrawDebugHelpers.h"
|
||||||
#include "Kismet/KismetSystemLibrary.h"
|
#include "Kismet/KismetSystemLibrary.h"
|
||||||
|
@ -205,7 +206,8 @@ void ACarlaGameModeBase::Tick(float DeltaSeconds)
|
||||||
Recorder->Tick(DeltaSeconds);
|
Recorder->Tick(DeltaSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!IsAtlasTextureValid) {
|
if(!IsAtlasTextureValid)
|
||||||
|
{
|
||||||
CreateAtlasTextures();
|
CreateAtlasTextures();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,7 +256,9 @@ void ACarlaGameModeBase::ParseOpenDrive(const FString &MapName)
|
||||||
Map = carla::opendrive::OpenDriveParser::Load(opendrive_xml);
|
Map = carla::opendrive::OpenDriveParser::Load(opendrive_xml);
|
||||||
if (!Map.has_value()) {
|
if (!Map.has_value()) {
|
||||||
UE_LOG(LogCarla, Error, TEXT("Invalid Map"));
|
UE_LOG(LogCarla, Error, TEXT("Invalid Map"));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Episode->MapGeoReference = Map->GetGeoReference();
|
Episode->MapGeoReference = Map->GetGeoReference();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,17 +382,22 @@ void ACarlaGameModeBase::DebugShowSignals(bool enable)
|
||||||
|
|
||||||
void ACarlaGameModeBase::CreateAtlasTextures()
|
void ACarlaGameModeBase::CreateAtlasTextures()
|
||||||
{
|
{
|
||||||
UE_LOG(LogCarla, Warning, TEXT("ACarlaGameModeBase::CreateAtlasTextures %d %dx%d"), SceneCaptureSensors.Num(), AtlasTextureWidth, AtlasTextureHeight);
|
if(AtlasTextureWidth > 0 && AtlasTextureHeight > 0)
|
||||||
|
|
||||||
FRHIResourceCreateInfo CreateInfo;
|
|
||||||
for(int i = 0; i < kMaxNumTextures; i++)
|
|
||||||
{
|
{
|
||||||
CamerasAtlasTexture[i] = RHICreateTexture2D(AtlasTextureWidth, AtlasTextureHeight, PF_B8G8R8A8, 1, 1, TexCreate_CPUReadback, CreateInfo);
|
UE_LOG(LogCarla, Warning, TEXT("ACarlaGameModeBase::CreateAtlasTextures %d %dx%d"), SceneCaptureSensors.Num(), AtlasTextureWidth, AtlasTextureHeight);
|
||||||
AtlasPixels[i].Init(FColor(), AtlasTextureWidth * AtlasTextureHeight);
|
|
||||||
|
FRHIResourceCreateInfo CreateInfo;
|
||||||
|
for(int i = 0; i < kMaxNumTextures; i++)
|
||||||
|
{
|
||||||
|
CamerasAtlasTexture[i] = RHICreateTexture2D(AtlasTextureWidth, AtlasTextureHeight, PF_B8G8R8A8, 1, 1, TexCreate_CPUReadback, CreateInfo);
|
||||||
|
AtlasPixels[i].Init(FColor(), AtlasTextureWidth * AtlasTextureHeight);
|
||||||
|
}
|
||||||
|
IsAtlasTextureValid = true;
|
||||||
}
|
}
|
||||||
IsAtlasTextureValid = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern FDynamicRHI* GDynamicRHI;
|
||||||
|
|
||||||
void ACarlaGameModeBase::CaptureAtlas()
|
void ACarlaGameModeBase::CaptureAtlas()
|
||||||
{
|
{
|
||||||
ACarlaGameModeBase* This = this;
|
ACarlaGameModeBase* This = this;
|
||||||
|
@ -422,12 +431,19 @@ void ACarlaGameModeBase::CaptureAtlas()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// GDynamicRHI->RHIReadSurfaceData(AtlasTexture, Rect, CurrentAtlasPixels, FReadSurfaceDataFlags(RCM_UNorm, CubeFace_MAX));
|
||||||
|
|
||||||
|
// FRHICommandBeginRenderPass RHICommandBeginRenderPass;
|
||||||
|
// FRHICommandBeginParallelRenderPass RHICommandBeginParallelRenderPass;
|
||||||
|
|
||||||
|
|
||||||
RHICmdList.ReadSurfaceData(
|
RHICmdList.ReadSurfaceData(
|
||||||
AtlasTexture,
|
AtlasTexture,
|
||||||
Rect,
|
Rect,
|
||||||
CurrentAtlasPixels,
|
CurrentAtlasPixels,
|
||||||
FReadSurfaceDataFlags(RCM_UNorm, CubeFace_MAX));
|
FReadSurfaceDataFlags(RCM_UNorm, CubeFace_MAX));
|
||||||
|
|
||||||
|
|
||||||
// PreviousTexture = CurrentTexture;
|
// PreviousTexture = CurrentTexture;
|
||||||
// CurrentTexture = (CurrentTexture + 1) & ~MaxNumTextures;
|
// CurrentTexture = (CurrentTexture + 1) & ~MaxNumTextures;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue