Skip to content

Crash in D3D12 BarrierRequest::MAX_SUBRESOURCES #992

Description

@Emaxoso

Terrain3D version

v1.0.2

System information

Godot v4.7.stable - Windows 11 (build 22631) - Multi-window, 2 monitors - Direct3D 12 (Forward+) - dedicated NVIDIA GeForce RTX 5080 (NVIDIA; 32.0.15.9621) - AMD Ryzen 9 5950X 16-Core Processor (32 threads) - 63.94 GiB memory - WASAPI (44100 Hz, Stereo/mono)

Is the issue reproducable in the demo?

Yes

Issue description

Calling Terrain3DData.import_images() with an 8192×8192 heightmap causes the engine to crash with the following fatal error:

ERROR: FATAL: Condition "p_resource->states_ptr->subresource_states.size() > BarrierRequest::MAX_SUBRESOURCES" is true.

Instead of crashing, the import should either complete successfully or fail gracefully with an error.

Steps to reproduce

  • Create a new scene containing only a Terrain3D node.
  • Set the Region Size to 512.
  • Import the demo material and demo assets.
  • Attach the following script to the root node and run the scene.
extends Node3D;

@onready var terrain: Terrain3D = $Terrain3D;

func _ready() -> void:
	const REGION_COUNT := 16;
	const REGION_SIZE := 512;
	const MAP_SIZE := REGION_COUNT * REGION_SIZE;
	
	var image := Image.create_empty(MAP_SIZE, MAP_SIZE, false, Image.FORMAT_RF);
	
	for x: int in MAP_SIZE:
		for y: int in MAP_SIZE:
			var point := Vector2(x, y);
			image.set_pixelv(point, Color(0.0, 0.0, 0.0));
		
	image.save_png("map.png");

	terrain.data.import_images(
		[image, null, null], 
		-(Vector3(MAP_SIZE, 0, MAP_SIZE) / 2.0),
		0, 30
	);

Logs

Terrain3DData#9019:import_images:861: Importing image type TYPE_HEIGHT, size: (8192, 8192), format: 8
Terrain3DData#9019:import_images:863: Applying offset: 0.0, scale: 30.0
Terrain3DRegion#7897:set_location:256: Set location: (-16, -16)
Terrain3DRegion#7897:set_height_map:89: Setting height map for region: (-16, -16)
Terrain3DUtil:get_min_max:177: Calculating minimum and maximum values of the image: (0.0, 0.0)
Terrain3DRegion#7897:set_control_map:98: Setting control map for region: (-16, -16)
Terrain3DRegion#7897:set_color_map:106: Setting color map for region: (-16, -16)
Terrain3DData#9019:add_region:244: Adding region at location (-16, -16), update maps: no

REPEATED LINES....

Terrain3DRegion#9945:set_location:256: Set location: (15, 15)
Terrain3DRegion#9945:set_height_map:89: Setting height map for region: (15, 15)
Terrain3DUtil:get_min_max:177: Calculating minimum and maximum values of the image: (0.0, 0.0)
Terrain3DRegion#9945:set_control_map:98: Setting control map for region: (15, 15)
Terrain3DRegion#9945:set_color_map:106: Setting color map for region: (15, 15)
Terrain3DData#9019:add_region:244: Adding region at location (15, 15), update maps: yes
Terrain3DCollision#3453:build:229: Building collision with Physics Server
Terrain3DMesher:update_aabbs:448: Updating 10 meshes AABBs
Terrain3DInstancer#0670:destroy:388: Destroying all MMIs
Terrain3DInstancer#0670:_update_mmis:18: Updating MMIs for all regions, all meshes
ERROR: Terrain3D#7368:_grab_camera:155: Cannot find the active camera. Set it manually with Terrain3D.set_camera(). Stopping _physics_process()
   at: push_error (core/variant/variant_utility.cpp:1023)
ERROR: FATAL: Condition "p_resource->states_ptr->subresource_states.size() > BarrierRequest::MAX_SUBRESOURCES" is true.
   at: _resource_transition_batch (drivers/d3d12/rendering_device_driver_d3d12.cpp:702)
Terrain3D#7368:_notification:940: NOTIFICATION_CRASH

================================================================
CrashHandlerException: Program crashed with signal 4
Engine version: Godot Engine v4.7.stable.official (5b4e0cb0fd279832bbdd69fed5354d4e5ad26f88)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
Load address: 7ff572dd0000

[1] 7ff6b6e96083 (main+40c6083) - no debug info in PE/COFF executable
[2] 7ffbfc25f846 (ntdll.dll+8f846) - no debug info in PE/COFF executable
[3] 7ffbfc275e9e (ntdll.dll+a5e9e) - no debug info in PE/COFF executable
[4] 7ffbfc1ee8c5 (ntdll.dll+1e8c5) - no debug info in PE/COFF executable
[5] 7ffbfc274e9d (ntdll.dll+a4e9d) - no debug info in PE/COFF executable
[6] 7ff6b415fc9b (main+138fc9b) - no debug info in PE/COFF executable
[7] 7ff6b4161de1 (main+1391de1) - no debug info in PE/COFF executable
[8] 7ff6b60dbb9b (main+330bb9b) - no debug info in PE/COFF executable
[9] 7ff6b60e3b7f (main+3313b7f) - no debug info in PE/COFF executable
[10] 7ff6b60e5663 (main+3315663) - no debug info in PE/COFF executable
[11] 7ff6b6058981 (main+3288981) - no debug info in PE/COFF executable
[12] 7ff6b60b20de (main+32e20de) - no debug info in PE/COFF executable
[13] 7ff6b614a59d (main+337a59d) - no debug info in PE/COFF executable
[14] 7ff6b2e2d541 (main+5d541) - no debug info in PE/COFF executable
[15] 7ff6b2dd2ef0 (main+2ef0) - no debug info in PE/COFF executable
[16] 7ff6b2e22501 (main+52501) - no debug info in PE/COFF executable
[17] 7ff6b2e2253d (main+5253d) - no debug info in PE/COFF executable
[18] 7ff6b2dd10c8 (main+10c8) - no debug info in PE/COFF executable
[19] 7ff6b2dd13f5 (main+13f5) - no debug info in PE/COFF executable
[20] 7ffbfa40259c (kernel32.dll+1259c) - no debug info in PE/COFF executable
[21] 7ffbfc22af77 (ntdll.dll+5af77) - no debug info in PE/COFF executable
[22] -1 (main+-7ff6b2dd0001) - no debug info in PE/COFF executable
-- END OF C++ BACKTRACE --
================================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions