Skip to content

Commit

Permalink
Merge pull request #7980 from Unity-Technologies/internal/master
Browse files Browse the repository at this point in the history
Internal/master
  • Loading branch information
UnityAljosha authored Oct 24, 2023
2 parents 4d52a1e + d02a0bd commit 6964463
Show file tree
Hide file tree
Showing 292 changed files with 42,996 additions and 4,475 deletions.
3 changes: 3 additions & 0 deletions Packages/com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- Added TYPED_TEXTURE[2D|2D_ARRAY|3D] macros to allow cross platform declaration of explicitly typed Texture[2D|2DArray|3D] resources.

Version Updated
The version number for this package has increased due to a version update of a related graphics package.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,21 @@ class CommandBufferGenerator

// Fuctions for raster (native render passes) only
static List<FunctionInfo> rasterFunctions = new List<FunctionInfo> {
"DrawMesh",
"DrawMultipleMeshes",
"DrawRenderer",
"DrawRendererList",
"DrawProcedural",
"DrawProceduralIndirect",
"DrawMeshInstanced",
"DrawMeshInstancedProcedural",
"DrawMeshInstancedIndirect",
"DrawOcclusionMesh",
new FunctionInfo("DrawMesh", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("DrawMultipleMeshes", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("DrawRenderer", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("DrawRendererList", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("DrawProcedural", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("DrawProceduralIndirect", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("DrawMeshInstanced", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("DrawMeshInstancedProcedural", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("DrawMeshInstancedIndirect", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("DrawOcclusionMesh", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("SetInstanceMultiplier", "", true),
"ClearRenderTarget",
new FunctionInfo("ClearRenderTarget", textureArg : "", modifiesGlobalState : false, triggersRasterization: true),
new FunctionInfo("SetFoveatedRenderingMode", "", true),
new FunctionInfo("ConfigureFoveatedRendering", "", true),
"SetWireframe"
new FunctionInfo("SetWireframe", "", true),
};

// Fuctions for lowlevel (warpper around Commandbuffer) only
Expand Down Expand Up @@ -217,11 +217,12 @@ public interface @type_name@ @base_type@

struct FunctionInfo
{
public FunctionInfo(string name, string textureArg, bool modifiesGlobalState = false)
public FunctionInfo(string name, string textureArg, bool modifiesGlobalState = false, bool triggersRasterization = false)
{
this.name = name;
this.textureArgs = textureArg;
this.modifiesGlobalState = modifiesGlobalState;
this.triggersRasterization = triggersRasterization;
}

public static implicit operator FunctionInfo(string value)
Expand All @@ -235,6 +236,8 @@ public static implicit operator FunctionInfo(string value)
public string textureArgs;
// Indicate if the function modifies global render state.
public bool modifiesGlobalState;
// Indicate if the function actually triggers rasterization and may thus cause pixel shader invocations.
public bool triggersRasterization;
}


Expand Down Expand Up @@ -289,6 +292,11 @@ static void GenerateCommandBufferType(string className, string docString, string
validationCode.Append("ThrowIfGlobalStateNotAllowed(); ");
}

if (info.triggersRasterization)
{
validationCode.Append("ThrowIfRasterNotAllowed(); ");
}

var arguments = method.GetParameters();
bool separator = false;
foreach (var arg in arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,6 @@ static void CollectGraphDebugData(CompilerContextData ctx,
var unversionedName = pointTo.GetName(ctx, inputResource);
var versionedName = unversionedName + " V" + inputResource.version;

if (pointTo.firstUsePassID == pass.passId)
{
passDebug.allocations.Add(unversionedName);
}

if (pointTo.lastUsePassID == pass.passId)
{
passDebug.releases.Add(unversionedName);
}

if (pointTo.lastWritePassID == pass.passId)
{
passDebug.lastWrites.Add(unversionedName);
Expand Down Expand Up @@ -197,6 +187,20 @@ static void CollectGraphDebugData(CompilerContextData ctx,
}
}

foreach (ref readonly var released in pass.LastUsedResources(ctx))
{
ref var pointTo = ref ctx.UnversionedResourceData(released);
string name = pointTo.GetName(ctx, released);
passDebug.releases.Add(name);
}

foreach (ref readonly var allocated in pass.FirstUsedResources(ctx))
{
ref var pointTo = ref ctx.UnversionedResourceData(allocated);
string name = pointTo.GetName(ctx, allocated);
passDebug.releases.Add(name);
}

if (pass.numFragments > 0 && pass.nativePassIndex >= 0)
{
ref var nativePass = ref ctx.nativePassData.ElementAt(pass.nativePassIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,22 @@ internal BaseCommandBuffer(CommandBuffer wrapped, RenderGraphPass executingPass,
internal protected void ThrowIfGlobalStateNotAllowed()
{
#if DEVELOPMENT_BUILD || UNITY_EDITOR
if (m_ExecutingPass != null && !m_ExecutingPass.allowGlobalState) throw new InvalidOperationException("Modifying global state from this command buffer is not allowed. Please ensure your render graph pass allows modifying global state.");
if (m_ExecutingPass != null && !m_ExecutingPass.allowGlobalState) throw new InvalidOperationException($"{m_ExecutingPass.name}: Modifying global state from this command buffer is not allowed. Please ensure your render graph pass allows modifying global state.");
#endif
}

/// <summary>
/// Checks if the Raster Command Buffer has set a valid render target.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if the there are no active render targets.</exception>
internal protected void ThrowIfRasterNotAllowed()
{
#if DEVELOPMENT_BUILD || UNITY_EDITOR
if (m_ExecutingPass != null && !m_ExecutingPass.HasUseTextureFragments()) throw new InvalidOperationException($"{m_ExecutingPass.name}: Using raster commands from a pass with no active render targets is not allowed as it will use an undefined render target state. Please set-up the pass's render targets using UseTextureFragment.");
#endif
}


// Validation when it is unknown if the texture will be read or written
internal protected void ValidateTextureHandle(TextureHandle h)
{
Expand Down
Loading

0 comments on commit 6964463

Please sign in to comment.