Giter Club home page Giter Club logo

blog's People

Contributors

superzscy avatar

Watchers

 avatar  avatar

blog's Issues

Check SSD

PowerShell

Get-PhysicalDisk | ForEach-Object {
$physicalDisk = $_
$physicalDisk |
Get-Disk |
Get-Partition |
Where-Object DriveLetter |
Select-Object DriveLetter, @{n='MediaType';e={ $physicalDisk.MediaType }}
}

P4 usefull commands

Generate patch

p4 diff2 -u //streamdepot/Dev/...@32696 //streamdepot/Dev/...@32697 > 32697.patch

check current revision

p4 changes -m1 "#have"
p4 changes -m1 //ac3l-remake-data/main/...#have

How to record/extract sound from video

  • Use obs-studio to record the video
  • Open VLC media player, "Media" - "Convert/Save" - "File, Add your video" - "Convert/Save" - "Profile, Audio - Vorbis(OGG)" - "Start"
  • Open Audacity, keep the range you want, clip the others.

UE issues

ShaderCompileWorker FromMsBuild exited with code 6

Try delete directory "Engine\Intermediate\Build\Win64\UE4Editor\Development\VisualStudioDTE" and rebuild.

Your project does not reference ".NETFramework,Version=v4.7.2" framework. Add a reference to ".NETFramework,Version=v4.7.2" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.

Get-ChildItem .\ -Include bin,obj -Recurse | %{ Remove-Item $_.FullName -Force -Recurse }

download speed of Setup.bat is low

setup proxy before running it: set HTTP_PROXY=http://localhost:8889

UE4 debug and profile skills

Memory

FScopedMemoryStats. need to add GlobalDefinitions.Add("ENABLE_MEMORY_SCOPE_STATS=1"); in xx.Target.cs
rhi.DumpMemory
r.DumpRenderTargetPoolMemory

Console Commands

Misc

ToggleDebugCamera
DisableAllScreenMessages/EnableAllScreenMessages
-waitforattach
-ExecCmds="stat unit,log LogTemp Verbose"

Stats

stats.MaxPerGroup

Render

// To get verbose informations about drawcalls. only for dev build. for test build, define ALLOW_PROFILEGPU_IN_TEST
ToggleDrawEvents
r.RHISetGPUCaptureOptions 1 // enable more infos

r.VisualizeOccludedPrimitives 1

dynamicres

r.SecondaryScreenPercentage.GameViewport
r.DynamicRes.OperationMode
r.DynamicRes.FrameTimeBudget

profileGPU //to investigate the breakdown of GPU performance per pass

Stat GPU to see the total gpu impact (overdraw in transparency, cycle cost in Niagara GPU Simulation)
Stat Niagara //is just a basic cost and memory overview
Stat NiagaraEmitters //gives frame information about the emitters
Stat NiagaraSystems //gives frame information about systems.

ConsoleManager.cpp

r.ShadowQuality // 0:off, 1:low(unfiltered), 2:low .. 5:max (default)
r.ScreenPercentage 10 // to quickly check if your`re GPU bound
r.SubsurfaceScattering 0 // to disable subsurface scattering
r.PostProcessAAQuality // 0:off, 1:very low (faster FXAA), 2:low (FXAA), 3:medium (faster TemporalAA), 4:high (default TemporalAA), 5:very high, 6:max
r.AmbientOcclusionLevels 0 // to disable AmbientOcclusion

r.ViewDistanceScale 0.0 - 1.0 // View Distance

// only in development build
ViewMode ShaderComplexity
ViewMode QuadOverdraw

when profiling

Turn off VSync: r.vsync 0
Turn off Frame Rate Smoothing

Network debug

startup arugument: networkversionoverride=123
FNetworkVersion::GetNetworkCompatibleChangelist
FNetworkVersion::GetLocalNetworkVersion
LogNetVersion: ProjectName 1.0.0.0, NetCL: 54239, EngineNetVer: 17, GameNetVer: 0 (Checksum: 4117681995)

