|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static string GetAutomaticName(int width, int height, RenderTextureFormat format) |
|
|
|
{ |
|
|
|
return "RenderTarget_" + width + "x" + height + "_" + format.ToString(); |
|
|
|
} |
|
|
|
|
|
|
|
// This method wraps around regular RenderTexture creation.
|
|
|
|
// There is no specific logic applied to RenderTextures created this way.
|
|
|
|
public static RTHandle Alloc( |
|
|
|
|
|
|
bool bindTextureMS = false, |
|
|
|
bool useDynamicScale = false, |
|
|
|
VRTextureUsage vrUsage = VRTextureUsage.None, |
|
|
|
RenderTextureMemoryless memoryless = RenderTextureMemoryless.None |
|
|
|
RenderTextureMemoryless memoryless = RenderTextureMemoryless.None, |
|
|
|
string name = "" |
|
|
|
) |
|
|
|
{ |
|
|
|
bool enableMSAA = msaaSamples != MSAASamples.None; |
|
|
|
|
|
|
bindTextureMS = bindTextureMS, |
|
|
|
useDynamicScale = useDynamicScale, |
|
|
|
vrUsage = vrUsage, |
|
|
|
memorylessMode = memoryless |
|
|
|
memorylessMode = memoryless, |
|
|
|
name = name == "" ? GetAutomaticName(width, height, colorFormat) : name |
|
|
|
}; |
|
|
|
rt.Create(); |
|
|
|
|
|
|
|
|
|
|
bool bindTextureMS = false, |
|
|
|
bool useDynamicScale = false, |
|
|
|
VRTextureUsage vrUsage = VRTextureUsage.None, |
|
|
|
RenderTextureMemoryless memoryless = RenderTextureMemoryless.None |
|
|
|
RenderTextureMemoryless memoryless = RenderTextureMemoryless.None, |
|
|
|
string name = "" |
|
|
|
) |
|
|
|
{ |
|
|
|
bool allocForMSAA = s_ScaledRTSupportsMSAA ? enableMSAA : false; |
|
|
|
|
|
|
bindTextureMS, |
|
|
|
useDynamicScale, |
|
|
|
vrUsage, |
|
|
|
memoryless |
|
|
|
memoryless, |
|
|
|
name |
|
|
|
); |
|
|
|
|
|
|
|
rth.scaleFactor = scaleFactor; |
|
|
|
|
|
|
bool bindTextureMS = false, |
|
|
|
bool useDynamicScale = false, |
|
|
|
VRTextureUsage vrUsage = VRTextureUsage.None, |
|
|
|
RenderTextureMemoryless memoryless = RenderTextureMemoryless.None |
|
|
|
RenderTextureMemoryless memoryless = RenderTextureMemoryless.None, |
|
|
|
string name = "" |
|
|
|
) |
|
|
|
{ |
|
|
|
bool allocForMSAA = s_ScaledRTSupportsMSAA ? enableMSAA : false; |
|
|
|
|
|
|
bindTextureMS, |
|
|
|
useDynamicScale, |
|
|
|
vrUsage, |
|
|
|
memoryless |
|
|
|
memoryless, |
|
|
|
name |
|
|
|
); |
|
|
|
|
|
|
|
rth.scaleFunc = scaleFunc; |
|
|
|
|
|
|
// Internal function
|
|
|
|
static RTHandle AllocAutoSizedRenderTexture( |
|
|
|
int width, |
|
|
|
int height, |
|
|
|
|
|
|
bool bindTextureMS, |
|
|
|
bool useDynamicScale, |
|
|
|
VRTextureUsage vrUsage, |
|
|
|
RenderTextureMemoryless memoryless |
|
|
|
RenderTextureMemoryless memoryless, |
|
|
|
string name |
|
|
|
) |
|
|
|
{ |
|
|
|
// Here user made a mistake in setting up msaa/bindMS, hence the warning
|
|
|
|
|
|
|
bindTextureMS = bindTextureMS, |
|
|
|
useDynamicScale = useDynamicScale, |
|
|
|
vrUsage = vrUsage, |
|
|
|
memorylessMode = memoryless |
|
|
|
memorylessMode = memoryless, |
|
|
|
name = name == "" ? GetAutomaticName(width, height, colorFormat) : name |
|
|
|
}; |
|
|
|
rt.Create(); |
|
|
|
|
|
|
|
|
|
|
bindTextureMS = false, // Somehow, this can be true even if antiAliasing == 1. Leads to Unity-internal binding errors.
|
|
|
|
useDynamicScale = refRT.useDynamicScale, |
|
|
|
vrUsage = refRT.vrUsage, |
|
|
|
memorylessMode = refRT.memorylessMode |
|
|
|
memorylessMode = refRT.memorylessMode, |
|
|
|
name = refRT.name |
|
|
|
}; |
|
|
|
newRT.Create(); |
|
|
|
|
|
|
|