Skip to content

Commit d6d8d7e

Browse files
committed
DX12 : Fix PipelineCache with defaultDepth and remove some dead code
1 parent 6d4db5f commit d6d8d7e

File tree

2 files changed

+9
-27
lines changed

2 files changed

+9
-27
lines changed

h3d/impl/DX12Driver.hx

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ class DxFrame {
191191
public var samplerHeap : ScratchHeap;
192192
public var srvHeapCache : ScratchHeapArray;
193193
public var samplerHeapCache : ScratchHeapArray;
194-
public var availableBuffers : TempBuffer;
195-
public var usedBuffers : TempBuffer;
196194
public var queryHeaps : Array<QueryHeap> = [];
197195
public var queriesPending : Array<Query> = [];
198196
public var queryCurrentHeap : Int;
@@ -529,7 +527,7 @@ class DX12Driver extends h3d.impl.Driver {
529527
public static var INITIAL_BUFFER_ALLOCATOR_SIZE = 2 * 1024 * 1024;
530528
public static var BUFFER_COUNT = #if console 3 #else 2 #end;
531529
public static var DEVICE_NAME = null;
532-
public static var DEBUG = false; // requires dxil.dll when set to true
530+
public static var DEBUG = true; // requires dxil.dll when set to true
533531

534532
public function new() {
535533
window = @:privateAccess dx.Window.windows[0];
@@ -648,23 +646,6 @@ class DX12Driver extends h3d.impl.Driver {
648646
}
649647
beginQueries();
650648

651-
var used = frame.usedBuffers;
652-
var b = frame.availableBuffers;
653-
var prev = null;
654-
while( b != null ) {
655-
if( b.lastUse < frameCount - 120 ) {
656-
b.buffer.release();
657-
b = b.next;
658-
} else {
659-
var n = b.next;
660-
b.next = used;
661-
used = b;
662-
b = n;
663-
}
664-
}
665-
frame.availableBuffers = used;
666-
frame.usedBuffers = null;
667-
668649
transition(frame.backBuffer, RENDER_TARGET);
669650
frame.commandList.iaSetPrimitiveTopology(TRIANGLELIST);
670651

@@ -1001,7 +982,8 @@ class DX12Driver extends h3d.impl.Driver {
1001982
if( w == 0 ) w = 1;
1002983
if( h == 0 ) h = 1;
1003984
initViewport(w, h);
1004-
pipelineBuilder.setRenderTarget(tex, depthEnabled);
985+
var depthBuffer = tex == null ? defaultDepth : tex.depthBuffer;
986+
pipelineBuilder.setRenderTarget(tex, depthEnabled ? depthBuffer : null);
1005987
}
1006988

1007989
function toDxgiDepthFormat( format : hxd.PixelFormat ) {
@@ -1053,7 +1035,8 @@ class DX12Driver extends h3d.impl.Driver {
10531035
frame.commandList.omSetRenderTargets(textures.length, tmp.renderTargets, true, depthEnabled ? getDepthViewFromTexture(t0, depthBinding == ReadOnly) : null);
10541036
initViewport(t0.width, t0.height);
10551037

1056-
pipelineBuilder.setRenderTargets(textures, depthEnabled);
1038+
var depthBuffer = t0 == null ? defaultDepth : t0.depthBuffer;
1039+
pipelineBuilder.setRenderTargets(textures, depthEnabled ? depthBuffer : null);
10571040
}
10581041

10591042
override function setDepth(depthBuffer : h3d.mat.Texture) {

h3d/impl/PipelineCache.hx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,10 @@ class PipelineBuilder {
152152
return d;
153153
}
154154

155-
public function setRenderTarget( tex : h3d.mat.Texture, depthEnabled : Bool ) {
155+
public function setRenderTarget( tex : h3d.mat.Texture, depth : h3d.mat.Texture ) {
156156
signature.setI32(PSIGN_RENDER_TARGETS, tex == null ? 0 : getRTBits(tex));
157157
signature.setI32(PSIGN_RENDER_TARGETS + 4, 0);
158-
var format = tex == null || !depthEnabled ? 0 : tex.depthBuffer.format.getIndex();
159-
signature.setI32(PSIGN_DEPTH_TARGET_FORMAT, format);
158+
signature.setI32(PSIGN_DEPTH_TARGET_FORMAT, depth == null ? 0 : depth.format.getIndex());
160159
needFlush = true;
161160
}
162161

@@ -171,14 +170,14 @@ class PipelineBuilder {
171170
needFlush = true;
172171
}
173172

174-
public function setRenderTargets( textures : Array<h3d.mat.Texture>, depthEnabled : Bool ) {
173+
public function setRenderTargets( textures : Array<h3d.mat.Texture>, depth : h3d.mat.Texture ) {
175174
var bits = 0;
176175
for( i => t in textures )
177176
signature.setUI8(PSIGN_RENDER_TARGETS + i, getRTBits(t));
178177
for ( i in textures.length...8)
179178
signature.setUI8(PSIGN_RENDER_TARGETS + i, 0);
180179
var tex = textures[0];
181-
var format = tex == null || !depthEnabled ? 0 : tex.depthBuffer.format.getIndex();
180+
var format = depth == null ? 0 : depth.format.getIndex();
182181
signature.setI32(PSIGN_DEPTH_TARGET_FORMAT, format);
183182
needFlush = true;
184183
}

0 commit comments

Comments
 (0)