to disable code optimization

// add in cpp
PRAGMA_DISABLE_OPTIMIZATION
PRAGMA_ENABLE_OPTIMIZATION

// add in xx.Build.cs
OptimizeCode = CodeOptimization.Never;

日志开关

log LogNetPackageMap VeryVerbose // 打开网络消息日志
log LogPhysics
log LogEQS
log LogStreaming
log LogNavigation
log LogUMG
log LogPlayerController Verbose
log LogRenderTargetPool Display
log LogStreamableManager Verbose

Debug non engine program

#new bat to call GenerateProjectFiles.bat
call "../GenerateProjectFiles.bat" "../../../Game/xx.uproject" -Game -Engine -Platforms=XSX+Win64+PS5 -ShippingConfigs -NoDummyConfigs -2019

debug GenerateProjectFiles by UnrealBuildTool.exe

working directory: Engine\Binaries\DotNET
command arguments: "../../../Game/xx.uproject" -Game -Engine -Platforms=XSX+Win64+PS5 -ShippingConfigs -NoDummyConfigs -2019

debug build Engine project by UnrealBuildTool.exe

working directory: Engine\Source
command arguments: xx XSX Test -WaitMutex -FromMsBuild -2019

UAT log

...\Engine\Programs\AutomationTool\Saved\Logs\Log.txt

Project Launcher

Generate multiple paks: check "Store all contents in a single file(UnrealPak)", uncheck "Generate Chunks"

What are in pak files:
Game\Saved\TmpPackaging\

UE - UGS Setup

设置一个Content Stream, 让美术和策划不必拉取源代码

P4 Stream Path Setting:

