Saturday, September 26. 2009morgen wird ein Änderhaken gesetzt![]() Morgen ist ein wichtiger Termin für Deutschlands Zukunft. Die Bundestagswahl wird unsere Zukunft beeinflussen. Und jeder Wahlberechtigte hat einen Einfluss. Er mag klein sein, aber er ist wichtig. Ich möchte jeden ermutigen sich folgendes durchzulesen (falls noch nicht geschehen). Und wem es so geht wie es bei mir auch mal war, dass der Name "Piraten" abschreckt, den bitte ich den Namen mal eben zu ignorieren und statt dessen auf die Inhalte zu schauen.
Thursday, June 18. 2009qemu/kvm and Vista
![]() As I've seen some bug reports on this issue and no solution I thought I'd post mine: Running Vista in qemu/kvm is mostly no problem. Except for user mode networking. Apparently Vista decides that it doesn't like the qemu DHCP server and ignores the IP it is assigned. Of course user net doesn't work then. The simple solution is to give Vista a fixed IP, but which IP should you actually give it? There's only one that makes everything work right, and that is 10.0.2.15. Found this out by looking through the qemu code. If you don't use this IP then -redir won't work. And that was a major issue for me. Hope it helps somebody. Saturday, May 9. 2009KUbuntu 9.04 hangs
![]() Dear Lazyweb, what is the best way to debug a problem with the session DBus apparently getting stuck? The KDE4 session on this computer becomes completely unresponsive. An ssh login still works but a simple export DISPLAY=:0 qdbusdoesn't return. No output at all. qdbus --systemstill works. Running strace qdbusshows it waiting on a read on some pipe it created right after reading /var/lib/dbus/machine-id. ps aux showed two session busses running. One from the user and another one from root. The root session bus was probably created by running Adept a few minutes before. strace on the dbus process of the user showed it polling and calling gettimeofday, apparently at timeouts. Attaching gdb to the session bus didn't give me any information Anyway, I don't know enough about dbus and I would like to get rid of this annoying hang. Whatever you try to do with the computer, in the end you have to fall back to SysRq + {S, U, B} since nothing else can get the system back. Any ideas how to get more information on what could be the cause? Thursday, May 7. 2009Do you need 128 1s?![]() When programming with SSE there are some cases where you need a double-quad vector filled with all 1s. E.g. for a simple bitwise not: _mm_andnot_ps(x, 1);
(This does a (~x & ~0) which of course is equal to ~x, the bitwise not we were looking for.) The bitwise not is necessary to implement some of the missing comparisons. SSE2 only has integer comparisons for ==, < and >. To implement !=, <= and >= you need a bitwise not.
So now that I motivated your need for a double quad with all 1s, where do you get it from? Well, easy, you say. Put a constant there. OK, it's 128 bits big, but what does that matter. And you're right, except if the constant is not in the L1 cache. Because then the load of the constant from L2 cache will introduce some unnecessary latency. So yes, it's a solution but not the nicest one. Here's a better one. Remember that a comparison in SSE gives you a full double-quad. And if the comparison of the entries in the vector says they were all equal (for cmpeq, that is) you get a double-quad filled with 1s. Great... let's do it: static inline __m128 _my_setallone() {
Works. Nice... except gcc warns about an uninitialized variable r being used. Looking at the generated code we see it added another xor instruction to initialize the register to 0. Ugh.
__m128 r; return _mm_cmpeq_ps(r, r); } I can do better than two instructions. I want one! So inline assembly it is: static inline __m128 _my_setallone() {
You'd expect that to work? I sure did. And sometimes it did. Sometimes it didn't. Huh? Guessing... put a __volatile__ there: Less failures. But not cured. So remove the __volatile__ again and objdump -d the binary while doing instruction steps in gdb in a split view in Konsole (nice feature there!). And what do I see. After cmpeqps was called on a register that register is all 0s! Why oh why? How can the same thing not be equal. So I look at the value of the register before the call: 4 NaNs (at least when interpreted as 4 floats). I slap my head, remember that NaNs are never equal to anything, and look for the integer comparison instruction.
__m128 r; __asm__ ("cmpeqps %0,%0":"=x"(r)::); return r; } The result: static inline __m128i _my_setallone() {
Perfect. Now it works. I am able to do a bitwise not in two instructions (gcc is able to keep the xmm register around for another pandn, so this is also as good as it can get) and I don't have to worry about the cache at all.
__m128i r; __asm__ ("pcmpeqb %0,%0":"=x"(r)::); return r; } Lesson learned: don't mess with floating point instructions when trying to do bit magic. Wednesday, April 22. 2009Programming for Larrabee![]() Short status update from me for all who still don't know: What I wanted to point everybody at, though, is that Intel has released the intrinsics it will be supporting with the Larrabee with the last gaming conference. What I didn't notice until today is that they also released a complete header that allows you to program with those intrinsics now. At home... If you don't know why LRB vector instructions are so cool let me tell you: SSE is nice. You can do four floating point instructions in one (or int, or two doubles...). With LRB the vector width is four times bigger: 16 floats/ints, 8 doubles. But the LRB instructions are a lot nicer than SSE. You have a 16/8 bit mask available to select the entries of the vector the instruction should write. You have all arithmetic instructions for float, int and double available (SSE 4.1 finally brought the multiply instruction for int). You have gather/scatter instructions that make it easy to access data that is stored in structs. You have free conversions and swizzles in the loads and stores. (e.g. you can store data as half-floats and compute as floats, halfing the I/O bandwidth your code needs) Now, intrinsics are already a lot nicer than writing inline assembly. But in the end you want to have a C++ class for this, right? If you do let me know. Friday, February 20. 2009how to do includes right
![]() Perhaps you remember such a discussion on core-devel quite some time ago. It resulted in a section on Techbase about the topic, with all the explanations why to do it that way. Too bad that the people who create the Microsoft Visual Studio stdlib headers haven't read it. This is too stupid... I have a project at university where all the filenames start with a long prefix - and that prefix is the same for all the files. Tedious for opening files, even with auto-completion. So I 'ln -s'ed all the files to a filename without the prefix. This broke my build on Windows (the files are made available to a Windows running in VirtualBox, which is why I can use ln -s) as there now was a Math.h file in the directory. And guess what the MSVC compiler did... The <cmath> include has a #include <math.h> line which made MSVC include my Math.h file instead of the math.h file lying in the same directory as the cmath file. Just to prove my point I fixed the cmath file to use #include "math.h" and now it compiles fine.
So if you write a library and don't know the difference between Friday, January 30. 2009Philipp Poisel Concert
![]() Last night we were at the Philipp Poisel gig in Schwetzingen. Great music and excellent musicians. It was great fun to listen and watch. If you have a chance to see Philipp as he's doing the remaining gigs from his tour, don't miss it! Monday, September 22. 2008Happy Musician
![]() Last night was the first time I played our (my wife plays the guitar as well, actually I initially learned it from her) new guitar on stage. And for quite some time that night I could fall asleep because I was still too happy about the sound and ease of playing. Oh, and the CPX900 in Mocha Black also just looks gorgeous. On some KDE related news: while browsing the Yamaha store for a bit I saw a device that looks so much like a Zaurus - just different symbols on the outer buttons. And it's running Opie and the accompanying computer system (installed below the grand piano's keyboard) is supposed to be running a free and open system. Congrats to Yamaha to what I think are some really good choices there. Wednesday, August 13. 2008download and test Quasar![]() So, there's much interest in the Phonon + Quasar code - as I had hoped To reproduce the result on your computer you need to get current phonon, current phonon-xine (with libxine >= 1.1.12) and current quasar from SVN. For those that don't know where Quasar lives, you can find it here: http://websvn.kde.org/trunk/playground/base/quasar/. To compile quasar you need to set the KDEDIR environment variable to the prefix where you installed phonon and then run qmake and make in the source dir. Then go to the examples/phonon subdir and run ./phonon /path/to/video.ogg. With S and Shift-S you can change the edge detection threshold. Have fun detecting edges in your videos ... Phonon + Quasar![]() I've got it working a long time ago, but since this Akademy it is finally available in KDE trunk: Phonon now can give the raw video frames (as RGB, YV12 or YUY2) to an application and Quasar gained a node to upload those frames as textures and uses Shaders to convert YUV formats to RGB and then do arbitrary effects with them. The cool part about that, obviously, is that the data intensive calculations are happening on the graphics card (you need OpenGL 2 for this to work). To demonstrate the power of this I wrote a simple example that connects the PhononInputNode to an EdgeDetection node and then to a RenderNode. I did a screencapture of the result, but that looks a lot worse than the real performance, which is totally smooth and, of course, doesn't show much CPU usage. You can also see me adjusting the threshold value of the edge detection filter with a keyboard shortcut. Here's the code: m_input = new PhononInputNode();
connect(m_input, SIGNAL(needUpdate()), SLOT(updateGL())); m_compo.addNode(m_input); m_displayNode = m_compo.createNode("/output/render"); m_saturationNode = m_compo.createNode("/color/edgedetect"); Quasar::link(m_input, "output", m_saturationNode, "texture"); Quasar::link(m_saturationNode, "output", m_displayNode, "texture"); Phonon::createPath(m_media, m_input); m_compo.prepare(); connect(m_media, SIGNAL(finished()), m_media, SLOT(play())); m_media->play(); Things to note:
Tuesday, July 29. 2008Akademy Travel
![]() As For the train I'd probably take the ICE 610 (12:35 Mannheim - Köln) and ICE 14 (14:44 Köln - Bruxelles-Nord) on Fr, 8th, of course. But sharing a car ride would probably be cheaper. Now back to exam preparations... Monday, January 21. 2008more UI feedback![]() After a month of no KDE coding I'm back to do a few things in KDE again - though I really want to (and need to) do more for University if I ever want to get done with it... Anyway, what I wanted to show is how to do simple animations in the UI that should help the user to understand how the different UI elements play together. I have one such case with the Phonon KCM where I now tried the following animation to clear things up a bit: The way I achieved this effect was to add a special Animation widget that sits above the other widgets and is not added to any QLayout. Reimplement the paintEvent to draw the animation frames and use a QTimeLine member to call repaint(). It needs two pixmaps: one of the old content of the QListView at the right and one with the new content. The paintEvent then draws the old content over the QListView so that it seems the widget contents have not changed yet and draws the new content depending on the frame number of QTimeLine (with 50% opacity). QTimeLine::finished() is connected to the deleteLater slot which removes the animation widget. Here's the code: class SelectionChangeAnimation : public QWidget
{ public: SelectionChangeAnimation(const QRect &sourceRect, QWidget *destWidget, QWidget *parent); void start(); protected: void paintEvent(QPaintEvent *); bool eventFilter(QObject *, QEvent *); private: QTimeLine m_timeLine; QPixmap m_old, m_new; QRect m_sourceRect; QRect m_destRect; QWidget *m_destWidget; bool m_needPixmapUpdate; }; SelectionChangeAnimation::SelectionChangeAnimation(const QRect &sourceRect, QWidget *destWidget, QWidget *parent) : QWidget(parent), m_timeLine(200), m_sourceRect(sourceRect), m_destRect(destWidget->mapTo(parent, QPoint(0, 0)), destWidget->size()), m_destWidget(destWidget), m_needPixmapUpdate(true) { setGeometry(m_sourceRect | m_destRect); m_sourceRect.moveTopLeft(mapFrom(parent, m_sourceRect.topLeft())); m_destRect.moveTopLeft(mapFrom(parent, m_destRect.topLeft())); m_old = QPixmap::grabWidget(m_destWidget); m_timeLine.setFrameRange(0, 63); connect(&m_timeLine, SIGNAL(finished()), SLOT(deleteLater())); m_destWidget->installEventFilter(this); show(); } void SelectionChangeAnimation::start() { m_timeLine.start(); connect(&m_timeLine, SIGNAL(frameChanged(int)), SLOT(repaint())); } bool SelectionChangeAnimation::eventFilter(QObject *o, QEvent *e) { if (o == m_destWidget && e->type() == QEvent::Paint) { m_needPixmapUpdate = true; } return QWidget::eventFilter(o, e); } void SelectionChangeAnimation::paintEvent(QPaintEvent *) { const int f = m_timeLine.currentFrame(); const QRect animRect = QRect( m_sourceRect.x() + ((m_destRect.x() - m_sourceRect.x()) * f >> 6), m_sourceRect.y() + ((m_destRect.y() - m_sourceRect.y()) * f >> 6), m_sourceRect.width() + ((m_destRect.width() - m_sourceRect.width()) * f >> 6), m_sourceRect.height() + ((m_destRect.height() - m_sourceRect.height()) * f >> 6)); // by masking the widget the flicker when deleting the animation widget is reduced setMask(QRegion(animRect) + QRegion(m_destRect)); QPainter p(this); p.drawPixmap(m_destRect, m_old); if (m_needPixmapUpdate) { m_destWidget->removeEventFilter(this); m_new = QPixmap::grabWidget(m_destWidget); m_destWidget->installEventFilter(this); } p.setOpacity(0.5); p.drawPixmap(animRect, m_new); } Thursday, December 13. 2007got a present today![]() Today I checked my mails and saw a few Phonon-related commits. I always read those commit messages with priority... and I was a bit surprised. I knew this day would come. But I didn't know when and I didn't know whether it's going to be GPL+commercial or LGPL. And I found the commit messages all said "[License: LGPL]". *dance* Now what does that license mean? It means everybody can contribute without having to sign a copyright assignment. That just makes it so much easier to handle contributions! Now I know what code I'm going to read and play with the next days. Sunday, December 9. 2007going crazySaturday, December 8. 2007QWidget::render
![]() Yesterday on IRC I was reminded of the nice abstractions Qt has with QPaintDevice. (There are many useful paint devices, but most important for this discourse are QWidget, QPixmap and QImage.) So there are several things Qt4 allows you to do:
Inspired by the video from Mirco Müller I wanted to see what could be done with those functions. I started with setRedirected but couldn't make it work immediately. So I did what the docs said and tried QPixmap::grabWidget. And without much effort I was able to draw a widget someplace else. But then I wanted to transform the image which needs a conversion to QImage. Expecting that Qt might optimize a bit if it renders directly into a QImage instead of a QPixmap and then converts to QImage I used QWidget::render to render a widget directly onto a QImage. Piece of cake. Now I had a QImage, transformed and painted into a different widget. Last missing piece is to update the image if the original widget changes (e.g. mouse or keyboard events). QObject::installEventFilter makes it easy to listen for paint events on the other widget and update accordingly. And to make it a fully featured class I added the ability to look for child widget paint events and made it repaint only as little as needed. The result is this code: int main(int argc, char **argv)
which makes for this (All the artifacts and "unsmoothness" are results of the screen-capture).{ QApplication app(argc, argv); QWidget topLevel; QWidget w(&topLevel); WidgetMirror leMirror(&topLevel); leMirror.setMirroredWidget(&w); QPushButton b("Button", &w); QLineEdit le(&w); QListWidget lw(&w); lw.setMaximumHeight(64); lw.addItems(QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4" << "Item 5" << "Item 6" << "Item 7" << "Item 8"); QGridLayout layout(&w); layout.setMargin(0); layout.addWidget(&b, 0, 0, Qt::AlignBottom); layout.addWidget(&le, 0, 1, Qt::AlignBottom); layout.addWidget(&lw, 0, 2, Qt::AlignBottom); QVBoxLayout outerLayout(&topLevel); outerLayout.setSpacing(0); outerLayout.addWidget(&w); outerLayout.addWidget(&leMirror); topLevel.show(); return app.exec(); } Today I wanted to see whether this eye-candy can be put into KDE at some place and I have not succeeded. Perhaps somebody can make a mockup of how this could be used without making you feel "something is wrong". Notice that all this is just fooling around with what Qt provides. This is neither useful nor going into KDE 4.0 For the interested people, the implementation of WidgetMirror looks like this: Continue reading "QWidget::render"
(Page 1 of 4, totaling 54 entries)
» next page
|
Calendar
QuicksearchCategoriesSyndicate This BlogBlog Administration |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||

