SharpDX debugging: "Device.CreateWithSwapChain()" versus "new SwapChain()"? - c#

If I create my Device and my SwapChain like this:
SwapChain _swapChain;
Device _device;
// SwapChain description
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(500, 300, new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = _windowHandle,
SampleDescription = new SampleDescription(1, 0),
Usage = Usage.RenderTargetOutput
};
Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.Debug,
desc, out _device, out _swapChain);
I get the expected debugging text:
Now if I create my Device and my SwapChain like this:
Factory _factory = new Factory();
Adapter adapter = _factory.GetAdapter(0);
SwapChain _swapChain;
Device _device = new Device(adapter, DeviceCreationFlags.Debug);
// SwapChain description
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(500, 300, new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = _windowHandle,
SampleDescription = new SampleDescription(1, 0),
Usage = Usage.RenderTargetOutput
};
_swapChain = new SwapChain(_factory, _device, desc);
I don't get the expected debugging text:
In addition to not getting the expected debugging text, I get a load of new messages in my output:
First-chance exception at 0x7631C42D in Tester.exe: Microsoft C++ exception: _com_error at memory location 0x064EEC28.
First-chance exception at 0x7631C42D in Tester.exe: Microsoft C++ exception: _com_error at memory location 0x064EED6C.
First-chance exception at 0x7631C42D in Tester.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
D3D11 ERROR: ID3D11Device::OpenSharedResource: Returning E_INVALIDARG, meaning invalid parameters were passed. [ STATE_CREATION ERROR #381: DEVICE_OPEN_SHARED_RESOURCE_INVALIDARG_RETURN]
D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets: Resource being set to OM RenderTarget slot 0 is inaccessible because of a previous call to ReleaseSync or GetDC. [ STATE_SETTING WARNING #9: DEVICE_OMSETRENDERTARGETS_HAZARD]
D3D11 WARNING: ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 0, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here. [ EXECUTION WARNING #3146081: DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET]
D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets: Resource being set to OM RenderTarget slot 0 is inaccessible because of a previous call to ReleaseSync or GetDC. [ STATE_SETTING WARNING #9: DEVICE_OMSETRENDERTARGETS_HAZARD]
Where the last message repeats itself every frame...
Why is this happening? What's the difference between the 2 creation methods? How can I use the second creation method properly?
PS: I want to use the second creation method because I need the device to determine anti-aliasing settings...
PPS: In case it's needed, here's the code that creates the RenderTargetView:
using (Texture2D backBuffer = _swapChain.GetBackBuffer<Texture2D>(0))
{
_renderTargetView = new RenderTargetView(_device, backBuffer);
}
_context = _device.ImmediateContext;
_context.OutputMerger.SetRenderTargets(_renderTargetView);
_context.Rasterizer.SetViewport(0, 0, 500, 300);

Using the second method of Device creating, replacing
Device _device = new Device(adapter, DeviceCreationFlags.Debug);
with
Device _device = new Device(DriverType.Hardware, DeviceCreationFlags.Debug);
makes the debug text appear again. It also seems to remove the warning messages and the first-chance exceptions
I must say this in an extremely subtle difference, which I only found through comparing the 2 Graphics Event Lists...

Related

SharpDX SwapChain1 AccessViolationException

So I try to create a SwapChain1 in SharpDX.
Here is the Code:
SwapChainDescription1 desc = new()
{
Width = toSetSize.Value.Width,
Height = toSetSize.Value.Height,
Format = Format.R8G8B8A8_UNorm,
Stereo = false,
SampleDescription = new SampleDescription(1, 0),
Usage = Usage.BackBuffer | Usage.RenderTargetOutput,
BufferCount = 1,
Scaling = Scaling.Stretch,
SwapEffect = SwapEffect.Discard
};
SwapChainFullScreenDescription scd = new SwapChainFullScreenDescription()
{
RefreshRate = new Rational(60, 1),
Scaling = DisplayModeScaling.Stretched,
Windowed = false
};
using (var dxgiDevice2 = device.QueryInterface<SharpDX.DXGI.Device2>())
using (var dxgiAdapter = dxgiDevice2.Adapter)
using (var dxgiFactory2 = dxgiAdapter.GetParent<SharpDX.DXGI.Factory2>())
{
res = new SwapChain1(dxgiAdapter.GetParent<SharpDX.DXGI.Factory2>(), device, Window.Handle, ref desc, scd);
return res;
}
my issue is, this code throws a AccessViolationException with the Attempted to read or write corrupted memory stuff.
What am i doing wrong?
How can i fix this?
I tried:
Changing the Parameters inside of "desc" and "scd"
Edit: So i got a step further, seemingly factory.NativePointer was IntPtr.Zero, i have updated the code, hope this helps...
Edit2: Okay one step closer, again, i enabled Debugging from native code and got this:
Exception called at 0x759CE292 in Demo.exe: Microsoft C++ Exception: _com_error at location 0x0297C5B8.
Exception called at 0x6BA81D22 (dxgi.dll) in Demo.exe: 0xC0000005: Access violation at position 0x000000B8.
Untranslated (german):
Ausnahme ausgelöst bei 0x759CE292 in Demo.exe: Microsoft C++-Ausnahme: _com_error bei Speicherort 0x0297C5B8.
Ausnahme ausgelöst bei 0x6BA81D22 (dxgi.dll) in Demo.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x000000B8.
Fixed it by doing this before returning the new SwapChain:
Window.TopMost = false;
Window.FormBorderStyle = FormBorderStyle.Fixed3D;

UWP AudioGraph setup not working in all devices, HRESULT: 0x88960001 thrown on AddOutgoingConnection

I'm having trouble with a AudioGraph in a UWP app. My trouble is that when I'm adding adding an Outgoing Connection to my input device node I get a Exception thrown with HRESULT: 0x88960001.
Using trial and error I figured out that the problem is with the MediaEncoding profile I set on both the input and output node... but I have now 2 settings only work on one machine and the other only works on another machine... I needed the audio to be Single Channel, 16bit sample with a 16K sample in PCM.
The code I'm using is fairly simple and was based on samples that exist online, the thing is it works only on some microphones and not others... I needed it to be generic and have always the same output so that I can input that to my service endpoint.
I left the 2 AudioEncodingProperties settings there (one of them commented out)
var result = await AudioGraph.CreateAsync(
new AudioGraphSettings(AudioRenderCategory.Media));
if (result.Status == AudioGraphCreationStatus.Success)
{
this.graph = result.Graph;
var microphone = await DeviceInformation.CreateFromIdAsync(
MediaDevice.GetDefaultAudioCaptureId(AudioDeviceRole.Default));
// Low gives us 1 channel, 16-bits per sample, 16K sample rate.
var outProfile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.Low);
//outProfile.Audio = AudioEncodingProperties.CreatePcm(16000, 1, 16);
outProfile.Audio = AudioEncodingProperties.CreatePcm(44100, 2, 32);
var inProfile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.Low);
//inProfile.Audio = AudioEncodingProperties.CreatePcm(16000, 1, 16);
inProfile.Audio = AudioEncodingProperties.CreatePcm(44100, 2, 32);
var outputResult = await this.graph.CreateFileOutputNodeAsync(file,
outProfile);
if (outputResult.Status == AudioFileNodeCreationStatus.Success)
{
this.outputNode = outputResult.FileOutputNode;
var inputResult = await this.graph.CreateDeviceInputNodeAsync(
MediaCategory.Speech,
inProfile.Audio,
microphone);
if (inputResult.Status == AudioDeviceNodeCreationStatus.Success)
{
//EXEPTION IS THROWN HERE
inputResult.DeviceInputNode.AddOutgoingConnection(
this.outputNode);
this.graph.Start();
}
}
}
else
{
throw new Exception("Could not create AudioGraph");
}
Thank you guys for our help
Instead of constructing the inputResult with the inProfile.Audio object, try using the default encoding properties for the graph:
var enc = graph.EncodingProperties;
CreateAudioDeviceInputNodeResult deviceInputNodeResult = await graph.CreateDeviceInputNodeAsync(MediaCategory.Media, enc, this.outputNode);
I had a similar issue and this cleared things up, and allowed the audio to be input from any device without specifying the encoding profile.

Updating Azure Batch autoscale formula once pool exists

I can create a pool with an autoscale formula fine. The code for this is as follows.
var pool = client.PoolOperations.CreatePool(poolName, vmsize, new CloudServiceConfiguration(osFamily, osVersion));
pool.TaskSchedulingPolicy = new TaskSchedulingPolicy(ComputeNodeFillType.Pack);
pool.AutoScaleFormula = autoscaleFormula;
pool.AutoScaleEnabled = true;
pool.AutoScaleEvaluationInterval = new TimeSpan(0, 0, 5, 0);
pool.Commit();
However if once the pool exists, I try and update the AutoScale formula, I get an error. The error is
{"The property AutoScaleFormula cannot be modified while the object is
in the Bound state."}
The code is
var client = BatchClient.Open(GetCloudSharedKeyCredentials(primary));
var pool = client.PoolOperations.GetPool(poolName);
pool.AutoScaleFormula = formula;
pool.AutoScaleEnabled = true;
pool.AutoScaleEvaluationInterval = new TimeSpan(0, 0, 5, 0);
pool.Commit();
This used to work before I updated to the latest version of the Azure Batch library. Has anyone got any experience of Azure Batch and can advise why I'm getting this error?
You can use the PoolOperations.EnableAutoScale method directly.
For your example, you could use the following:
var client = BatchClient.Open(GetCloudSharedKeyCredentials(primary));
client.Pooloperations.EnableAutoScale(poolName, formula, TimeSpan.FromMinutes(5));

DirectX 11 initialisation "works" and fails on rendering only

Does anybody know why device creation for using DirectX11 works, even though the hardware doesn't support it? I have the following simplified code (this uses SlimDx, but I guess the language is of second importance here:
var form = frm;
form.Resize += form_Resize;
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = form.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain);
device.Factory.SetWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll);
Resize(form.ClientSize);
sprite = new SpriteRendererSlimDx(device, m_lock);
var textBlock = new TextBlockRendererSlimDx(sprite, "Arial", FontWeight.Bold, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 16);
MessagePump.Run(form, () =>
{
device.ImmediateContext.ClearRenderTargetView(renderView, Color.DarkBlue);
textBlock.DrawString("Hello World", Vector2.Zero, Color.Red);
sprite.Flush();
swapChain.Present(0, PresentFlags.None);
});
The code opens a window and draws some text. It works fine on Graphics Cards supporting Feature Level 11.0, but if I run the same code on my aging ATI Radeon HD 4550, which only supports Feature Level 10.1, the device driver locks up and windows restarts the display driver.
The issue is not with the (in the example not shown) text rendering, but happens for rendering triangles, too. Debugging shows that the lockup happens on the swapChain.Present() call.
Directx 11 Compatiblilty suggests that I might be having a problem with using Shader Level 5 (which I'm trying to use), but generally my question is: Why don't I get an ordinary error message if something is not supported? The driver shouldn't attempt to compile Shader Level 5, if the card cannot do it, should it?
Update
The error also seems to happen if I only use shader level 4.

Delayed delivery with ActiveMQ 5.3 and NMS

I'm attempting to use the new delayed delivery functionality from NMS.
The schedulerSupport attribute has been set in the config file, and I'm using the following code to attempt to delay delivery of a message until the date/time chosen by the user is reached.
The code (which does not seem to be working currently) is as follows:
var timeDelay = dateTimePicker.Value.Subtract(DateTime.Now).TotalMilliseconds;
var message = topicPublisher.CreateTextMessage();
message.Properties["AMQ_SCHEDULED_DELAY"] = timeDelay;
message.Text = CM.ToXMLString();
topicPublisher.Send(message);
Can you point out what might be incorrect within this example?
Many thanks!
I don't see anything obvious from the code provided.
You could try turning up the logging in the broker to see if the scheduler receives the message and that the values are correct, that would also confirm that you have indeed enabled scheduler support. You could also try creating a small java program that does something similar to determine if the NMS client is behaving correctly.
I assume you have a consumer running and its connection object has been started?
Regards
Tim.
www.fusesource.com
Thanks for your help with this Tim. I have found the cause of the issue. Slightly delayed response on my part - I had to concentrate on other areas of work, but I have today managed to come back to this.
The issue is the C# ".TotalMilliseconds" function - this returns a fractional total.partial milliseconds value, which it is apparent that ActiveMQ is not fond of.
Now I'm converting this millisecond value to an integer, the delayed messaging is working as required.
Log Excerpt Below:
2011-03-07 10:14:44,186 | DEBUG | quasar adding destination: topic://REDACTED | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///REDACTED:50161
2011-03-07 10:14:44,576 | DEBUG | Error occured while processing async command: ActiveMQTextMessage {commandId = 4, responseRequired = false, messageId = ID:HL003323-50159-634350896828327757-0:0:1:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:HL003323-50159-634350896828327757-0:0:1:1, destination = topic://REDACTED, transactionId = null, expiration = 0, timestamp = 1299492884437, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId = null, replyTo = null, persistent = false, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = org.apache.activemq.util.ByteSequence#1ae0436, dataStructure = null, redeliveryCounter = 0, size = 0, properties = {targetModule=HL.Services.Blackbird.OrderManager, AMQ_SCHEDULED_DELAY=53564.4233}, readOnlyProperties = false, readOnlyBody = false, droppable = false, text = <?xml version="1.0" encoding="utf-16"?>
<Com...mandMessage>}, exception: java.lang.NullPointerException | org.apache.activemq.broker.TransportConnection.Service | ActiveMQ Transport: tcp:///REDACTED:50161
java.lang.NullPointerException
at org.apache.activemq.broker.scheduler.SchedulerBroker.send(SchedulerBroker.java:179)
at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
at org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:96)
at org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:227)
at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
at org.apache.activemq.security.AuthorizationBroker.send(AuthorizationBroker.java:192)
at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:135)
at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:462)
at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:677)
at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:311)
at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:185)
at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:228)
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:220)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:202)
at java.lang.Thread.run(Thread.java:595)
2011-03-07 10:14:44,577 | WARN | Async error occurred: java.lang.NullPointerException | org.apache.activemq.broker.TransportConnection.Service | ActiveMQ Transport: tcp:///REDACTED:50161
java.lang.NullPointerException
at org.apache.activemq.broker.scheduler.SchedulerBroker.send(SchedulerBroker.java:179)
at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
at org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:96)
at org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:227)
at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
at org.apache.activemq.security.AuthorizationBroker.send(AuthorizationBroker.java:192)
at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:135)
at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:462)
at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:677)
at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:311)
at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:185)
at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:228)
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:220)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:202)
at java.lang.Thread.run(Thread.java:595)

Categories

Resources