share ...
exclude UnrealEngine/Engine/...
share UnrealEngine/Engine/Binaries/...
share UnrealEngine/Engine/Build/...
share UnrealEngine/Engine/Config/...
share UnrealEngine/Engine/Content/...
share UnrealEngine/Engine/Shaders/...
share UnrealEngine/Engine/Plugins/...
exclude UnrealEngine/Engine/Plugins/....h
exclude UnrealEngine/Engine/Plugins/....cpp
exclude UnrealEngine/Engine/Plugins/....cs
share UnrealEngine/Engine/Source/Programs/Shared/MetaData.cs
exclude UnrealEngine/Game/Source/...
share UnrealEngine/Game/Source/*Editor.Target.cs

如果workspace看不到 *Editor.Target.cs, 那UGS就无法启动Editor
image

上述配置有个问题, editor binary提交p4后, UGS依然无法看到记录, 原因为workspace过滤掉了相关代码.
临时解决办法:
1.去掉代码过滤.
2.手动修改CL号为具体代码提交CL

image
最终解决办法: 不过滤代码

Understand CSharp applition

Compilation

C# source file -> CSC.exe -> app.exe
app.exe .text section contains:

  • Intermediate Language
  • metadata

Execution

app.exe -> MSCOREE.dll -> CLR Loaded -> Compils IL to machine code -> run machine code

Conditional Rendering (Predication)

Overview

This is a feature that enables the GPU ranther than the CPU to determine to not draw, copy, or dispatch an object.
The typical use of this feature is with occlusion: if a bounding box is drawn and is occluded, there is no point in drawing the object itself.

while early-z pass remove the unnecessary pixels shading, conditional rendering can remove the overhead of drawing cammand itself,

MySQL root password

MySQL v 5.7 or higher generates a temporary random password after installation and stored that in mysql error log file, located at /var/log/mysqld.log
for an installation by the MySQL Yum repository on CentOS 7.
use below command to see the password:

shell > sudo grep ‘temporary password’ /var/log/mysqld.log

use below mysql command to set the password policy to low:

SET GLOBAL validate_password.policy=LOW;

Get type size in compile time

char (*__kaboom)[sizeof( TYPE )] = 1;

find the compilation error: can not convert 'int' to 'char (*)[xxx]'

xxx will be the sizeof( TYPE )

Useful Regex

.*[^a]$
If you put the ^ symbol at the beginning of brackets, it means "everything except the things in the brackets." $ is simply an anchor to the end.

Keyword New in CSharp

#Usage

  • To create an instance of a type.
  • To hide members that is inherited from a base class.
public class DerivedC : BaseC
{
   new public void Invoke() {}
}
  • To constrain a generic type.
class ItemFactory<T> where T : new()
{
  public T GetNewItem()
  {
    return new T();
  }
}

git trobleshooting

Error message: Make sure you have the correct access rights
use ssh -vv to check which ssh config file is used, add

Host gitlab.hostname.com
  PreferredAuthentications publickey
  IdentityFile path_to_fork_ssh_key

GPU debug

We encounter a rendering issue that one drawcall wirtes color buffer to all black.
From the GPU frame capture, found that the VS output does not match the PS input, one unsed attribute is not past to PS for saving the memory bandwith. so it`s a layout issue.

Fix:
hlslcc-option-flags 0x4000 is used when compiling shader.
HLSLCC_FLAG_SEPARABLE_SHADER_OBJECTS 0x4000 If set, adds location qualifiers to intra-shader varyings.

VS

Before After
out vec4 vs_COLOR0; layout(location = 4) out vec4 vs_COLOR0;
out vec4 vs_COLOR1; layout(location = 5) out vec4 vs_COLOR1;
out vec4 vs_COLOR2; layout(location = 6) out vec4 vs_COLOR2;
out vec4 vs_COLOR3; layout(location = 7) out vec4 vs_COLOR3;

PS

Before After
in vec4 vs_COLOR0; layout(location = 4) in vec4 vs_COLOR0;
in vec4 vs_COLOR2; layout(location = 6) in vec4 vs_COLOR2;
in vec4 vs_COLOR3; layout(location = 7) in vec4 vs_COLOR3;

Mixin VS CRTP

CRPT: Curiously Recurring Template Pattern
e.g. std::enable_shared_from_this

Both are use to add generic functions onto existing class.

CRPT: existing class needs to inherit the CRTP.
Mixin: existing class leaves unchanged.

Modern C++: if statement

Since C++17:

  • init-statements in if/switch
std::vector<int> vec ={1,2,3,4,5};
if(auto it = std::find(vec.begin(), vec.end(), 3); it != vec.end())
{
  std::cout << *it << std::endl;
}
  • constexpr if statement
template<typename T0, typename... T>
void MyPrint(T0 t0, T... t)
{
  std::cout << t0 << std::endl;
  if constexpr (sizeof...(t) > 0) MyPrint(t...);
}

TrinityCore

Client Version 3.3.5(12340)
6852306D5908A9519D61C06BB06A923CF3E46405.zip

https://www.wowhead.com/wotlk/items can be used to check the item id, id is in the url.

https://trinitycore.atlassian.net/wiki/spaces/tc/pages/77971021/Final+Server+Steps

GM commands:
https://trinitycore.atlassian.net/wiki/spaces/tc/pages/2130065/GM+Commands

worldserver.conf
AlwaysMaxSkillForLevel = 1

.additem 51809 4 // 24 slots bag
.gm fly on
.modify speed fly 15

// learn all my class skills
.learn my trainer

// learn riding skills
.learn 34091 // riding 300
.learn 54197 // cold weather flying
.additem 44843 // dragonhawk
.additem 44413 // motorcycle

// learn fishing
.learn 51294
.additem 44050 // fishing pole


// add itemset
.additem set 885 // priest

How to solve UE maximum path size exceeded issue

  1. Start the registry editor (regedit.exe)
  2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
  3. Double-click LongPathsEnabled
  4. Set to 1 and click OK
  5. Reboot and retry to package the project

FPS limiter

minUpdateDiff = 1; //ms
while()
{
  realCurrTime = getMSTime();

  uint32 diff = getMSTimeDiff(realPrevTime, realCurrTime);
  if (diff < minUpdateDiff)
  {
      // sleep until enough time passes that we can update all timers
      std::this_thread::sleep_for(Milliseconds(minUpdateDiff - diff));
      continue;
  }

  sWorld->Update(diff);
  realPrevTime = realCurrTime;
}

CSharp Debug Skills

Check the application commmand arguments and workking directory

Console.WriteLine($"Arguments: {System.Reflection.Assembly.GetExecutingAssembly().Location} {string.Join(", ", Arguments)}\nCurrentDirectory: {System.IO.Directory.GetCurrentDirectory()}");

How to wait until debugger attached

Console.WriteLine("Waiting for debugger to attach");
while (!Debugger.IsAttached)
{
    Thread.Sleep(100);
}
Console.WriteLine("Debugger attached");

Python Notes

List comprehensions with if
[expression for variable_name in iterable if condition]

odds = [i for i in range(10) if i % 2 == 1]
print(odds)
# [1, 3, 5, 7, 9]

sort a tuple list, by the second item

obj_diff_list.sort(key = lambda i:i[1], reverse=True)

UE Code Notes

How to define CVar and callback at same place.
Check "FAutoConsoleCommandWithWorldAndArgs DumpNiagaraComponentsCommand;"

How to access cvar from different cpp

static const auto CVarEnableTickAggregation = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("EnableTickAggregation"));

Get argument at very early time, we need to use special functions rather than FCommandLine

#if !UE_BUILD_SHIPPING
	const TCHAR* CommandLine = ::GetCommandLineW();

	if (FCString::Stristr(CommandLine, TEXT("-ansimalloc")))
	{
		AllocatorToUse = EMemoryAllocatorToUse::Ansi;
	}
#endif

UE stat cmd implementation

in StatsCommand.cpp, just define a static variable then cmds will be handled.

/** Exec used to execute core stats commands on the stats thread. */
static class FStatCmdCore : private FSelfRegisteringExec
{
public:
	/** Console commands, see embeded usage statement **/
	virtual bool Exec( UWorld*, const TCHAR* Cmd, FOutputDevice& Ar ) override
	{
		// Block the thread as this affects external stat states now
		return DirectStatsCommand(Cmd,true,&Ar);
	}
}
StatCmdCoreExec;

