Creating Root Signature failed after changing version 1.1 - direct3d

I mimimized my code to the problem part.
I used to create root signature version 1.0 with no problem. Then I tried to upgrade my code to compatible with root signature version 1.1 if the hardware support.
D3D12_ROOT_DESCRIPTOR1 CBV1rootDescriptor;
CBV1rootDescriptor.ShaderRegister = 0;
CBV1rootDescriptor.RegisterSpace = 0;
CBV1rootDescriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE;
D3D12_ROOT_DESCRIPTOR1 CBV2rootDescriptor;
CBV2rootDescriptor.ShaderRegister = 1;
CBV2rootDescriptor.RegisterSpace = 0;
CBV1rootDescriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE;
D3D12_ROOT_PARAMETER1 rootParam[2];
rootParam[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
rootParam[0].Descriptor = CBV1rootDescriptor;
rootParam[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
rootParam[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
rootParam[1].Descriptor = CBV2rootDescriptor;
rootParam[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
D3D12_FEATURE_DATA_ROOT_SIGNATURE featureData = {};
featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_1;
if (FAILED(device->CheckFeatureSupport(D3D12_FEATURE_ROOT_SIGNATURE, &featureData, sizeof(featureData))))
{
featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_0;
}
D3D12_ROOT_SIGNATURE_DESC1 rootSigDesc = {};
rootSigDesc.NumParameters = _countof(rootParam);
rootSigDesc.pParameters = rootParam;
rootSigDesc.NumStaticSamplers = 0;
rootSigDesc.pStaticSamplers = nullptr;
rootSigDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT;
D3D12_VERSIONED_ROOT_SIGNATURE_DESC VersionedrootSigDesc = {};
VersionedrootSigDesc.Version = featureData.HighestVersion;
VersionedrootSigDesc.Desc_1_1 = rootSigDesc;
ID3DBlob* serializedRootSig = nullptr;
ID3DBlob* errorBlob = nullptr;
ThrowIfFailed(D3DX12SerializeVersionedRootSignature(&VersionedrootSigDesc, featureData.HighestVersion, &serializedRootSig, &errorBlob));
The code will throw if I run like above, I checked featureData.HighestVersion is 1.1. If I forced featureData.HighestVersion to 1.0, the code will pass. And if I remove the second rootParam[1], only use 1 rootParam, even featureData.HighestVersion is 1.1, the code will pass. Does version 1.1 has some restrictions on CBV on root descriptor? (Windows 10 21H2 OS Build 19044.1706, Visual Studio 2022 community 17.2.2)

D3D12_ROOT_DESCRIPTOR1 CBV2rootDescriptor;
CBV2rootDescriptor.ShaderRegister = 1;
CBV2rootDescriptor.RegisterSpace = 0;
CBV1rootDescriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE;
Since I copied and pasted for CBV2, I didn't change CBV1rootDescriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE; to CBV2rootDescriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE; and I didn't initialize CBV2rootDescriptor, so CBV2rootDescriptor.Flags could be random number which cause the creation failed. I found this when I initialize CBV2rootDescriptor to {}, then the failure gone, which made to to look at each assignment again and found CBV1rootDescriptor.Flags didn't change to CBV2rootDescriptor.Flags.

Related

Gradle can't find protobuf generated class (Android DataStore)

I introduced the dependency by referring to the documentation
implementation "androidx.datastore:datastore:1.0.0"
then defined the schema app/src/main/proto/.proto
syntax = "proto3";
option java_package = "com.freedom.android.config.work";
option java_multiple_files = true;
message WorkItemVO {
bool enabled = 1;
string title = 2;
string repeat_interval = 3;
string repeat_interval_timeUnit = 4;
string last_update_time = 5;
string last_update_result = 6;
}
after app build, But build/generated/source/proto/ did not generate WorkItemVO class files.
Can you tell me what I'm missing?

"Failed to get the task for process -1"

am new to working with iOS, so apologies for what may be a simple question. I have an iOS app that recently stopped working with upgrade to iOS 15. I loaded my previous xcode project into the latest version of Xcode and tried loading again on my iPhone. I'm getting an error stating: "Could not launch "my app name"" "failed to get the process for task -1". In details it provides this additional information. Appreciate any thoughts or input!
{
DVTRadarComponentKey = 855031;
IDERunOperationFailingWorker = DBGLLDBLauncher;
RawUnderlyingErrorMessage = "failed to get the task for process -1";
}
--
Analytics Event: com.apple.dt.IDERunOperationWorkerFinished : {
"device_model" = "iPhone11,2";
"device_osBuild" = "15.0 (19A346)";
"device_platform" = "com.apple.platform.iphoneos";
"launchSession_schemeCommand" = Run;
"launchSession_state" = 1;
"launchSession_targetArch" = arm64;
"operation_duration_ms" = 5872;
"operation_errorCode" = 3;
"operation_errorDomain" = IDEDebugSessionErrorDomain;
"operation_errorWorker" = DBGLLDBLauncher;
"operation_name" = IDEiPhoneRunOperationWorkerGroup;
"param_consoleMode" = 0;
"param_debugger_attachToExtensions" = 0;
"param_debugger_attachToXPC" = 0;
"param_debugger_type" = 5;
"param_destination_isProxy" = 0;
"param_destination_platform" = "com.apple.platform.iphoneos";
"param_diag_MainThreadChecker_stopOnIssue" = 0;
"param_diag_MallocStackLogging_enableDuringAttach" = 0;
"param_diag_MallocStackLogging_enableForXPC" = 1;
"param_diag_allowLocationSimulation" = 1;
"param_diag_gpu_frameCapture_enable" = 0;
"param_diag_gpu_shaderValidation_enable" = 0;
"param_diag_gpu_validation_enable" = 1;
"param_diag_memoryGraphOnResourceException" = 0;
"param_diag_queueDebugging_enable" = 0;
"param_diag_runtimeProfile_generate" = 0;
"param_diag_sanitizer_asan_enable" = 0;
"param_diag_sanitizer_tsan_enable" = 0;
"param_diag_sanitizer_tsan_stopOnIssue" = 0;
"param_diag_sanitizer_ubsan_stopOnIssue" = 0;
"param_diag_showNonLocalizedStrings" = 0;
"param_diag_viewDebugging_enabled" = 1;
"param_diag_viewDebugging_insertDylibOnLaunch" = 1;
"param_install_style" = 0;
"param_launcher_UID" = 2;
"param_launcher_allowDeviceSensorReplayData" = 0;
"param_launcher_kind" = 0;
"param_launcher_style" = 0;
"param_launcher_substyle" = 0;
"param_runnable_appExtensionHostRunMode" = 0;
"param_runnable_productType" = "com.apple.product-type.application";
"param_runnable_swiftVersion" = "5.5";
"param_runnable_type" = 2;
"param_testing_launchedForTesting" = 0;
"param_testing_suppressSimulatorApp" = 0;
"param_testing_usingCLI" = 0;
"sdk_canonicalName" = "iphoneos15.0";
"sdk_osVersion" = "15.0";
"sdk_variant" = iphoneos;
}
--
System Information
macOS Version 11.4 (Build 20F71)
Xcode 13.0 (19234) (Build 13A233)
Timestamp: 2021-09-27T11:54:55-07:00

Confusion about Texture2D and ShaderResourceViews

I am new to Direct3D11 and I am currently trying to create a texture programatically within my code using this code I found online:
// Some Constants
int w = 256;
int h = 256;
int bpp = 4;
int *buf = new int[w*h];
//declarations
ID3D11Texture2D* tex;
D3D11_TEXTURE2D_DESC sTexDesc;
D3D11_SUBRESOURCE_DATA tbsd;
// filling the image
for (int i = 0; i<h; i++)
for (int j = 0; j<w; j++)
{
if ((i & 32) == (j & 32))
buf[i*w + j] = 0x00000000;
else
buf[i*w + j] = 0xffffffff;
}
// setting up D3D11_SUBRESOURCE_DATA
tbsd.pSysMem = (void *)buf;
tbsd.SysMemPitch = w*bpp;
tbsd.SysMemSlicePitch = w*h*bpp; // Not needed since this is a 2d texture
// initializing sTexDesc
sTexDesc.Width = w;
sTexDesc.Height = h;
sTexDesc.MipLevels = 1;
sTexDesc.ArraySize = 1;
sTexDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sTexDesc.SampleDesc.Count = 1;
sTexDesc.SampleDesc.Quality = 0;
sTexDesc.Usage = D3D11_USAGE_DEFAULT;
sTexDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
sTexDesc.CPUAccessFlags = 0;
sTexDesc.MiscFlags = 0;
hr = m_pd3dDevice->CreateTexture2D(&sTexDesc, &tbsd, &tex);
and that' all fine and dandy, but I am a bit confused about how to actually load this into the shader. Below I initialized this ID3D11ShaderResourceView:
ID3D11ShaderResourceView* m_pTextureRV = nullptr;
I found on the Microsoft tutorials I need to use the CreateShaderResourceView. But how exactly do I use it? I tried this:
hr = m_pd3dDevice->CreateShaderResourceView(tex, NULL , m_pTextureRV);
but it gives me an error, telling me that m_pTextureRV is not a valid argument for the function. What am I doing wrong here?
The correct way to call that function is:
hr = m_pd3dDevice->CreateShaderResourceView(tex, nullptr, &m_pTextureRV);
Remember that ID3D11ShaderResourceView* is a pointer to an interface. You need a pointer-to-a-pointer to get a new instance of one back.
You should really consider using a COM smart-pointer like Microsoft::WRL::ComPtr instead of raw pointers for these interfaces.
Once you have created the shader resource view for your texture object, then you need to associate it with whatever slot the HLSL expects to find it in. So, for example, if you were to write an HLSL source file as:
Texture2D texture : register( t0 );
SamplerState sampler: register( s0 );
float4 PS(float2 tex : TEXCOORD0) : SV_Target
{
return texture.Sample( sampler, tex );
}
Then compile it as a Pixel Shader, and bind it to the render pipeline via PSSetShader. Then you'd need to call:
ID3D11ShaderResourceView* srv[1] = { m_pTextureRV };
m_pImmediateContext->PSSetShaderResources( 0, 1, srv );
Of course you also need a ID3D11SamplerState* sampler bound as well:
ID3D11SamplerState* m_pSamplerLinear = nullptr;
D3D11_SAMPLER_DESC sampDesc = {};
sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
sampDesc.MinLOD = 0;
sampDesc.MaxLOD = D3D11_FLOAT32_MAX;
hr = m_pd3dDevice->CreateSamplerState( &sampDesc, &m_pSamplerLinear );
Then when you are about to draw:
m_pImmediateContext->PSSetSamplers( 0, 1, &m_pSamplerLinear );
I strongly recommend you check out the DirectX Tool Kit and the tutorials there.

Box2dWeb bodies not colliding

I've implemented Box2dWeb into a Node.js server and everything works fine apart from collisions. When there are 2 players connected their bodies don't collide - just go through each other. Here's the player body creation code:
//World creation
var world = new b2World(new b2Vec2(0, 0));
//Body+Fixture creation
var bodyDef = new b2BodyDef();
bodyDef.type = b2Body.b2_dynamicBody;
bodyDef.position.x = 100;
bodyDef.position.y = 100;
bodyDef.linearDamping = 5;
bodyDef.angularDamping = 1;
var fixDef = new b2FixtureDef();
fixDef.density = 0.001;
fixDef.friction = 1;
fixDef.restitution = 1;
fixDef.shape = new b2CircleShape;
fixDef.shape.SetRadius(8);
var body = world.CreateBody(bodyDef);
body.CreateFixture(fixDef);
Any help is very much appreciated!
EDIT: I've added this code:
var listener = new Box2D.Dynamics.b2ContactListener;
listener.BeginContact = function(contact) {
console.log(contact.GetFixtureA().GetBody().GetUserData());
}
world.SetContactListener(listener);
and once the bodies collide, I get "null" in the console.
OK, that was simple, just as I expected it would be. I changed the code from:
this.world.Step(deltaTime);
to
this.world.Step(deltaTime, 10, 10);

Help required to form Json string in Javascript

Hi i have to create a json sting in javascript like this
{widget_list:[{widget_id:1,new_position:2},{widget_id:2,new_position:3}, . . .]}
using json.org library. Function i am using of this library is
var json_text =
JSON.stringify(uploaded, "", "");
Which creates a perfect json string i am able to generate when there is a no array
function uploaded()
{
}
var uploaded = new Uploaded();
uploaded.widget_id = 1;
uploaded.new_position = 2;
var json_text = JSON.stringify(uploaded, "", "");
when u alert json_text u will get {"widget_id":1,"new_position":2} requirment is just download a file json2.js from json.org for javascript and include it.
so please help some logic issue i am unable to create....
thanks in advance....
uploaded = {};
var a = [];
uploaded.widget_id = 1;
uploaded.new_position = 2;
a[0] = uploaded;
uploaded.widget_id = 2;
uploaded.new_position = 3;
a[1] = uploaded;
uploaded_new = {}
uploaded_new.widget_list = a
alert( JSON.stringify(uploaded_new, "", ""));
alert will give
{"widget_list":[{"widget_id":2,"new_position":3},{"widget_id":2,"new_position":3}]}
I came across this looking for a similar solution, in that it helped. But you need to re-initialize the "uploaded" object, otherwise it over-writes the existing values.
So, with that slight modification, it would be
uploaded = {};
var a = [];
uploaded.widget_id = 1;
uploaded.new_position = 2;
a[0] = uploaded;
**uploaded = {};**
uploaded.widget_id = 2;
uploaded.new_position = 3;
a[1] = uploaded;
uploaded_new = {}
uploaded_new.widget_list = a
alert( JSON.stringify(uploaded_new, "", ""));

Resources