How to find GPU memory(video memory) using NVAPI - memory

I am using NVAPI, I can get some performance data by calling this function:
NvAPI_GPU_GetDynamicPstatesInfoEx
But don't know how to get video memory usage. I find some c# codes call this function to get it.
NVAPI.NvAPI_GPU_GetMemoryInfo
But there is no the same function in NVAPI.
Any idea?

Does it have to be in NVAPI? If not, check out Nvidia PerfKit: http://developer.nvidia.com/nvidia-perfkit

In case somebody still needs this, you can use this library:
https://github.com/falahati/NvAPIWrapper
Find the right GPU using the NvAPIWrapper.GPU.PhysicalGPU.GetPhysicalGPUs() static method.
Use the NvAPIWrapper.GPU.PhysicalGPU.MemoryInfo property to get the total memory, available memory and other information relative to memory.

Related

Get Direct3D device from Direct2D render target

I'm using Direct2D to render my user interface.
What I would like is to be more easily able to profile my ui rendering (since I'm using several panels using Graphics debugger is a bit cumbersome).
Since I know that Direct2D uses a Direct3D device (exactly d3d11 device using 10_0 feature level) under the hood, I'd like to know if it is possible to retrieve either a ID310Device or ID3D11Device instance from ID2D1RenderTarget or ID2D1Factory object.
In that case I would easily be able to attach a timestamp query on the BeginDraw/EndDraw calls.
I tried several QueryInterface calls, but none of them have been sucessful so far.
An interesting undocumented secret is that any ID2D1RenderTarget you get from ID2D1Factory will also be an ID2D1DeviceContext (it seems to be intentional from what I've gathered, just accidentally undocumented?). Just call IUnknown::QueryInterface() to snag it. From there you can toy around with methods like GetDevice() and GetTarget(). If you can get the target then you may be able to weasel your way to obtaining the IDXGISurface which supports IDXGIDeviceSubObject::GetDevice() https://msdn.microsoft.com/en-us/library/windows/desktop/bb174529(v=vs.85).aspx (I haven't verified this part)
And in Win10 it looks like ID2D1Device2 gives you precisely what you want: GetDxgiDevice() https://msdn.microsoft.com/en-us/library/windows/desktop/dn917489(v=vs.85).aspx . So in that case, your ID2D1RenderTarget is cast to an ID2D1DeviceContext via IUnknown::QueryInterface(), and then you get an ID2D1Device via ID2D1DeviceContext::GetDevice() and then cast it to an ID2D1Device2 via another call to IUnknown::QueryInterface().

Is NSData + (id)dataWithContentsOfURL:(NSURL *)aURL options:(NSDataReadingOptions)mask error:(NSError **)errorPtr: cached automatically?

When I read the section on
NSDataReadingOptions
Options for methods used to read NSData objects.
enum {
NSDataReadingMappedIfSafe = 1UL << 0,
NSDataReadingUncached = 1UL << 1,
NSDataReadingMappedAlways = 1UL << 3,
};
typedef NSUInteger NSDataReadingOptions;
It says that
NSDataReadingUncached
A hint indicating the file should not be stored in the file-system caches.
For data being read once and discarded, this option can improve performance.
Available in OS X v10.6 and later.
Declared in NSData.h.
So I am assuming that by default these URL requests are cached and there is no need to implement NSURLRequest to cache data if I want to use shared global cache ? Is this understanding correct ?
Let me start off by saying that dataWithContentsOfURL:options:error: and its ilk are probably the worst APIs for getting something from network. They are very alluring to developers because they can get a resource from network in a single line of code, but they come with some very pernicious side-effects:
First, they block the thread on which they are called. This means that if you execute this on the main thread (the only thread on which your UI can be updated), then your application will appear frozen to the user. This is a really big 'no no' from a user experience perspective.
Second, you cannot cancel these requests, so even if you put this request on a background thread, it will continue to download even though the data may no longer be useful. For example, if your user arrives on a view controller and you execute this request and the user subsequently decides to hit a back button, that data will continue to download, even though it is no longer relevant.
Bottom line: DO NOT USE THESE APIs.
Please use async networking like NSURLConnection or AFNetworking. These classes were designed to get data efficiently and in a way that doesn't impact the user experience. What's even better is that they handle the specific use case you originally asked: how do I stop it from caching on disk?.
There is no answer to your specific question which refer to the caches managed by the URL loading system.
The reading options in method dataWithContentsOfFile:options:error: refer solely to reading from the file system (please consult to the official documentation of NSDataReadingOptions).
Unfortunately, the documentation gives no hint about the behavior when reading from remote resources. Whether the response is cached in the URL cache is unspecified - that is, we don't know, and the internal behavior and implementation can change with each new OS version.
IMHO, we should generally avoid to use the "convenient methods" to read from remote resources. It appears, these methods work only by "accident" when accessing remote resources. So, I strongly agree with #Wayne Hartman ;)

How obtain a screenshot of the ChromiumEmbedded browser in Delphi XE2/Firemonkey?

Have tried to obtain a screenshot from the ChromiumEmbedded browser for Delphi XE2/Firemonkey, but the ChromiumFMX.MakeScreenshot method only returns an empty bitmap.
Anyone have any idea how to obtain a bitmap?
Thx.
Instead, use the following (be sure to instantiate YourBitmap prior to this call):
CefGetBitmap(ChromiumFMX.Browser, PET_VIEW, YourBitmap);

How to obtain all OIDs from all MIBs

I would like obtain a list of all OIDs in the MIBs that are loaded on a manager and display it to users so that they can choose which MIB object to perform the GET/SET request. I would also like to obtain the syntax and max-access of the object. I'm programming using C++. I want to parse the MIBs to obtain the OIDs, not use snmpwalk. I am trying to use the Net-SNMP MIB_API. I've looked at the manual page but am not clear of how to use the functions to achieve what I want to do.
I see that read_all_mibs() is already called when we call init_mib(). That means I don't need to call read_all_mibs() again, right? Could anyone please guide on what is the next step after init_mib() that I should do.
Any help would be much appreciated. Thanks.
You should look at the apps/snmptranslate.c file for an example of how to walk the loaded mib tree to get information like the syntax and max-access details.
And, no, if you call init_snmp() or init_mib() you don't need to call read_all_mibs()

cvRetrieveFrame intricacies - openCV

The Documentation of OpenCV mentions that "the returned image (by cvRetrieveFrame) should not be released or modified by the user" ...
Link: http://opencv.willowgarage.com/documentation/c/highgui_reading_and_writing_images_and_video.html#retrieveframe
I am trying to debug my code, which involves the following steps:
Retrieve frame from video using cvRetrieveFrame()
Do some processing on the frame
output results
My instinct says that something is wrong with cvRetrieveFrame() because if I manually input frames using cvLoadImage, the program works fine. But I am not getting same results while using cvRetrieveFrame().
Since the documentation mentions such a restriction, any reason for such a restriction ? And, any alternatives ?
Have a great day
Before you call this function, you should have used another function which is cvGrabFrame() in order to be able to use the mentioned function, which you can use it for doing any necessary processing on the frame (such as the decompression stage in
the codec) and then return an IplImage* pointer that points to another internal buff er
(so do not rely on this image, because it will be overwritten the next time you call
cvGrabFrame()).

Resources