shared_ptr deleter usage

It is a convinient that put Open/Close, Start/Stop or Initlize/Uninitialize functions call together, like this:

if (!StartDB())
        return 1;
std::shared_ptr<void> dbHandle(nullptr, [](void*) { StopDB(); });

w coordinate in gl_FragCoord

A homogeneous coordinate is given by: (x, y, z, w), which projects to: (x/w, y/w, z/w). gl_FragCoord stores this projection, but rather than storing the (useless) (w/w) = (1) for the last component, it stores (1/w), to preserve useful information.

Excel tips

Find exclusive items in Column B against Column A:
A|B|=IF(COUNTIF($A:$A, $B1)=0, "Not found in A", "")

std::weak_ptr

  • It has to be used with shared_ptr
  • Use lock() function to get a new shared_ptr saftly, to acess the referenced object.
  • Use cases: cache, observer lists, prevention of shared_ptr cycles.

std::enable_shared_from_this use std::weak_ptr to enable passing shared_ptr within class member function.

How to view the deduced type

  1. Declare an undefined class template.
  2. Instantiate this template.
  3. Find the type value in the error message.
template<int N>
class TSize;
TSize<sizeof(long)> tSize;
error : implicit instantiation of undefined template 'TSize<8>'

template<typename N>
class TD;
auto x = 100;
TD<decltype(x)> xType;
Error message:
error : implicit instantiation of undefined template 'TDef<int>'

C++ lambda

A lambda can only be converted to a function pointer if it does not capture.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.